Author Topic: Need help with a Script  (Read 1558 times)

Today I was making a short little script that when Super Admins type /wrench they get a wrench, but I'm having problems. I've been trying to solve the problems by myself all day, but I couldn't fix it. Here's the script.
Code: [Select]
package Wrenchcmd{
   function serverCmdWrench(%client)
{
%player = %client.player;
if(%client.isSuperAdmin);{
return;
if(isObject(%player))
{
%player.updateArm(wrenchImage);
%player.mountImage(wrenchImage,0);
}
}
};
ActivatePackage(Wrenchcmd);

I tryed to help.But Failed :(.
« Last Edit: June 19, 2008, 09:01:43 PM by LTvic »


Count your brackets there. You're opening 4 and ending 3.

So I do it like this?
Code: [Select]
package Wrenchcmd{
   function serverCmdWrench(%client)
{
%player = %client.player;
if(%client.isSuperAdmin);{
return;
if(isObject(%player))
{
%player.updateArm(wrenchImage);
%player.mountImage(wrenchImage,0);
}
   }
      }
};
ActivatePackage(Wrenchcmd);

Well it will give a wrench in inventory slot 4 I think didn't test.
Code: [Select]
function servercmdwrench(%client)
{
         if(%client.isAdmin || %client.isSuperAdmin)
{
         %client.player.tool[4] = nametoID(WrenchItem);
         messageClient(%client, 'MsgItemPickup', '', 4, nametoID(WrenchItem));
         bottomPrintAll("\c2" @ %client.name @ " \c6 has Claimed a Wrench!",5,3);
}

Code: [Select]
package Wrenchcmd{
   function serverCmdWrench(%client)
{
%player = %client.player;
if(!%client.isSuperAdmin)
return;
if(isObject(%player))
{
%player.updateArm(wrenchImage);
%player.mountImage(wrenchImage,0);
}
}
};
ActivatePackage(Wrenchcmd);

You opened a bracket where it wasn't necessary and didn't close it, also you were checking if were a super admin and returning instead of if they weren't.

Code: [Select]
package Wrenchcmd{
   function serverCmdWrench(%client)
*{*
%player = %client.player;
if(!%client.isSuperAdmin)
return;
if(isObject(%player))
{
%player.updateArm(wrenchImage);
%player.mountImage(wrenchImage,0);
}
}
};
ActivatePackage(Wrenchcmd);

You opened a bracket where it wasn't necessary and didn't close it, also you were checking if were a super admin and returning instead of if they weren't.
Is the bracket with the two *'s around it the unnecessary one?

Well it will give a wrench in inventory slot 4 I think didn't test.
Code: [Select]
function servercmdwrench(%client)
{
         if(%client.isAdmin || %client.isSuperAdmin)
{
         %client.player.tool[4] = nametoID(WrenchItem);
         messageClient(%client, 'MsgItemPickup', '', 4, nametoID(WrenchItem));
         bottomPrintAll("\c2" @ %client.name @ " \c6 has Claimed a Wrench!",5,3);
}
This script doesn't work you do /wrench you get the wrench on the 4th slot, but its like the wrench isn't there. Try it and you'll see what I mean.
« Last Edit: June 20, 2008, 01:08:16 PM by HellsHero »

I know I've had that bug before I didn't test it so ya.

Code: [Select]
function servercmdwrench(%client)
{
         if(%client.isAdmin || %client.isSuperAdmin)
{
         %client.player.tool[4] = nametoID(WrenchItem);
         messageClient(%client, 'MsgItemPickup', '', 4, nametoID(WrenchItem));
         bottomPrintAll("\c2" @ %client.name @ " \c6 has Claimed a Wrench!",5,3);
}
For god sakes, count your loving brackets.
Use this

Code: [Select]
function servercmdwrench(%client)
{
         if(%client.isAdmin || %client.isSuperAdmin)
        {
         %client.player.tool[4] = nametoID(WrenchItem);
         messageClient(%client, 'MsgItemPickup', '', 4, nametoID(WrenchItem));
         bottomPrintAll("\c2" @ %client.name @ " \c6 has Claimed a Wrench!",5,3);
        }
}

Code: [Select]
function servercmdwrench(%client)
{
         if(%client.isAdmin || %client.isSuperAdmin)
{
         %client.player.tool[4] = nametoID(WrenchItem);
         messageClient(%client, 'MsgItemPickup', '', 4, nametoID(WrenchItem));
         bottomPrintAll("\c2" @ %client.name @ " \c6 has Claimed a Wrench!",5,3);
}
For god sakes, count your loving brackets.
Use this

Code: [Select]
function servercmdwrench(%client)
{
         if(%client.isAdmin || %client.isSuperAdmin)
        {
         %client.player.tool[4] = nametoID(WrenchItem);
         messageClient(%client, 'MsgItemPickup', '', 4, nametoID(WrenchItem));
         bottomPrintAll("\c2" @ %client.name @ " \c6 has Claimed a Wrench!",5,3);
        }
}
I did that fix the first day, but it didn't help realy.

Tri

Use GMP`s method.