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

Solved onKill = die

Demnish

Tibian Hero
Joined
Sep 28, 2011
Messages
401
Solutions
2
Reaction score
63
Location
Sweden
I have a problem with this script, I think the problem depends on hp/mana gain on level up since I use PVP-Enforced.

mcfrag.lua
Code:
function onKill(cid, target, lastHit) if cid ~= target and isPlayer(target) then
if getPlayerIp(cid) == getPlayerIp(target) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'You have been slain for killing a player of the same IP.')
doCreatureAddHealth(cid, -getCreatureMaxHealth(cid) - getCreatureHealth(cid))
else
doPlayerAddItem(cid, 2152, 1)
end
end
return true
end

Is there anyway to get around it, because I get the text, but my character wont die.


Thanks in advance.
/Zeeb


SOLVED
Here is the code:
Code:
function onKill(cid, target, lastHit)
if cid ~= target and isPlayer(target) then
if getPlayerIp(cid) == getPlayerIp(target) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'You will be punished for killing a player of the same IP.')
addEvent(doCreatureAddHealth, 1000, cid, -(2*getCreatureMaxHealth(cid)))
else
doPlayerAddItem(cid, 2152, 1)
end
end
return true
end
 
Last edited:
try now
Code:
function onKill(cid, target, lastHit)
    if isPlayer(cid) and cid ~= target and isPlayer(target) then
    if getPlayerIp(cid) == getPlayerIp(target) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'You have been slain for killing a player of the same IP.')
        doCreatureAddHealth(cid, (getCreatureMaxHealth(cid) - getCreatureHealth(cid)))
    else
        doPlayerAddItem(cid, 2152, 1)
    end
    end
return true
end
 
Last edited:
oh fuck i changed something that i didnt had to xd
Code:
if getPlayerIp(cid) == getPlayerByIp(target) then
to (like u had it)
Code:
if getPlayerIp(cid) == getPlayerIp(target) then
 
Code:
function onKill(cid, target, lastHit)
if cid ~= target and isPlayer(target) then
if getPlayerIp(cid) == getPlayerIp(target) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'You have been slain for killing a player of the same IP.')
doCreatureAddHealth(cid, -getCreatureMaxHealth(cid))
else
doPlayerAddItem(cid, 2152, 1)
end
end
return true
end
 
Last edited:
Doesnt work, I think its because at the same time you lose HP, you gain lvl, therefor you gain max hp & mana on lvl up.

looks like this:
Code:
20:06 You have been punished for killing a player of the same IP.
20:06 Warning! The murder of Master Sorcerer was not justified.
20:06 You gained 1569460 experience points.
20:06 You advanced from Level 100 to Level 103.
 
Which server do you use? I can't reproduce the problem (tested on TFS 0.2.15 with pvp-enforced and killing higher lvl).
If the health difference is the problem you can always do something like this.
Code:
doCreatureAddHealth(cid, -(2*getCreatureMaxHealth(cid)))
 
I am using the same distro, but not PVP-Enforced, only PVP because AOL does not work in PVPE, I cant fix it since I have no sources.

I noticed when trying the script with a friend that he gained no money from killing me (since he is on a different IP he should be rewarded but was not).


I will try the line you sent.
 
Yes ofcourse :)

I tried the healthevent you posted, still only got this:
Code:
22:38 You have been slain for killing a player of the same IP.
22:38 Warning! The murder of Elder Druid was not justified.
22:38 You gained 784730 experience points.
22:38 You advanced from Level 100 to Level 101.
 
If you add this under doCreatureAddHealth
Code:
print("script load test")
Do you see this message in your console when you kill someone?
 
Nope :/


Code:
[14/09/2014 06:57:02] Master Sorcerer has logged in.
[14/09/2014 06:57:20] Elder Druid has logged out.
[14/09/2014 06:57:20] Saving server...
[14/09/2014 06:57:20] Notice: Map save (relational) took : 0.051 s
Code:
06:57 You have been slain for killing a player of the same IP.
06:57 Warning! The murder of Elder Druid was not justified.
06:57 You gained 784730 experience points.
06:57 You advanced from Level 100 to Level 101.
 
login.lua
Code:
function onLogin(cid)
    registerCreatureEvent(cid, "PlayerDeath")
    registerCreatureEvent(cid, "FirstItems")
    -- registerCreatureEvent(cid, "PremEnd")
    registerCreatureEvent(cid, "McFrag")
    return TRUE
end

creaturescripts.xml

Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
    <event type="login" name="PlayerLogin" script="login.lua"/>
    <event type="death" name="PlayerDeath" script="playerdeath.lua"/>
 
    <!--CUSTOM -->
    <event type="login" name="FirstItems" script="firstitems.lua"/>
    <!-- <event type="login" name="PremEnd" script="premend.lua"/> -->
    <event type="advance" name="Reward" script="reward.lua"/>
    <event type="kill" name="McFrag" script="mcfrag.lua"/>
</creaturescripts>


Problem is that I get the message you're supposed to get when I kill the other player
"You have been slain for killing a player with the same IP."
 
There is only 1 script with type kill: mcfrag.lua
You probable have 2 onKill Lua scripts, 1 mcfrag.lua and the one with removing health is another.
The fact that it doesn't show the print message in your console means that script isn't loaded, so it's like it's not added at all.
 
mcfrag.lua
Code:
function onKill(cid, target, lastHit)
print("script load test")
if cid ~= target and isPlayer(target) then
if getPlayerIp(cid) == getPlayerIp(target) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'You have been slain for killing a player of the same IP.')
doCreatureAddHealth(cid, -(2*getCreatureMaxHealth(cid)))
else
doPlayerAddItem(cid, 2152, 1)
end
end
return true
end

This is the only one with a onKill function that I have, the one we're working on.


These are my creaturescripts:
creaturescripts.png
 
Back
Top