• 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 An Event(onthink) Script errors

supomglol

Member
Joined
Jan 29, 2012
Messages
195
Reaction score
10
[Creature Event]
This event should check to see if the players storage values and global event storages are met, THEN do the following commands.


Code:
local startstorage = 87381
local amountofplayers = 87382
local playing = 87383
local winner = 87384 

local over = 87385
local started = 87386

function onThink(cid, interval)
	if not isPlayer(cid) or getPlayerGroupId(cid) >= 3 then
		return
	end
	
if getCreatureStorage(cid, playing) == 1 and
   getCreatureStorage(cid, winner) == 1 then
   doPlayerAddItem(cid,9971, 4)
	setGlobalStorageValue(startstorage, 0)
	setGlobalStorageValue(amountofplayers, 0)
    setGlobalStorageValue(over, 1)
	doCreatureSetStorage(cid, winner, 0)
	doBroadcastMessage("The minigame is over! We have our winner!", MESSAGE_STATUS_WARNING)
	return true
	end
	if  getGlobalStorageValue(over) == 1 and
	getCreatureStorage(cid, playing) == 1 then
	doPlayerAddItem(cid,9971, 2)
	setGlobalStorageValue(over, 0)
	doCreatureSetStorage(cid, playing, 0)
doPlayerPopupFYI(cid, "Thank you for participating! Tokens have been added to your inventory")
	doTeleportThing(cid, {x = 32369, y = 32241, z = 7})
	setGlobalStorageValue(started, 0)
	return true
	end
	if getGlobalStorageValue(startstorage) == 1 and
	getGlobalStorageValue(amountofplayers) == 5 and
	getGlobalStorageValue(started) == 0 and
	getCreatureStorage(cid, playing) == 1 then
	doTeleportThing(cid, {x = 32489, y = 32376, z = 7})
	setGlobalStorageValue(started, 1)
	doBroadcastMessage("We have 5 players! Our minigame has begun!", MESSAGE_STATUS_WARNING)
	return true
	end
end

None of the script works, I am on 8.6, the rest of my entire event works though! i plan to share it with everyone as soon as i can get it working!


The format of my code is all correct, i just cannot see what i am missing!


any help will be greatly appreciated! thank you:p


Forgot to mention :i am getting NO console errors :l just not working
 
Last edited:
Thats what I had before, and it wasnt working, so i tried this.

- - - Updated - - -

wait, maybe
if instead of
Code:
if getCreatureStorage(cid, playing) == 1 and
   getCreatureStorage(cid, winner) == 1 then
   doPlayerAddItem(cid,9971, 4)


Does it have to be

Code:
if getCreatureStorage(cid, playing) == 1 and IF
   getCreatureStorage(cid, winner) == 1 then IF
   doPlayerAddItem(cid,9971, 4)

- - - Updated - - -

Code:
local startstorage = 87381
local amountofplayers = 87382
local playing = 87383
local winner = 87384 

local over = 87385
local started = 87386

function onThink(cid, interval)
	if not isPlayer(cid) or getPlayerGroupId(cid) >= 3 then

	
if getCreatureStorage(cid, playing) == 1 and
   getCreatureStorage(cid, winner) == 1 then
   doPlayerAddItem(cid,9971, 4)
	setGlobalStorageValue(startstorage, 0)
	setGlobalStorageValue(amountofplayers, 0)
    setGlobalStorageValue(over, 1)
	doCreatureSetStorage(cid, winner, 0)
	doBroadcastMessage("The minigame is over! We have our winner!", MESSAGE_STATUS_WARNING)
	return true
	end
	elseif  getGlobalStorageValue(over) == 1 and
	getCreatureStorage(cid, playing) == 1 then
	doPlayerAddItem(cid,9971, 2)
	setGlobalStorageValue(over, 0)
	doCreatureSetStorage(cid, playing, 0)
doPlayerPopupFYI(cid, "Thank you for participating! Tokens have been added to your inventory")
	doTeleportThing(cid, {x = 32369, y = 32241, z = 7})
	setGlobalStorageValue(started, 0)
	return true
	
	elseif getGlobalStorageValue(startstorage) == 1 and
	getGlobalStorageValue(amountofplayers) == 5 and
	getGlobalStorageValue(started) == 0 and
	getCreatureStorage(cid, playing) == 1 then
	doTeleportThing(cid, {x = 32489, y = 32376, z = 7})
	setGlobalStorageValue(started, 1)
	doBroadcastMessage("We have 5 players! Our minigame has begun!", MESSAGE_STATUS_WARNING)
	return true
	end
	return true
end


latest attempt, still doesn't work :S
 
LUA:
 local config = { 
	startstorage = 87381,
	amountofplayers = 87382,
	playing = 87383,
	winner = 87384,
	over = 87385,
	started = 87386
} 

function onThink(cid, interval)
	if not (isPlayer(cid) or getPlayerGroupId(cid) >= 3) then
	return true
end
	
	if (getCreatureStorage(cid, config.playing) == 1 and getCreatureStorage(cid, config.winner) == 1) then
		doPlayerAddItem(cid,9971, 4)
		setGlobalStorageValue(config.startstorage, 0)
		setGlobalStorageValue(config.amountofplayers, 0)
		setGlobalStorageValue(config.over, 1)
		doCreatureSetStorage(cid, config.winner, 0)
		doBroadcastMessage("The minigame is over! We have our winner!", MESSAGE_STATUS_WARNING)
	elseif  (getGlobalStorageValue(config.over) == 1 and getCreatureStorage(cid, config.playing) == 1) then
		doPlayerAddItem(cid,9971, 2)
		setGlobalStorageValue(config.over, 0)
		doCreatureSetStorage(cid, config.playing, 0)
		doPlayerPopupFYI(cid, "Thank you for participating! Tokens have been added to your inventory")
		doTeleportThing(cid, {x = 32369, y = 32241, z = 7})
		setGlobalStorageValue(config.started, 0)
	elseif (getGlobalStorageValue(config.startstorage) == 1 and getGlobalStorageValue(config.amountofplayers) == 5 and getGlobalStorageValue(config.started) == 0 and getCreatureStorage(cid, config.playing) == 1) then
		doTeleportThing(cid, {x = 32489, y = 32376, z = 7})
		setGlobalStorageValue(config.started, 1)
		doBroadcastMessage("We have 5 players! Our minigame has begun!", MESSAGE_STATUS_WARNING)
	return true
end
 
Back
Top