• 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 onThink script

sonny11

New Member
Joined
Dec 22, 2007
Messages
137
Reaction score
0
Lua:
function onThink(interval, lastExecution)

function winners(cid)
	for _, pid in ipairs(getPlayersOnline()) do
		if isInArea(getPlayerPosition(pid), War.fromPos, War.toPos) then
			doTeleportThing(pid, War.rewardRoom, false)
		end
	end
end

local War = {
fromPos={x=638, y=711, z=7, stackpos=253},
toPos={x=751, y=780, z=7, stackpos=253},
rewardRoom = {x=636,y=662,z=7,stackpos=1}}

local redStorage = getGlobalStorageValue(2001)
local blueStorage = getGlobalStorageValue(2002)

		if (blueStorage >= 1 and redStorage < 1) then
			addEvent(winners,5000,cid)
			setGlobalStorageValue(2001, 0)
			setGlobalStorageValue(2002, 0)
			doBroadcastMessage("The War-Event has finished, The Blue team has won.")
		elseif (blueStorage < 1 and redStorage >= 1) then
			doBroadcastMessage("The War-Event has finished, The Red team has won.")
			addEvent(winners,5000,cid)
			setGlobalStorageValue(2001, 0)
			setGlobalStorageValue(2002, 0)
		end
 
	return true
end
end

This script basically checks the last person to die in a war event, and whenever they die. the server crashes
 
It is supposed to crash when playr die?


If not then try it like that
Lua:
local War = 	{
					fromPos={x=638, y=711, z=7, stackpos=253},
					
					toPos={x=751, y=780, z=7, stackpos=253},
					
					rewardRoom = {x=636,y=662,z=7,stackpos=1}
				}


function winners()
	for _, pid in ipairs(getPlayersOnline()) do
		if isInRange(getPlayerPosition(pid), War.fromPos, War.toPos) then
			doTeleportThing(pid, War.rewardRoom, false)
		end
	end
end

function onThink(interval, lastExecution)
 
local redStorage = getGlobalStorageValue(2001)
local blueStorage = getGlobalStorageValue(2002)
 
		if (blueStorage >= 1 and redStorage < 1) then
			addEvent(winners,5000)
			setGlobalStorageValue(2001, 0)
			setGlobalStorageValue(2002, 0)
			doBroadcastMessage("The War-Event has finished, The Blue team has won.")
		elseif (blueStorage < 1 and redStorage >= 1) then
			doBroadcastMessage("The War-Event has finished, The Red team has won.")
			addEvent(winners,5000)
			setGlobalStorageValue(2001, 0)
			setGlobalStorageValue(2002, 0)
		end
 
	return true
end
 
Last edited:
No.... lol.

when the players die there is a onstatchange script that removes one storage value.

i couldn't get the onstatchange script to make it so that it checks if the storagevalue is so that the red or blue team won.
so i used an onthink script which checked if the last player is killed (when the storage value of one of the teams is below 1)

but it crashes the server whenever the player is killed.

EDIT: Your one crashed aswell. :(
 
Last edited:
Back
Top