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

Storage Counts deaths

laxante

New Member
Joined
Mar 13, 2009
Messages
120
Reaction score
4
Hi, I need if I can help put in my database to a storagevalue
count the deaths of a player.

example on web :
frags | deaths
Playername [frags]| [Deaths]

thank you very much
rep for the help
 
I donno if you want frags to be added like normal frags , i mena if attacked player have red skull or white skull or black skull then the killer dont get frags.
Lua:
function onLogin(cid)
	registerCreatureEvent(cid, "kill_count")
	registerCreatureEvent(cid, "death_count")
	return true
end


local death = 23984   -- storage
function onDeath(cid, corpse, deathList)
	if isPlayer(cid) then
		 setPlayerStorageValue(cid,death,math.max(1,getPlayerStorageValue(cid,death)+1))
	end
	return true
end



local kill = 23494   -- storage
function onKill(cid,target,lastHit)
	if isPlayer(cid) and isPlayer(target) then
		if lastHit then
		 setPlayerStorageValue(cid,death,math.max(1,getPlayerStorageValue(cid,death)+1))
		end
	end
	return true
end


Then in creatureevent.xml

Code:
	<event type="kill" name="kill_count" event="script" value="xxxx.lua"/>
	<event type="death" name="death_count" event="script" value="xxxx.lua"/>
 
Last edited:
just a tip damadger, you can use math.max:
Code:
 setPlayerStorageValue(cid,death,math.max(1,getPlayerStorageValue(cid,death)+1))
which is the same as
Code:
if getPlayerStorageValue(cid,death) < 0 then
      setPlayerStorageValue(cid,death,1)
else
      setPlayerStorageValue(cid,death,getPlayerStorageValue(cid,death)+1)
end
 
math.max returns only the max value of the two params:

math.max(1,10)
will return 10

math.max(1,-1)
will return 1

..so
setPlayerStorageValue(cid,death,math.max(1,getPlayerStorageValue(cid,death)+1))

when storage is -1 you know it will summ 0, so mathmax will pick 1 instead of 0
 
I could help you make a creature script showing frags and deaths counter in player whit
doPlayerSetSpecialDescription ("you have" ..frags .. "and " .. Deaths ..)?


ty i rep you +
sorry bad english
 
Back
Top