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

LUA 8.60 Kill Reward Script

Jordan_August

New Member
Joined
Jul 24, 2012
Messages
122
Reaction score
4
I came across this kill reward script that works almost perfectly but there is one thing stopping me. I need this script to not give exp at all to the person that kills an individual on the same IP. If someone could help me out or point me in the right direction that would be great.
Code:
function onKill(cid, target, lastHit)
    if isPlayer(target) then
        if getPlayerParty(cid) == getPlayerParty(target) or getPlayerIp(cid) == getPlayerIp(target) then
            doPlayerAddExp(cid, -0)
            doPlayerSendTextMessage(cid, 20, "You have been punished for killing a player of the same IP.")
            setPlayerStorageValue(cid, 3000, getPlayerStorageValue(cid, 3000)+1)
        else
            doPlayerAddItem(cid, 2152, 1)
        end
    end
    return true
end
 
I came across this kill reward script that works almost perfectly but there is one thing stopping me. I need this script to not give exp at all to the person that kills an individual on the same IP. If someone could help me out or point me in the right direction that would be great.
Code:
function onKill(cid, target, lastHit)
    if isPlayer(target) then
        if getPlayerParty(cid) == getPlayerParty(target) or getPlayerIp(cid) == getPlayerIp(target) then
            doPlayerAddExp(cid, -0)
            doPlayerSendTextMessage(cid, 20, "You have been punished for killing a player of the same IP.")
            setPlayerStorageValue(cid, 3000, getPlayerStorageValue(cid, 3000)+1)
        else
            doPlayerAddItem(cid, 2152, 1)
        end
    end
    return true
end
It's not possible to make it in LUA. There is almost no way to check how much exp player received for kill (maybe it's in TFS 1.1, but not in old TFS for 8.6).

EDIT:
Tell us what engine you use (0.3.6? 0.4?). Maybe someone can write source fix for it.
 
i did not put a -0 just how the script was. I tried compiling a new .exe following the tutorial located via forums but it didnt seem to work and i had no errors in my compile. so i guess the only way imma do it is just disable MC i guess. which sucks.
 
Last edited:
i did not put a -0 just how the script was. I tried compiling a new .exe following the tutorial location via forums but it didnt seem to work and i had no errors in my compile. so i guess the only way imma do it is just disable MC i guess. which sucks.
If a script has 0 errors the way to see if it is working is to place print statements in different parts of the script to see where the problem lies.
For instance, using the current script you have:
Code:
function onKill(cid, target, lastHit)
    print("entered onKill", cid, target lastHit)
    if isPlayer(target) then
    print("entered isPlayer")
        if getPlayerParty(cid) == getPlayerParty(target) or getPlayerIp(cid) == getPlayerIp(target) then
        print("entered the if statement")
            doPlayerAddExp(cid, -0)
            doPlayerSendTextMessage(cid, 20, "You have been punished for killing a player of the same IP.")
            setPlayerStorageValue(cid, 3000, getPlayerStorageValue(cid, 3000)+1)
        else
        print("entered the else statement")
            doPlayerAddItem(cid, 2152, 1)
        end
    end
    print("entered return true")
    return true
end
This is how most programmers debug a script, if nothing prints to console window then the script isn't being properly called by the server meaning the problem could be with registering it in creature events.
 
Last edited:
If a script has 0 errors the way to see if it is working is to place print statements in different parts of the script to see where the problem lies.
For instance, using the current script you have:
Code:
function onKill(cid, target, lastHit)
    print("entered onKill", cid, target lastHit)
    if isPlayer(target) then
    print("entered isPlayer")
        if getPlayerParty(cid) == getPlayerParty(target) or getPlayerIp(cid) == getPlayerIp(target) then
        print("entered the if statement")
            doPlayerAddExp(cid, -0)
            doPlayerSendTextMessage(cid, 20, "You have been punished for killing a player of the same IP.")
            setPlayerStorageValue(cid, 3000, getPlayerStorageValue(cid, 3000)+1)
        else
        print("entered the else statement")
            doPlayerAddItem(cid, 2152, 1)
        end
    end
    print("entered return true")
    return true
end
This is how most programmers debug a script, if nothing prints to console window then the script isn't being properly called by the server meaning the problem could be with registering it in creature events.

I mean the script doesn't show any errors and it does not give the kill reward, and it sends the killer (if on the same ip) the message. The only issue im having is the fact that the script is still giving exp after the person with the same IP is killing someone.
 
Back
Top