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

Zombie, latest winner?

I just made this for you, cba really to make a gesior page cause im not familiar with gesior. But i at least made a talkaction and the sql queries so they can easily be called within gesior if you or someone else can help you make a page :)


Execute these queries in your tfs database:

Query 1:
Code:
CREATE TABLE IF NOT EXISTS `zombiewinner` (
`id` int(11) NOT NULL auto_increment,
`zombiesleft` bigint(20) NOT NULL,
`winnername` text(255) NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


Query 2:
Code:
INSERT INTO `zombiewinner` VALUES (NULL,0,'nil');



Edited creaturescript ZombieAttack:

<event type="statschange" name="ZombieAttack" event="script" value="zombieonattack.lua"/>
LUA:
function loseOnZombieArena(cid)
	kickPlayerFromZombiesArea(cid)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tough luck, the zombies got you!")
	local players = getZombiesEventPlayers()
	local win1 = 2300 	-- Winner gets this item (1)
	local wcou1 = 5	-- How many of item (1)
	local win2 = 2160	-- Winner gets this item (2)
	local wcou2 = 3	-- How many of item (2)
	if(#players <= 1) then
	local winner = players[1]
	if(winner) then
		doPlayerAddItem(winner, win1, wcou1, true)
		doPlayerAddItem(winner, win2, wcou2, true)
		db.executeQuery("UPDATE `zombiewinner` SET `zombiesleft` = '" .. getStorage(ZE_ZOMBIES_SPAWNED) .. "',`winnername` = '" .. getCreatureName(winner) .. "' WHERE `id` = 1;")
		doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "You won the zombie arena event!")
		doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " seconds of fight " .. getCreatureName(winner) .. " won the zombie arena event in game versus " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies!")
		kickPlayerFromZombiesArea(winner)
	else
		doBroadcastMessage("Zombie arena event finished! No one won?!?!?! WTF!")
	end
	doSetStorage(ZE_STATUS, 0)
	doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
	doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
	doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
	local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
	local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
	local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
		for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
			centerPos.z = z
			for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
				if(isMonster(uid)) then
					doRemoveCreature(uid)
				end
			end
		end
	end
end

function onStatsChange(target, cid, changetype, combat, value)
	if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then
		doCreatureAddHealth(target, getCreatureMaxHealth(target))
		loseOnZombieArena(target)
	return false
	end
	return true
end


Talkaction:

<talkaction words="!zlatestwinner;/zlatestwinner" event="script" value="zombiewinner.lua"/>


Script:
LUA:
function getZombieWinner()
local random = db.getResult("SELECT `winnername` FROM `zombiewinner` WHERE `id` = 1 LIMIT 1")
       if random:getID() ~= LUA_ERROR then
        	local winnername=random:getDataString("winnername")
        	random:free()
        	return winnername
    	end
     	return LUA_ERROR
end

function getZombiesLeft()
local random = db.getResult("SELECT `zombiesleft` FROM `zombiewinner` WHERE `id` = 1 LIMIT 1")
       if random:getID() ~= LUA_ERROR then
        	local zombiesleft=random:getDataInt("zombiesleft")
        	random:free()
        	return zombiesleft
    	end
     	return LUA_ERROR
end

function onSay(cid, words, param, channel)
	local zLeft = getZombiesLeft()
	local zWinner = getZombieWinner()
		if zWinner == 'nil' then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "There has never been a winner of the Zombie Arena event yet!")
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The latest winner of Zombie Arena event was: "..zWinner.." with "..zLeft.." Zombies left!")
		end
		return true
end


You could make a globalevent or something broadcasting that too.. if you want just make a file named pheenix.lua in your /libs/ folder and paste this:

LUA:
function getZombieWinner()
local random = db.getResult("SELECT `winnername` FROM `zombiewinner` WHERE `id` = 1 LIMIT 1")
       if random:getID() ~= LUA_ERROR then
        	local winnername=random:getDataString("winnername")
        	random:free()
        	return winnername
    	end
     	return LUA_ERROR
end

function getZombiesLeft()
local random = db.getResult("SELECT `zombiesleft` FROM `zombiewinner` WHERE `id` = 1 LIMIT 1")
       if random:getID() ~= LUA_ERROR then
        	local zombiesleft=random:getDataInt("zombiesleft")
        	random:free()
        	return zombiesleft
    	end
     	return LUA_ERROR
end

Then you can call those functions in any other script. Like if you decide to make a "Server Game Highscores" talkaction or broadcast or w/e you can come up with.
 
Last edited:
I just made this for you, cba really to make a gesior page cause im not familiar with gesior. But i at least made a talkaction and the sql queries so they can easily be called within gesior if you or someone else can help you make a page :)


Execute these queries in your tfs database:

Query 1:
Code:
CREATE TABLE IF NOT EXISTS `zombiewinner` (
`id` int(11) NOT NULL auto_increment,
`zombiesleft` bigint(20) NOT NULL,
`winnername` text(255) NOT NULL,
PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;


Query 2:
Code:
INSERT INTO `zombiewinner` VALUES (NULL,0,'nil');



Edited creaturescript ZombieAttack:

<event type="statschange" name="ZombieAttack" event="script" value="zombieonattack.lua"/>
LUA:
function loseOnZombieArena(cid)
	kickPlayerFromZombiesArea(cid)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Tough luck, the zombies got you!")
	local players = getZombiesEventPlayers()
	local win1 = 2300 	-- Winner gets this item (1)
	local wcou1 = 5	-- How many of item (1)
	local win2 = 2160	-- Winner gets this item (2)
	local wcou2 = 3	-- How many of item (2)
	if(#players <= 1) then
	local winner = players[1]
	if(winner) then
		doPlayerAddItem(winner, win1, wcou1, true)
		doPlayerAddItem(winner, win2, wcou2, true)
		db.executeQuery("UPDATE `zombiewinner` SET `zombiesleft` = '" .. getStorage(ZE_ZOMBIES_SPAWNED) .. "',`winnername` = '" .. getCreatureName(winner) .. "' WHERE `id` = 1;")
		doPlayerSendTextMessage(winner, MESSAGE_STATUS_CONSOLE_BLUE, "You won the zombie arena event!")
		doBroadcastMessage("After " .. os.time() - getPlayerZombiesEventStatus(winner) .. " seconds of fight " .. getCreatureName(winner) .. " won the zombie arena event in game versus " .. getStorage(ZE_ZOMBIES_SPAWNED) .. " zombies!")
		kickPlayerFromZombiesArea(winner)
	else
		doBroadcastMessage("Zombie arena event finished! No one won?!?!?! WTF!")
	end
	doSetStorage(ZE_STATUS, 0)
	doSetStorage(ZE_PLAYERS_NUMBER, ZE_DEFAULT_NUMBER_OF_PLAYERS)
	doSetStorage(ZE_ZOMBIES_TO_SPAWN, 0)
	doSetStorage(ZE_ZOMBIES_SPAWNED, 0)
	local width = (math.max(ZE_spawnFromPosition.x, ZE_spawnToPosition.x) - math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)) / 2 + 1
	local height = (math.max(ZE_spawnFromPosition.y, ZE_spawnToPosition.y) - math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)) / 2 + 1
	local centerPos = {x=math.min(ZE_spawnFromPosition.x, ZE_spawnToPosition.x)+width,y=math.min(ZE_spawnFromPosition.y, ZE_spawnToPosition.y)+height,z=ZE_spawnFromPosition.z}
		for z = math.min(ZE_spawnFromPosition.z, ZE_spawnToPosition.z), math.max(ZE_spawnFromPosition.z, ZE_spawnToPosition.z) do
			centerPos.z = z
			for i, uid in pairs(getSpectators(centerPos, width, height, false)) do
				if(isMonster(uid)) then
					doRemoveCreature(uid)
				end
			end
		end
	end
end

function onStatsChange(target, cid, changetype, combat, value)
	if((cid and isMonster(cid) and getCreatureName(cid) == "Zombie Event") or (isInRange(getThingPosition(target), ZE_spawnFromPosition, ZE_spawnToPosition) and changetype == STATSCHANGE_HEALTHLOSS and math.abs(value) >= getCreatureHealth(target))) then
		doCreatureAddHealth(target, getCreatureMaxHealth(target))
		loseOnZombieArena(target)
	return false
	end
	return true
end


Talkaction:

<talkaction words="!zlatestwinner;/zlatestwinner" event="script" value="zombiewinner.lua"/>


Script:
LUA:
function getZombieWinner()
local random = db.getResult("SELECT `winnername` FROM `zombiewinner` WHERE `id` = 1 LIMIT 1")
       if random:getID() ~= LUA_ERROR then
        	local winnername=random:getDataString("winnername")
        	random:free()
        	return winnername
    	end
     	return LUA_ERROR
end

function getZombiesLeft()
local random = db.getResult("SELECT `zombiesleft` FROM `zombiewinner` WHERE `id` = 1 LIMIT 1")
       if random:getID() ~= LUA_ERROR then
        	local zombiesleft=random:getDataInt("zombiesleft")
        	random:free()
        	return zombiesleft
    	end
     	return LUA_ERROR
end

function onSay(cid, words, param, channel)
	local zLeft = getZombiesLeft()
	local zWinner = getZombieWinner()
		if zWinner == 'nil' then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "There has never been a winner of the Zombie Arena event yet!")
		else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The latest winner of Zombie Arena event was: "..zWinner.." with "..zLeft.." Zombies left!")
		end
		return true
end


You could make a globalevent or something broadcasting that too.. if you want just make a file named pheenix.lua in your /libs/ folder and paste this:

LUA:
function getZombieWinner()
local random = db.getResult("SELECT `winnername` FROM `zombiewinner` WHERE `id` = 1 LIMIT 1")
       if random:getID() ~= LUA_ERROR then
        	local winnername=random:getDataString("winnername")
        	random:free()
        	return winnername
    	end
     	return LUA_ERROR
end

function getZombiesLeft()
local random = db.getResult("SELECT `zombiesleft` FROM `zombiewinner` WHERE `id` = 1 LIMIT 1")
       if random:getID() ~= LUA_ERROR then
        	local zombiesleft=random:getDataInt("zombiesleft")
        	random:free()
        	return zombiesleft
    	end
     	return LUA_ERROR
end

Then you can call those functions in any other script. Like if you decide to make a "Server Game Highscores" talkaction or broadcast or w/e you can come up with.

Thanks for your time. but "Edited creaturescript ZombieAttack:" What should i do with this one?

I can make an page to gesior it is noproblem. Only if i get the PhP script for it..
 
there is a creaturescript <event type="statschange" name="ZombieAttack" event="script" value="zombie/onattack.lua"/> from the original Zombie Arena Event that you linked, replace zombie/onattack.lua with the one i posted. It's the one that will change the Latest winner everytime a Zombie Event has finished!

- - - Updated - - -

This is for php but gesior is.. gah i dont know.. so much clutter in the code :P

Code:
$data = mysql_query("SELECT * FROM zombiewinner") 
 or die(mysql_error()); 
 Print "<table border cellpadding=3>"; 
 while($info = mysql_fetch_array( $data )) 
 { 
 Print "<tr>"; 
 Print "<th>Name:</th> <td>".$info['winnername'] . "</td> "; 
 Print "<th>Zombies Left:</th> <td>".$info['zombiesleft'] . " </td></tr>"; 
 } 
 Print "</table>";
 
Back
Top