• 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 (CreatureEvent) After kill Help? tfs 0.4

Status
Not open for further replies.

Eddie TheGod

New Member
Joined
Jul 30, 2016
Messages
20
Reaction score
3
Hello I'm making a war server, and well my problem is, I try to add a creaturescript for when you kill a person he gives you 5 platinium coins on your backpack etc, and another one where whenever you kill someone, he will loot a certain item/id on his CORPSE. I'm not sure, but I think it has to do something with the login.lua script on the createscrupt but i'm not so sure. I have tfs 0.4 3777-master

Any help? Thx
 
Code:
function onKill(cid, target, lastHit)
    if isPlayer(target) then
        local item   = itemid
        local amount = amount
        doPlayerGiveItem(cid, 2152, 5)
        addEvent(doAddContainerItem, 0, getTileItemByType(getCreaturePos(target), ITEM_TYPE_CONTAINER).uid, item, amount)
    end
    return true
end
 
Nope man doesn't work :/ look this is my login.lua
Here is it VVVV
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil and getPlayerStorageValue(cid, "bless") ~= 5) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    if(getPlayerStorageValue(cid, "death_bless") == 1) then
        local t = {PLAYERLOSS_EXPERIENCE, PLAYERLOSS_SKILLS, PLAYERLOSS_ITEMS, PLAYERLOSS_CONTAINERS}
        for i = 1, #t do
            doPlayerSetLossPercent(cid, t, 100)
        end
        setPlayerStorageValue(cid, "death_bless", 0)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")

    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    return true
end|/code]
This is where it ends^^^
 
Nope man doesn't work :/ look this is my login.lua
Here is it VVVV
local config = {
loginMessage = getConfigValue('loginMessage'),
useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
local loss = getConfigValue('deathLostPercent')
if(loss ~= nil and getPlayerStorageValue(cid, "bless") ~= 5) then
doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
end

if(getPlayerStorageValue(cid, "death_bless") == 1) then
local t = {PLAYERLOSS_EXPERIENCE, PLAYERLOSS_SKILLS, PLAYERLOSS_ITEMS, PLAYERLOSS_CONTAINERS}
for i = 1, #t do
doPlayerSetLossPercent(cid, t, 100)
end
setPlayerStorageValue(cid, "death_bless", 0)
end

local accountManager = getPlayerAccountManager(cid)
if(accountManager == MANAGER_NONE) then
local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
if(lastLogin > 0) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
else
str = str .. " Please choose your outfit."
doPlayerSendOutfitWindow(cid)
end

doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
elseif(accountManager == MANAGER_NAMELOCK) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
elseif(accountManager == MANAGER_ACCOUNT) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
end

if(not isPlayerGhost(cid)) then
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
end

registerCreatureEvent(cid, "Mail")
registerCreatureEvent(cid, "GuildMotd")

registerCreatureEvent(cid, "Idle")
if(config.useFragHandler) then
registerCreatureEvent(cid, "SkullCheck")
end

registerCreatureEvent(cid, "ReportBug")
registerCreatureEvent(cid, "AdvanceSave")
return true
end
This is where it ends^^^
you have to save my code in another file, add it to creaturescripts xml and register it in login.lua
 
Okok let me try it man, thank you for helping, let me test it out

So for example, I added it to the creaturescript, but how do I register it on the login.lua? I called it onKill, so for example I put this
registerCreatureEvent(cid, "onKill")
?
 
Last edited by a moderator:
So for example, I added it to the creaturescript, but how do I register it on the login.lua? I called it onKill, so for example I put this
registerCreatureEvent(cid, "onKill")
?
i wouldnt call it onKill but sure
register name should be whatever your name=" " in xml
 
DUDE it worked! Thank you so much!

i wouldnt call it onKill but sure
register name should be whatever your name=" " in xml
Holy fck dude, you saved my life! Lmao!! Thank you tbh! waiting for 2 days to fix this. Thanks
 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top