• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

CreatureEvent Store Deaths

Sync

Ø,ø
Joined
May 26, 2009
Messages
1,902
Reaction score
26
Location
Canada
These simple Scripts store Total Deaths, Can be used to modify onLook to show how many deaths a player has, on website, Etc.

Code:
ALTER TABLE players ADD deaths bigint(11) NOT NULL

050-function.lua
LUA:
function doPlayerAddDeaths(cid, add)
	return db.executeQuery("UPDATE `players` SET `deaths` = `deaths` + "..add.." WHERE `name` = '"..getCreatureName(cid).."';")
end

function getPlayerDeaths(cid)
	local DB_points = db.getResult("SELECT `deaths` FROM `players` WHERE `name` = '"..getCreatureName(cid).."';")
	points = DB_points:getDataInt("deaths")
	DB_points:free()
	return points
end

addDeath.lua
LUA:
function onPrepareDeath(cid, deathList)
         doPlayerAddDeaths(cid, 1)
        return true
end

Heres a base script to show total Deaths of cid.

LUA:
function onSay(cid, words, param, channel)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have a total of " .. getPlayerDeaths(cid) .. " deaths.")
	return true
end
 
It would be much more efficient if you were to use player storage instead of raw database queries.
 
It would be much more efficient if you were to use player storage instead of raw database queries.
or like this;
Code:
function doPlayerAddDeaths(d)
	local q = 0
	q = q + d
	return d
end
 
Last edited:
or like this;
Code:
function doPlayerAddDeaths(d)
    local q = 0
    q = q + d
    return d
end
:ninja:that will always return '1' or the same value
replace q with getPlayerStorageValue
and where's the player? (cid)
oh right, that's all unnecessary!

sqless
LUA:
function doPlayerAddDeath(cid) return doPlayerSetStorageValue(cid, storage, getPlayerStorageValue(cid, storage)+1) end
 
I did it in DB querys so its easier to get the information for Website Scripts and what not. Feel free to change it if you desire.
 
Back
Top