| Blockland Forums > Modification Help |
| Setting an item to slot 4. |
| << < (2/3) > >> |
| Daenth:
Alright, I'm having an issue with that bit of code. I'm testing it out and no matter what it doesn't add the weapon to my inventory. I set it to a command like... --- Code: ---function serverCmdgunswitchtest(%client,%player) { %item = gunItem.getID(); %slot = 1; %oldTool = %player.tool[%slot]; %player.tool[%slot] = %item; messageClient(%player.client,'MsgItemPickup','',%slot,%item); if(%oldTool <= 0) player.weaponCount++; } --- End code --- I type in /gunswitchtest and my inventory doesn't change. |
| Chrono:
--- Quote from: Destiny/Zack0Wack0 on April 20, 2011, 09:18:43 PM --- --- Code: ---if(%oldTool <= 0) %player.weaponCount++; --- End code --- --- End quote --- Not every item is a weapon. |
| Destiny/Zack0Wack0:
--- Quote from: Daenth on May 17, 2011, 07:33:24 PM --- --- End quote --- Is %player actually a player object or are you just trying to get the client who used the command's player object? If so, use %client.player |
| Daenth:
--- Quote from: Destiny/Zack0Wack0 on May 17, 2011, 11:54:31 PM ---Is %player actually a player object or are you just trying to get the client who used the command's player object? If so, use %client.player --- End quote --- Even if I switch, it won't work. =/ |
| Red_Guy:
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 --- |
| Navigation |
| Message Index |
| Next page |
| Previous page |