• 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 Restoring bush

ziggy46802

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

rocks
Code:
function restore(cid, storage)
			setPlayerStorageValue(cid, 1024, 1)
				return true
				end


function onUse(cid, item, frompos, item2, topos)
if getPlayerStorageValue(cid, 1024) == 1
then
			doSendMagicEffect(getPlayerPosition(cid), 13)	
			doCreatureSay(cid, "You have come across some rocks, keep collecting them.", TALKTYPE_ORANGE_1)
			doPlayerAddItem(cid, 5953, 1)
			setPlayerStorageValue(cid, 1024, 2)
				addEvent(restore, 1000)
			else
				doCreatureSay(cid, "no rocks man, wait for more to form.", TALKTYPE_ORANGE_1)
				return true
			end
			return true
			end

I'm getting an error with something about "setPlayerStorageValue <>. Player not found.

All I want it to do is this:
You use the thing and you get a rock, and then it takes a second for it to respawn so if you try to spam it, then it says to wait and you get nothing, but if you use it, then wait a second for it to respawn and use it again, then you get another rock, and then you have to wait again.

What is wrong with my script?

By the way, I have it set so "on login" if your storage value of 1024 is < 1, then it sets it to 1, so that is not the problem. The problem is I get a rock, but then it keeps telling me to wait forever and wont respawn.
 
I think you need to do something like this:

LUA:
addEvent(restore, 1000, cid)

And remove the storage parameter from the restore function, it seems you're not using it.

LUA:
function restore(cid)
 
Okay it is working now, but there is a problem where I can hold CTRL and click it really fast and I will get like 5 rocks before it kicks in and stops me for 3 seconds then I spam it and get 5 more.

How do I get around this? Does this only happen to me because I am hosting the server on my own computer and this would not happen to other players?

I was thinking, maybe I could make it so it teleports the player "x + 2" or something but I have no idea how to do that.


EDIT-> Nevermind, this only happened with the "3 second test mode", if I dont spam it WHILE its restoring itself, then I only get one even if I double click it super fast once it has restored itself. So basically, when I use the real script for like an hour or two, it will work perfectly fine.

Thank you very much Evan I gave you rep.
 
Last edited:
Back
Top