Blockland Forums > Modification Help
Setting an item to slot 4.
Daenth:
--- Quote from: Red_Guy on May 18, 2011, 03:23:19 PM ---the %player in your command is never set to anything, and your script expects it to be set -- so its not going to work.
try this:
--- Code: ---function serverCmdgunswitchtest(%client)
{
%player = %client.player;
%slot = 1;
if (!isObject(%client.oldTool))
{
%item = %player.oldTool;
}
else
{
%item = gunItem.getID();
}
%player.oldTool = %player.tool[%slot];
%player.tool[%slot] = %item;
messageClient(%client,'MsgItemPickup','',%slot,%item);
}
--- End code ---
--- End quote ---
Tried this and all it does it remove my current item when I type it the first time and when I type it a second time, it puts it back.
Destiny/Zack0Wack0:
--- Code: ---function serverCmdGunSwitchTest(%client)
{
%player = %client.player;
%slot = 1;
%item = gunItem.getID();
%player.tool[%slot] = %item;
messageClient(%client,'MsgItemPickup','',%slot,%item);
}
--- End code ---
Daenth:
--- Quote from: Destiny/Zack0Wack0 on May 19, 2011, 02:42:12 AM ---
--- Code: ---function serverCmdGunSwitchTest(%client)
{
%player = %client.player;
%slot = 1;
%item = gunItem.getID();
%player.tool[%slot] = %item;
messageClient(%client,'MsgItemPickup','',%slot,%item);
}
--- End code ---
--- End quote ---
That works wonderfully, thank you.
Red_Guy:
--- Quote from: Daenth on May 19, 2011, 01:18:38 AM ---Tried this and all it does it remove my current item when I type it the first time and when I type it a second time, it puts it back.
--- End quote ---
thats what happens when I try to script w/o testing things.
this will switch an item with the gun
--- Code: ---function serverCmdgunswitchtest(%client)
{
%player = %client.player;
%slot = 1;
if (isObject(%player.oldTool))
{
%item = %player.oldTool;
}
else
{
%item = gunItem.getID();
}
%player.oldTool = %player.tool[%slot];
%player.tool[%slot] = %item;
messageClient(%client,'MsgItemPickup','',%slot,%item);
}
--- End code ---