• 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) QUESTION about SetPlayerStorageValue

Whiskey

a Bear.
Joined
Feb 19, 2009
Messages
27
Reaction score
0
I have a simple question about setPlayerStorageValue(cid,storage,value) function: Can I add 1 or remove 1 value from a specific storage? Not change it to a certain number, but ADD or REMOVE one (or more) from actual player storage value state?
 
I don't want it removed. I want to decrease or increase the value...

ps. Besides it won't remove it, storage will remain with value -1.
 
Last edited:
Code:
function increaseStorageValue(cid, key, amount)
	amount = amount or 1
	if(isPlayer(cid)) then
		doPlayerSetStorageValue(cid, key, getPlayerStorageValue(cid, key) + amount)
	end
	return true
end

Like this? ;p
 
Code:
function increaseStorageValue(cid, key, amount)
	amount = amount or 1
	if(isPlayer(cid)) then
		doPlayerSetStorageValue(cid, key, getPlayerStorageValue(cid, key) + amount)
	end
	return true
end

Like this? ;p

stop failing man!
What he means is he wants the "key" to change not the storage value:
Ex:
Shinmaru -> Key = 12345 -> StorageValue = -1 or 0 or 1(whatever) but I insist on what iruga said it has to be done to D, but maybe there can be a work around, I just haven't figured it out.

Edit:
Here is a mock-up function:
Code:
function increaseStorageKey(cid, key, amount, storage)
	amount = amount or 1
	if(isPlayer(cid)) then
		doPlayerSetStorageValue(cid, key, -1)
	end
	key = key+amount
	return doPlayerSetStorageValue(cid, key, storage)
end
Question is, if the storage is set to -1, will it remove the key from the DB?
 
Last edited:
no.

to erase storage, use setPlayerStorageValue(cid, key) (without value) :p

Thanks!
then it can be erased!

Credits to Chojrak and Cykotitan

this should work!
Code:
function increaseStorageKey(cid, key, storage, amount)
	amount = amount or 1
	if(isPlayer(cid)) then
		doPlayerSetStorageValue(cid, key)
	end
	key = key+amount
	return doPlayerSetStorageValue(cid, key, storage)
end

function decreaseStorageKey(cid, key, storage, amount)
	amount = amount or 1
	if(isPlayer(cid)) then
		doPlayerSetStorageValue(cid, key)
	end
	key = key-amount
	return doPlayerSetStorageValue(cid, key, storage)
end
 
Back
Top