Hello Graalians,
I'm doing a staff tools system but the public functions I use do not work (and they are both in Clientside). It say in F2 that the function aren't found.
Here is my code of -Staff/Tools:
PHP Code:
// Scripted by Joe (Developer)
this.join("function_staff");
function onActionServerSide(){
if (params[0] == "check")
{
if(!isStaff(player.account))
{
findplayer(player.account).removeweapon(this.name);
echo("StaffTools:" @ player.nick @ "(" @ player.communityname @ "(" @ player.account @ ")) Tried to use Staff Tools,but his not staff.");
}
}
}
//#CLIENTSIDE
function onCreated()
{
//Checking if player is Staff
triggerserver("weapon", this.name,"check");
//Basics Variables
this.equipweapon = false;
//Create Tools Array
this.buttonArray = {
{0,"default","-Staff/Tools","Open/Close Staff Tools"},
{1,"boots","-Staff/Boots","Boots"},
{2,"stealth","-Staff/Stealth","Stealth"},
{3,"drag","-Staff/Drag","Drag"},
{4,"staffstick","-Staff/Stick","Staff Stick"},
{5,"punish","-Staff/Punish","Punish"}
};
//Create GUI
createStaffToolsWindow(this.buttonArray);
}
function createStaffToolsWindow(buttonArrayTabs){
//Basics Variables
temp.staffToolX = screenwidth - 120;
temp.staffToolY = 20;
for (temp.i = 0; i < buttonArrayTabs.size(); i++)
{
new GuiBitmapButtonCtrl("StaffToolsW_Button_" @ temp.i) {
x = temp.staffToolX;
y = temp.staffToolY;
width = height = 44;
normalbitmap = "peria_stafftools-button-" @ buttonArrayTabs[i][1] @ "-off.png";
mouseoverbitmap = "peria_stafftools-button-" @ buttonArrayTabs[i][1] @ "-hover.png";
pressedbitmap = "peria_stafftools-button-" @ buttonArrayTabs[i][1] @ "-on.png";
hint = buttonArrayTabs[i][3];
alpha = .85;
this.getId = buttonArrayTabs[i][0];
this.getName = buttonArrayTabs[i][1];
this.getWeapon = buttonArrayTabs[i][2];
this.toolOpen = false;
thiso.catchevent(this, "onAction", "onStaffToolsButtonAction");
if(buttonArray[i][1] == "boots"){
new GuiMLTextCtrl("StaffTools_Button_Boots_Text") {
profile = GuiBlueMLTextProfile;
x = 28;
y = 3;
text = "";
}
}
//Hide all Button, not the first
if(temp.i > 0){
this.hide();
}
else{
this.show();
}
}
//Increment y
temp.staffToolY += 50;
}
}
function onKeyPressed(code,key) {
if (key == "t")
{
temp.ButtonDefault = new GuiBitmapButtonCtrl("StaffToolsW_Button_" @ this.buttonArray[0][0]);
onStaffToolsButtonAction(temp.ButtonDefault);
}
}
function onStaffToolsButtonAction(obj)
{
for (temp.i = 0; i < this.buttonArray.size(); i++)
{
if(this.buttonArray[i][0] == obj.getID)
{
if((@ obj.getWeapon).isOpenTool()){
obj.normalbitmap = "peria_stafftools-button-" @ obj.getName @ "-off.png";
obj.mouseoverbitmap = "peria_stafftools-button-" @ obj.getName @ "-hover.png";
obj.pressedbitmap = "peria_stafftools-button-" @ obj.getName @ "-on.png";
player.chat = obj.getName SPC ": Off";
if((@ obj.getWeapon) == this.name)
{
for (temp.e = 1; e < this.buttonArray.size(); e++){
temp.Window = new GuiBitmapButtonCtrl("StaffToolsW_Button_" @ temp.e);
temp.Window.hide();
}
}
(@ obj.getWeapon).closeTool();
}
else{
obj.normalbitmap = "peria_stafftools-button-" @ obj.getName @ "-on.png";
obj.mouseoverbitmap = "peria_stafftools-button-" @ obj.getName @ "-on.png";
obj.pressedbitmap = "peria_stafftools-button-" @ obj.getName @ "-off.png";
player.chat = obj.getWeapon SPC ": On";
if((@ obj.getWeapon) == this.name)
{
for (temp.e = 1; e < this.buttonArray.size(); e++){
temp.Window = new GuiBitmapButtonCtrl("StaffToolsW_Button_" @ temp.e);
temp.Window.show();
}
}
(@ obj.getWeapon).openTool();
}
}
}
}
function closeTool() {
this.equipweapon = false;
//this.onCreated();
}
function openTool() {
this.equipweapon = true;
}
function isOpenTool() {
if(this.equipweapon = true){
return true;
}
else{
return false;
}
}
and here the -Staff/Boots (which contains public function used in -Staff/Tools):
PHP Code:
// Scripted by Joe
//#CLIENTSIDE
function onCreated(){
this.equipweapon = false;
this.speed = 1;
setTimer(0);
}
function onKeyPressed(code,key)
{
if (this.isOpenTool())
{
this.openTool();
setTimer(0.05);
if (code == 187)
{
if (this.speed+1 <= 30)
{
this.speed+=1;
player.chat = "Speed: " @ this.speed;
}
}
else if (code == 109)
{
if (this.speed-1 >= 0)
{
this.speed-=1;
player.chat = "Speed: " @ this.speed;
}
}
}
}
function onTimeOut()
{
if (this.isOpenTool())
{
for (a=0; a<4; a++)
{
if (keydown(a))
{
switch(a)
{
case "0":
player.y-=this.speed;
break;
case "1":
player.x-=this.speed;
break;
case "2":
player.y+=this.speed;
break;
case "3":
player.x+=this.speed;
break;
}
}
}
}
setTimer(0.05);
}
public function closeTool() {
this.equipweapon = false;
this.onCreated();
}
public function openTool() {
this.equipweapon = true;
}
public function isOpenTool() {
if(this.equipweapon = true){
return true;
}
else{
return false;
}
}
Thanks for your help,
Joe.