• 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 Event PROBLEM

Acubens

Old Penguin
Joined
May 6, 2008
Messages
1,261
Solutions
13
Reaction score
184
Location
Venezuela
Hello Otlanders, i need help with this script, i want create globalevent, if X player have X storage value, he is teleported and the storage be reset when the globalevent is executed

this is my script:

Lua:
function onThink(interval, lastExecution)

local room = {x=32340,y=32130,z=7}
	
	for _, pid in ipairs(getPlayersOnline()) do
	local cid = getPlayerByName(pid)	

		if getPlayerStorageValue(pid,54731) == 1 then
			doTeleportThing(cid,room)
		
				doPlayerSendTextMessage(cid, 19, "You enter ok")	
				setPlayerStorageValue(pid,54731,0)
			
		else
			doPlayerSendTextMessage(pid, 19, "good luck in the next time..")	

		end	
	end	
end

but i got

[Error - Globalevents::think} couldn't execute event: Rooms:

Rep++ for help
 
I donno what is the need of getPlayerByName function,also it's param should be player's name not uid w/e here is it.
Lua:
local room = {x=32340,y=32130,z=7}
local storage = 54731

function onThink(interval, lastExecution)
 
	for _, cid in ipairs(getPlayersOnline()) do
 
		if getPlayerStorageValue(cid,storage) == 1 then
			doTeleportThing(cid,room)
			doPlayerSendTextMessage(cid, 19, "You enter ok")	
			setPlayerStorageValue(cid,storage,0)
		else   -- I would recommend not to use the else statement because the player dont have storage = spam this msg
			doPlayerSendTextMessage(cid, 19, "good luck in the next time..")	
		end	

	end	
	
	return true
end
 
On of 2 things, either you have put it wrong in the globalevent, or the player storage dont match the one in script, the storage must be = 1 .
 
This is talkaction give the storage to the player

Lua:
local t = {

gp = 50000, 
lvl = 100, 
storage = 54731

}

function onSay(cid, words, param)


	if getPlayerLevel(cid) >= t.lvl then
			if doPlayerRemoveMoney(cid,t.gp) == 1 then
				setPlayerStorageValue(cid,t.storage)
				doPlayerSendTextMessage(cid, 25, "test ok")			
			else
				doPlayerSendCancel(cid, "No money..")
				
			end
	else
		doPlayerSendCancel(cid, "No level..")
	end


	
return TRUE
end
 
set storage to what..
Lua:
local t = {
 
gp = 50000, 
lvl = 100, 
storage = 54731
 
}
 
function onSay(cid, words, param)
 
 
	if getPlayerLevel(cid) >= t.lvl then
			if doPlayerRemoveMoney(cid,t.gp)  then
				setPlayerStorageValue(cid,t.storage,1)
				doPlayerSendTextMessage(cid, 25, "test ok")			
			else
				doPlayerSendCancel(cid, "No money..")
 
			end
	else
		doPlayerSendCancel(cid, "No level..")
	end
 
 
 
return true
end
 
Back
Top