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

Kill Player Gain Gold

xLosT

Member
Joined
Jan 11, 2010
Messages
1,022
Reaction score
13
Location
Brasil, Rio Grande do Sul
i need script to tfs 1.2 if kill player gain gold i have one but dont work and not erros in console

Code:
function onKill(cid, target, lastHit)
local reward = {
        item = 2152, --ITEM ID!
        count = 1 -- How many?
}
    if cid ~= target and isPlayer(target) and getPlayerLevel(target) <= 132 then
    if getPlayerIp(cid) ~= getPlayerIp(target) then
                        doPlayerAddItem(cid, 2152, 1)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"You cannot take reward by killing a player of the same IP.")
                end
end
return TRUE
end
 
please learn how to indent properly
lua-users.org/wiki/LuaStyleGuide

Code:
local reward, count = 2152, 1

function onKill(creature, target)
    if creature:getPlayer() and target:getPlayer() then
        if creature:getIp() ~= target:getIp() then
            if target:getLevel() <= 132 then
                target:addItem(reward, count)
            end
        else
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You may not get a reward by killing a player with the same IP as yours.')
        end
    end
    return true
end
 
Code:
local reward, count = 2152, 1

function onKill(creature, target)
    if creature:getPlayer() and target:getPlayer() then
        if creature:getIp() ~= target:getIp() then
            if target:getLevel() <= 132 then
                creature:addItem(reward, count)
            end
        else
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You may not get a reward by killing a player with the same IP as yours.')
        end
    end
    return true
end
 
player:registerEvent("onkill")
onkill.lua
<event type="kill" name="onkill" script="onkill.lua"/>


I do not know if there are any similarities
But when you kill some player the server do not register anything in the database
 
i tested it
are you registering it in the xml and login.lua?
i found in login.lua have one " < " and bug all scripts i remove and work, but have one error

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/onkill.lua:onKill
data/creaturescripts/scripts/onkill.lua:4: attempt to index global 'creature' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/creaturescripts/scripts/onkill.lua:4: in function <data/creaturescripts/scripts/onkill.lua:3>
 
i found in login.lua have one " < " and bug all scripts i remove and work, but have one error

Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/onkill.lua:onKill
data/creaturescripts/scripts/onkill.lua:4: attempt to index global 'creature' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/creaturescripts/scripts/onkill.lua:4: in function <data/creaturescripts/scripts/onkill.lua:3>
did you edit the code at all?
if you did then show it
if you didn't i don't know what to tell you because i tested it
 
Code:
local reward, count = 2152, 1

function onKill(creature, target)
    if creature:getPlayer() and target:getPlayer() then
        if creature:getIp() ~= target:getIp() then
            if target:getLevel() <= 132 then
                creature:addItem(reward, count)
            end
        else
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You may not get a reward by killing a player with the same IP as yours.')
        end
    end
    return true
end

works perfectly on tfs 1.2 thanks.
 
Back
Top