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

Please fix frag reward script.

Sorbal

Member
Joined
Jul 23, 2010
Messages
406
Reaction score
11
Location
Poland
Hello, can someone fix this script?:
function onKill(cid, target, lastHit)
local reward = 2152
local exp = 500
if(isPlayer(cid) and isPlayer(target)) then
if(getIpByName(getCreatureName(cid)) ~= getIpByName(getCreatureName(target))) then
doPlayerAddItem(cid, reward, 1)
elseif(getPlayerName(cid) == getPlayerName(target)) then
doPlayerAddItem(cid, reward, 1)
else
doPlayerAddExperience(cid, - exp)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have been punished for killing a player of the same IP.")
end
end
return true
end
<event type="kill" name="fragreward" event="script" value="fragreward.lua"/>
Its working good, if i kill my MC i don't earn a platinum coin and i lose 500 exp. But if i kill myself by Fire field i earn platinum coin (Frag reward). I want to earn frag reward only when i kill other player, not myself by fire field. Bye ^_^.
 
Lua:
function onKill(cid, target, lastHit)
	if cid ~= target and isPlayer(target) then
		if getPlayerIp(cid) == getPlayerIp(target) then
			doPlayerAddExperience(cid, -500)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have been punished for killing a player of the same IP.')
		else
			doPlayerAddItem(cid, 2152, 1)
		end
	end
	return true
end
 
It works perfectly, I added a few "improvements" that I was still needed like (doPlayerAddExperience(cid, 500) if he kill other player + doSendAnimatedText(getPlayerPosition(cid),"500", TEXTCOLOR_WHITE)
. Thanks you Cykotitan, You're the best. :)
 
i cant understand very good, but, if you want to add +500 exp and animated text
i think it will work:

Lua:
function onKill(cid, target, lastHit)
	if cid ~= target and isPlayer(target) then
		if getPlayerIp(cid) == getPlayerIp(target) then
			doPlayerAddExperience(cid, -500)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have been punished for killing a player of the same IP.')
		else
			doPlayerAddItem(cid, 2152, 1)
			doPlayerAddExperience(cid, 500)
            doSendAnimatedText(getPlayerPosition(cid),"500", TEXTCOLOR_WHITE)
		end
	end
	return true
end
 
Back
Top