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

Lua how to set storage value onstepin

ziggy46802

Active Member
Joined
Aug 19, 2012
Messages
418
Reaction score
27
Here is my script

moveevents.xml
Code:
	<!-- Mino check point -->
	<moveevent event="StepIn" itemid="406" script="minocheckpoint.lua"/>

minocheckpoint.lua
Code:
function onStepIn(cid, item, position, fromPosition)
	if item.actionid == 1001 then
		setPlayerStorageValue(cid,9010,2)	
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "9010 is now at 2")
	end

	return true
end

Now when I walk on the tile with action id 1001, i get the message "9010 is now at 2" but when I check my MYSQL database for the storage value 9010, it doesnt even exist???
 
Maybe you need to use spaces...
LUA:
setPlayerStorageValue(cid, 9010, 2)
<-- try like this


Or maybe you are looking at the wrong place for storage, check if you have the storage with similar script.
LUA:
	function onStepIn(cid, item, position, fromPosition)
	if (getPlayerStorageValue(cid, 9010) == 2) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "9010 is now at 2")
	end

	return true
end
 
I tried it with the spaces but it still does not even create that storage value.

What I'm trying to do is make it so that the player steps on a square right past a lvl 30 door for a quest and when he steps on that square, it sets a storage value that the quest npc checks for to make sure you didnt cheat and just buy the quest item from another player and never went past the door yourself.
 
Then use something like this:
LUA:
function onStepIn(cid, item, position, fromPosition)
local storageValue = 9010

	if(getPlayerStorageValue(cid, storageValue) ~= 2) then
     setPlayerStorageValue(cid, storageValue, 2)
     doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "9010 is now at 2")
end
		return TRUE
	end
It also checks if you already have the storage and won't add you again the next time you step in.
 
Last edited:
Thank you, it finally works. I basically just had to use a square of terrain that I would never use anywhere else since using action ids and unique ids wouldn't seem to work, so I used some weird looking grass tile, but it works now and that's all that matters.

Gave you rep for that, thanks man.
 
You're welcome!
Unique ID should work fine, i suggest you to use unique id for this, just set unique id to your title on map editor and register it to movements.xml
LUA:
	<movevent type="StepIn" uniqueid="xxxx" event="script" value="xxxx" />
make sure you register it as uniqueid not itemid.


Edit:
Sorry confused it for an action for second :D, fixed now
 
Idk why you're using ~= 2, it could just be done as simple as this:

Also @ OP, you don't need to use special items, or even check action ids etc.

In movements.xml use this script and just set it for any action id and then add that action id to the tile in the map editor.
LUA:
local storage_id = 9010

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if isPlayer(cid) and getCreatureStorage(cid, storage_id) < 1 then
		doCreatureSetStorage(cid, storage_id, 1)
	end
	return true
end
 
Idk why you're using ~= 2, it could just be done as simple as this:

Also @ OP, you don't need to use special items, or even check action ids etc.

In movements.xml use this script and just set it for any action id and then add that action id to the tile in the map editor.
LUA:
local storage_id = 9010

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
	if isPlayer(cid) and getCreatureStorage(cid, storage_id) < 1 then
		doCreatureSetStorage(cid, storage_id, 1)
	end
	return true
end

His original script had setPlayerStorageValue(cid,9010,2) and i am not so skilled like you to do it any other way. That's why i am using it like this and it works so what's the difference?
 
His original script had setPlayerStorageValue(cid,9010,2) and i am not so skilled like you to do it any other way. That's why i am using it like this and it works so what's the difference?

Your script actually doesn't even work because you didn't even end the function..
 
Back
Top