Author Topic: [SOLVED] How to give a player an item with a script  (Read 1033 times)

The title says it all.
How do I give a player a specific item with a script?

Please help.
« Last Edit: July 17, 2016, 09:56:40 PM by KozzyMoto »

Look at the Event_AddItem add-on to learn how to do this.


something worth noting is when sending the itemPickup message to the client there is a third argument you can set which is a bool, if turned on it will suppress the *dink* item pickup noise

ie like this:
Code: [Select]
messageClient(%client,'MsgItemPickup','',%slot,%itemId,true);

It seems there is a problem.

When I do this:

$client.player.tool[3] = "65";

The tool only goes into my inventory if I quit the game and restart the server.
Why isn't it working? I'm doing the same exact thing that the Event_AddItem is.


It seems there is a problem.

When I do this:

$client.player.tool[3] = "65";

The tool only goes into my inventory if I quit the game and restart the server.
Why isn't it working? I'm doing the same exact thing that the Event_AddItem is.


Code: [Select]
messageClient(%client,'MsgItemPickup','',%slot,%itemId,true);
this is important because it basically refreshes the inventory for the player.

Oh boi, I feel stupid.
I forgot to do the client thing.

so can we see your code and have an explanation as to why you are using a global variable for client?

also when setting items use itemName.getId() because a datablock ID is dependant on the order that datablocks are loaded, so if you set an item to "65" it will only be the proper item if you are loading with all the same addons, infact 65 might not even be an item datablock if you have other addons enabled


$client.player.tool[3] = "65";

Why are you using global variables?
« Last Edit: July 17, 2016, 10:42:16 PM by Cruxeis »