• 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 Frag Rewards

X X X

Newb
Joined
Jul 26, 2015
Messages
148
Reaction score
13
I've looked through a lot of threads, and I can't get this to work. Literally, nothing happens; no exp, no message, no platinum coin, dying is the same as it was before I added these.
Any help would be much appreciated =)

fragrewards.lua
Code:
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
creaturescripts.xml
Code:
<event type="kill" name="FragReward" value="fragreward.lua"/>
login.lua
Code:
registerCreatureEvent(cid, "FragReward")
 
I've looked through a lot of threads, and I can't get this to work. Literally, nothing happens; no exp, no message, no platinum coin, dying is the same as it was before I added these.
Any help would be much appreciated =)

fragrewards.lua
Code:
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
creaturescripts.xml
Code:
<event type="kill" name="FragReward" value="fragreward.lua"/>
login.lua
Code:
registerCreatureEvent(cid, "FragReward")

I think the problem is in the XML tag. Try this:
Code:
<event type="kill" name="FragReward" event="script" value="fragreward.lua"/>
 
Code:
<event type="kill" name="FragReward" value="fragreward.lua"/>

Any help would be much appreciated =)

fragrewardS.lua

maybe you are missing an s at the end in the xml value thingy?

The value in the xml file has to be equal to your .lua script name.
 
I think the problem is in the XML tag. Try this:
Code:
<event type="kill" name="FragReward" event="script" value="fragreward.lua"/>
Tried it, but I was just following the models of everything else in my creaturescripts.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
    <event type="login" name="PlayerLogin" script="login.lua"/>
    <event type="login" name="FirstItems" script="firstitems.lua"/>
    <event type="death" name="PlayerDeath" script="playerdeath.lua"/>
    <event type="kill" name="FragReward" script="fragreward.lua"/>
</creaturescripts>

Code:
<event type="kill" name="FragReward" value="fragreward.lua"/>



maybe you are missing an s at the end in the xml value thingy?

The value in the xml file has to be equal to your .lua script name.
I had it right, I just typed it wrong on here :p

Remove "lastHit" from this:

function onKill(cid, target, lastHit)

I'm assuming you're using 0.3 or 0.4. There was a bug with it. :p Also, check this out:


Good luck. :) Merry Christmas.
Tried it, no difference. And I'm using 0.2.15 :)

Thanks for the help guys but still nothin comin up :(



The problem may be I didn't format the code correctly... I got the script from another thread that was just pasted into the reply box, and I'm not familiar with indenting and all the stuff in coding... Not sure if I have all of the "ends" and the trues" in the right spot. So here it is again:
Code:
function onKill(cid, target)
    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
 
Sorry for double post but I got it fixed :D
Noticed an error in xml and the server started telling me what line the error was on. Thanks tho guys! Merry Christmas :)
 
Back
Top