• 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!

Lua executeQuery to add storage?

seto sazo

Member
Joined
Apr 27, 2009
Messages
162
Reaction score
21
Noob question. Whats the executeQuery to add a storage value such as 1234 to a player in a script?
 
You should check first for player id then check if he has that storage value their,if it is there then you will use UPDATE else you should use INSERT
 
So this?
Lua:
  db.executeQuery("INSERT `player_storage` SET `key` = 1234, 'value' = 1, WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")
 
You should use insert ignore then after it use the update

Lua:
  db.executeQuery("INSERT IGNORE INTO `player_storage` SET  `player_id` = '" .. getPlayerGUID(cid) .. "' `key` = '1234', 'value' = '-1' ;") -- this insert the storage if not exist
  db.executeQuery("UPDATE `player_storage` SET  'value' = '1' WHERE `player_id` = '" .. getPlayerGUID(cid) .. "' AND `key` = '1234' ;")-- this sets the storage to value
 
You should use insert ignore then after it use the update

Lua:
  db.executeQuery("INSERT IGNORE INTO `player_storage` SET  `player_id` = '" .. getPlayerGUID(cid) .. "' `key` = '1234', 'value' = '-1' ;") -- this insert the storage if not exist
  db.executeQuery("UPDATE `player_storage` SET  'value' = '1' WHERE `player_id` = '" .. getPlayerGUID(cid) .. "' AND `key` = '1234' ;")-- this sets the storage to value
>insert
>set
EkOow.png
 
Back
Top Bottom