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

CreatureEvent K/D Ratio System by Narko

Amiroslo

Excellent OT User
Joined
Jul 28, 2009
Messages
6,767
Solutions
5
Reaction score
769
Hello, All credits to narko. I just converted it from mod to a normal lua script :D

Open creaturescript.xml
add
Lua:
<event type="kill" name="killpoint" event="script" value="onkill.lua"/>
Now add this script in scripts, make one called onkill.lua
Lua:
		function onKill(cid, target, damage, flags)
			if isPlayer(target) == true then
				db.query("UPDATE `players` SET `frags` = `frags` + 1 WHERE id = " .. getPlayerGUID(cid) .. ";") 
				doCreatureSay(cid, '+1 Frag Point!', TALKTYPE_ORANGE_1) 
			end
			
			return true
		end

now reopen creaturescript.xml
add
Lua:
<event type="preparedeath" name="deathpoint" event="script" value="onpd.lua"/>
Now add this script in scripts, make one called onpd.lua
Lua:
			function onPrepareDeath(cid, deathList, lastHitKiller, mostDamageKiller)
			if isPlayer(cid) == true then
				db.query("UPDATE `players` SET `deaths` = `deaths` + 1 WHERE id = " .. getPlayerGUID(cid) .. ";") 
				doCreatureSay(cid, '+1 Death Point!', TALKTYPE_ORANGE_1) 
			end

			return true
		end
open creaturescript.xml again and add
Lua:
<event type="look" name="KdrLook" event="script" value="onlook.lua"/>

make a new script call it onlook.lua and paste this in it:
Lua:
		function onLook(cid, thing, position, lookDistance)
		function getKillsPlayer(cid)
			local Info = db.getResult("SELECT `frags` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
				local frags= Info:getDataInt("frags")
					return frags
			end

		function getDeathsPlayer(cid)
			local Info = db.getResult("SELECT `deaths` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
				local deaths= Info:getDataInt("deaths")
					return deaths
			end
		if isPlayer(thing.uid) then
local kdr = getKillsPlayer(thing.uid)/getDeathsPlayer(thing.uid)
				doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and "\nShe" or "\nHe") .. " has Killed: ["..getKillsPlayer(thing.uid).."] Players."..(getPlayerSex(thing.uid) == 0 and "\nShe" or "\nHe") .. " has Died: ["..getDeathsPlayer(thing.uid).."] Times.\nThe Kdr(Kill Death Ratio) is: ["..kdr.."].")
			end
		if(thing.uid == cid) then
local kdr = getKillsPlayer(thing.uid)/getDeathsPlayer(thing.uid)
				doPlayerSetSpecialDescription(thing.uid, "\nYou have Killed: ["..getKillsPlayer(thing.uid).."] Players.\nYou have Died: ["..getDeathsPlayer(thing.uid).."] Times.\nYou Kdr(Kill Death Ratio) is: ["..kdr.."].")
			end
			return true
		end

now open login.lua and add

Lua:
		registerCreatureEvent(cid, "KdrLook")
		registerCreatureEvent(cid, "killpoint")
		registerCreatureEvent(cid, "deathpoint")

SQL:
ALTER TABLE `players` ADD `frags` INT( 11 ) NOT NULL DEFAULT '0';
ALTER TABLE `players` ADD `deaths` INT( 11 ) NOT NULL DEFAULT '0';
 
Last edited:
bring up this post.

I like this concept..but what is to stop players from boosting for a good K/D ratio? They can just MC or get friends to kill for good K/D ratio :/. HM?
 
bring up this post.

I like this concept..but what is to stop players from boosting for a good K/D ratio? They can just MC or get friends to kill for good K/D ratio :/. HM?

Every online game with a KDR system has this issue, there is no way to stop it short from adding some sort of check that prevents you from gaining a kill or a death count from the same person twice in a certain amount of time which would kinda defeat the purpose of the system xD I suppose its more of a fun factor.
 
use Anti MC? or 1chat pr ip or maybe if u kill same traget a lot of times x thing happens? :p
 
use Anti MC? or 1chat pr ip or maybe if u kill same traget a lot of times x thing happens? :p

Can you add something like this perhaps? Otherwise I will just use what you have now. :)

EDIT: Hm this doesn't work for me. This also happened when I tried Narko's mods. Any ideas?
 
Last edited:
Can anyone tell me why looking at yourself on a 0.4.3777 would not display your kdr? I can check the kdr of other players but I cannot view my own kdr.

EDIT: Seems fine after both chars had a death and a kill each (when zero was involved it was acting silly)
Also, the kdr ratio is bugging like this...
XUoJJ.png

The kdr is right with '1' but it has that INF thing listed after it and I can't find that in the onlook script so I'm unsure of how to fix it..

Thanks,
~Justin
 
Can anyone tell me why looking at yourself on a 0.4.3777 would not display your kdr? I can check the kdr of other players but I cannot view my own kdr.

EDIT: Seems fine after both chars had a death and a kill each (when zero was involved it was acting silly)
Also, the kdr ratio is bugging like this...
XUoJJ.png

The kdr is right with '1' but it has that INF thing listed after it and I can't find that in the onlook script so I'm unsure of how to fix it..

Thanks,
~Justin

Code:
its logic (1/0)=infinity u need add a condition 
if(getDeathsPlayer(cid)==0)then 
          krd=getKillsPlayer(cid) 
end
 
Back
Top