• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

AddItem for player online/offline TFS 0.4 r3884

Please read the rules. Support board is if you have problem with: Engine, Source, Website, and so on. That you writed is for request.
 
You should state what server / version you are using, making it easier for people to help you.

Your problem is that you want to give an item to a player wether he is online or not. If the player is offline, you have to inject code into the SQL directly, although this won't work if he's online.

You have to make an `if`-statement, checking if the player is online, should he be online, then you can just copy the functionality from the additem script, otherwise you'd have to, as I previously mentioned, make a query in this fashion:

Code:
db.query("INSERT INTO `player_items`  SET `player_id` = x, `itemtype` = y, `count` = z")

Then there are continous problems where you want to place it (backpack, hand, feet), if the player has no capacity / room, then you might want to insert into the depot, etc. The lua function Player::addItem~ takes care of all of this, but if you're going to do it manually, you have to check these things yourself.

I hope this helps.

Ignazio.
 
Back
Top