• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Ondeath

Slafesko

New Member
Joined
Jan 6, 2016
Messages
101
Reaction score
2
Sorry, but may someone check this script because when i die from a monster i find this error.
Code:
function onDeath(cid, corpse, deathList)
if getPlayerIp(cid) ~= getPlayerIp(deathList[1]) then
if isPlayer(cid) and isPlayer(deathList[1]) then
doPlayerAddItem(deathList[1], 5944)
end
else
doPlayerSendTextMessage(deathList[1], 18, "You didn't get reward because of killing a player with same ip.")
end
return true
end
2exr9f6.jpg
 
Code:
function onDeath(cid, corpse, deathList)
if isPlayer(cid) and isPlayer(deathList[1]) then
getPlayerIp(cid) ~= getPlayerIp(deathList[1]) 
isPlayer(cid) and isPlayer(deathList[1])
doPlayerAddItem(deathList[1], 5944)
else
doPlayerSendTextMessage(deathList[1], 18, "You didn't get reward because of killing a player with same ip.")
end
return true
end

This totally shouldn't work (cuz I'm noob as hell in lua) and I didn't tested it but.. You can try it.
 
Code:
function onDeath(cid, corpse, deathList)
if isPlayer(cid) and isPlayer(deathList[1]) then
getPlayerIp(cid) ~= getPlayerIp(deathList[1])
isPlayer(cid) and isPlayer(deathList[1])
doPlayerAddItem(deathList[1], 5944)
else
doPlayerSendTextMessage(deathList[1], 18, "You didn't get reward because of killing a player with same ip.")
end
return true
end

This totally shouldn't work (cuz I'm noob as hell in lua) and I didn't tested it but.. You can try it.

Code:
function onDeath(cid, corpse, deathList)
if isPlayer(cid) and isPlayer(deathList[1]) then
if getPlayerIp(cid) ~= getPlayerIp(deathList[1]) then
doPlayerAddItem(deathList[1], 5944)
end
else
doPlayerSendTextMessage(deathList[1], 18, "You didn't get reward because of killing a player with same ip.")
end
return true
end
I would say it's more like this :P
 
Code:
function onDeath(cid, corpse, deathList)
if isPlayer(cid) and isPlayer(deathList[1]) then
if getPlayerIp(cid) ~= getPlayerIp(deathList[1]) then
doPlayerAddItem(deathList[1], 5944)
end
else
doPlayerSendTextMessage(deathList[1], 18, "You didn't get reward because of killing a player with same ip.")
end
return true
end
I would say it's more like this :p
Okay :)
 

It's because when a player die by a monster the script is trying to take info from him.
Doesn't matter if you are checking isPlayer(), monsters are not declared in onDeath.

Use onKill instead.

Code:
function onKill(cid, target, damage, flags, war)

   if isPlayer(cid) and isPlayer(target) then
     if getPlayerIp(cid) ~= getPlayerIp(target) then
       doPlayerAddItem(cid, 5944)
     else
       doPlayerSendTextMessage(cid, 22, "You didn't get reward because of killing a player with same ip.")
     end
   end
   return true
end
 
Last edited:
It's because when a player die by a monster the script is trying to take info from him.
Doesn't matter if you are checking isPlayer(cid), monsters are not declared in onDeath.

Use onKill instead.

Code:
function onKill(cid, target, damage, flags, war)

   if isPlayer(cid) and isPlayer(target) then
     if getPlayerIp(cid) ~= getPlayerIp(target) then
       doPlayerAddItem(cid, 5944)
     else
       doPlayerSendTextMessage(cid, 22, "You didn't get reward because of killing a player with same ip.")
     end
   end
   return true
end
Is it work with last hit only? because i don't need to reward all killers with this item
 
Is it work with last hit only? because i don't need to reward all killers with this item

Code:
function onKill(cid, target, damage, flags, war)

   if cid ~= target then
     if isPlayer(cid) and isPlayer(target) then
       if getPlayerIp(cid) ~= getPlayerIp(target) then
         if (flags % 2 == 1) then
           doPlayerAddItem(cid, 5944)
         end
       else
         doPlayerSendTextMessage(cid, 22, "You didn't get reward because of killing a player with same ip.")
       end
     end
   end
   return true
end
 
Code:
function onKill(cid, target, damage, flags, war)

   if cid ~= target then
     if isPlayer(cid) and isPlayer(target) then
       if getPlayerIp(cid) ~= getPlayerIp(target) then
         if (flags % 2 == 1) then
           doPlayerAddItem(cid, 5944)
         end
       else
         doPlayerSendTextMessage(cid, 22, "You didn't get reward because of killing a player with same ip.")
       end
     end
   end
   return true
end
Is it last hit? :D because i read the script and find %2 == 1 :D
 
Doesn't matter if you are checking isPlayer(cid), monsters are not declared in onDeath.
Even if monsters are not declared in onDeath you can still check if the killer is a player or not

and
Code:
%2 == 0
or
Code:
%2 == 1
is a lua function for checking even or odd numbers so it doesn't really matter which tfs verion you're using since nearly all lua functions work on all tfs versions
 
Even if monsters are not declared in onDeath you can still check if the killer is a player or not

His script was trying to take monster info even with isPlayer().


Code:
%2 == 0
or
Code:
%2 == 1
is a lua function for checking even or odd numbers so it doesn't really matter which tfs verion you're using since nearly all lua functions work on all tfs versions

Yes but flags are required to check the lastHit. For example, 0.3.6 doesn't have that, it has be to done with lastHit instead flags.
That's why i asked about tfs version.
 
Last edited:
% is called the modulus operator, it returns the remainder of 2 operands, it is used in countless programming languages
Code:
operand1 % operand2 = remainder
This is an example of how it works
Code:
5 / 2 = 2
2 * 2 = 4
5 - 4 = 1
So 5 % 2 = 1
 
Well my tfs is 0.4 and your script didn't work with me :S @Musztang and sorry for not understanding you guys :D because im still a beginner with lua, and may i ask someone to teach me lua please? because i tried to learn it from LUA official site but i couldn't get it, thanks.
 
Well my tfs is 0.4 and your script didn't work with me :S @Musztang and sorry for not understanding you guys :D because im still a beginner with lua, and may i ask someone to teach me lua please? because i tried to learn it from LUA official site but i couldn't get it, thanks.

It should... i just test it and seems fine.
Make sure to register the event onLogin.
 
Back
Top