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

Reward medal not working fine :S

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
923
Location
Chile
Hi, look i have a reward medal script but i have 2 errors: 1 is that when a person die the medal is drop anyway (i want to be dropped only when someone kill someone)
and the second thing is that the written thing is bad, is says this:

PHP:
00:25 You see a  Oscar's Frag Trophy.
It weighs 1.00 oz.
He died at level 154[Unjustified]

i want something like:
PHP:
you see oscar's frag thophy. he was killed by XX

is an example, but something like that

well here is my reward lua:
LUA:
function onDeath(cid, corpse, deathList)
    if isPlayer(cid) then
        local v = { 
            target_name = getCreatureName(cid), 
            target_level = getPlayerLevel(cid) ; 
            } ; 
        local reward = doAddContainerItem(corpse.uid, 5785, 1)
        doItemSetAttribute(reward, "description", "" .. 
            ( getPlayerSex(cid) == 0 and "She" or "He" ) .. " died at level " .. v.target_level .. 
            (getCreatureSkullType(cid) <= SKULL_GREEN and "[Unjustified]" or "[Justified]"))
        doItemSetAttribute(reward, "name"," " .. v.target_name .. "'s Frag Trophy")
    end
    return true
end

oooh and the unjustified part to erase it plz :) and if it possible that the reward appears inmediately in your bp instead of inside the dead body :)
 
Last edited by a moderator:
[14/11/2012 13:18:49] Alissow Server, version 0.4.1 (Alissow)
[14/11/2012 13:18:49] Compiled with: Comedinhasss & Fireelement.
[14/11/2012 13:18:49] A server developed by: Alissow & CiA.
[14/11/2012 13:18:49] Visit our forum for updates & support: Só Otserv.

this is what u are asking?
 
Try this one out.

LUA:
function onDeath(cid, corpse, deathList)
	local killer = nil
	for _, pid in pairs(deathList) do
		if isPlayer(pid) then
			killer = pid
		end
	end
	
	if not(killer) then return true end
	
	if isPlayer(cid) then
		local reward = doAddContainerItem(corpse.uid, 5785, 1)
		doItemSetAttribute(reward, "description", (getPlayerSex(cid) == 0 and "She" or "He") .. " died at level " .. getPlayerLevel(cid) .. (getCreatureSkullType(cid) <= SKULL_GREEN and " [Unjustified]" or " [Justified]"))
		doItemSetAttribute(reward, "name"," " .. getPlayerName(cid) .. "'s Frag Trophy. He was killed by " .. getCreatureName(killer))
	end
	return true
end
 
Last edited:
summ i tried that one and when a person is killed by another player his body dissapear and this error appeard at the console:
XML:
[15/11/2012 22:46:07] [Error - CreatureScript Interface] 
[15/11/2012 22:46:07] data/creaturescripts/scripts/frag_reward.lua:onDeath
[15/11/2012 22:46:07] Description: 
[15/11/2012 22:46:07] data/creaturescripts/scripts/frag_reward.lua:14: attempt to index global 'v' (a nil value)
[15/11/2012 22:46:07] stack traceback:
[15/11/2012 22:46:08] 	data/creaturescripts/scripts/frag_reward.lua:14: in function <data/creaturescripts/scripts/frag_reward.lua:1>

- - - Updated - - -
 
Last edited:
:D it works, but i wondering if it i possible that the medal appears in your bp, at any space available, instead of inside the dead body >.<
 
This?
LUA:
function onDeath(cid, corpse, deathList)
	local killer = nil
	for _, pid in pairs(deathList) do
		if isPlayer(pid) then
			killer = pid
		end
	end
 
	if not(killer) then return true end
 
	if isPlayer(cid) then
		local reward = doPlayerAddItem(killer, 5785, 1)
		if reward then
			doItemSetAttribute(reward, "description", (getPlayerSex(cid) == 0 and "She" or "He") .. " died at level " .. getPlayerLevel(cid) .. (getCreatureSkullType(cid) <= SKULL_GREEN and " [Unjustified]" or " [Justified]"))
			doItemSetAttribute(reward, "name"," " .. getPlayerName(cid) .. "'s Frag Trophy. He was killed by " .. getCreatureName(killer))
		end
	end
	return true
end
 
Back
Top