• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

ifOnlyOnce

Erexo

Kage
Premium User
Joined
Mar 27, 2010
Messages
741
Solutions
5
Reaction score
193
Location
Pr0land
GitHub
Erexo
Hello, i would like to present my very simple lua function.
ifOnlyOnce(cid, storage)

Lua:
function ifOnlyOnce(cid,storage)
	if getPlayerStorageValue(cid, storage) >= 0 then
	return FALSE
	else
	setPlayerStorageValue(cid, storage, 1)
	return TRUE
	end

end

Ive made many quests, so that function is very useful to me, if someone need this, feel free to use :)

EX:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if ifOnlyOnce(cid, 65432) then
		doPlayerAddItem(cid,2152,79)
		doPlayerAddItem(cid,2160,1)
	else
		doPlayerSendCancel(cid, "Nothing usefull here")
	end
	return TRUE
end
 
Last edited:
well done, just fix the typo error at the example jajaja
but gj bro ^^

i think this should works too

Lua:
function ifOnlyOnce(cid, storage)
	return (getPlayerStorageValue(cid, storage) >= 0 and FALSE) or (setPlayerStorageValue(cid, storage, 1) and TRUE)
end
 
Last edited:
Back
Top