• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

RevScripts revscript reward onplayerkill

johnsamir

Banned User
Joined
Oct 13, 2009
Messages
555
Solutions
5
Reaction score
98
Location
Nowhere
Hello

I've created this simple revscript based on others scripts function. the script is not working and is not giving
at data/scripts reward.lua
Code:
local killevent = CreatureEvent("kill_rewards")

local reward, count = 2152, 3

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

killevent:register()





at creaturescripts/login.lua
Lua:
player:registerEvent("kill_rewards")
 
OP
OP
J

johnsamir

Banned User
Joined
Oct 13, 2009
Messages
555
Solutions
5
Reaction score
98
Location
Nowhere
Lua:
local killevent = CreatureEvent("kill_rewards")

local reward, count = 2152, 3

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

killevent:register()
nothing occurs
 
OP
OP
J

johnsamir

Banned User
Joined
Oct 13, 2009
Messages
555
Solutions
5
Reaction score
98
Location
Nowhere
You need to add another creature event .onLogin where you
player:registerEvent("kill_rewards")
i have registered it at creaturescripts/login.lua too or what do you mean?
Post automatically merged:

I get it now i know it's working because is sending me error haha thank you!
always get this problem don't know how to close functions very well, could you point me out whta's missing because adding ends or returns does not work
Lua:
local killevent = CreatureEvent("kill_rewards")

local reward, count = 2152, 3

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

killevent:register()


function login.onLogin(player)
    player:registerEvent("kill_rewards")
    return true
end

login:register()

fixed, solution:
Lua:
local killevent = CreatureEvent("kill_rewards")

local reward, count = 2152, 3

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

killevent:register()

local login = CreatureEvent("kill_rewards")

function login.onLogin(player)
    player:registerEvent("kill_rewards")
    return true
end

login:register()

this was missing:
Code:
local login = CreatureEvent("kill_rewards")

now have no errors but script does not work, not even sending message
Code:
   player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, 'You may not get a reward by killing a player with the same IP
 
Last edited:
Top