• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua How to [Kill]?

8674011

New Member
Joined
Jun 21, 2010
Messages
160
Reaction score
3
Location
The House
Hi guys, I'm making a script which involves when a creature it teleports everyone in the room to a position, now I need some way to register the kill, but for some reason the creature script isn't working and i'm starting to wonder if "kill" is even an event for TFS 0.2.1.5

here is my
creaturescript.xml
Code:
    <event type="kill" name="TamedTroll" event="script" value="test.lua"/>

and

script that occurs:

Code:
function onKill()
    local NESTSPAWN = { {x = 524 , y = 838, z = 7},
{x = 524 , y = 838, z = 7, stackpos = STACKPOS_TOP_CREATURE}    }
   
    if(getGlobalStorageValue(1005) == 1) then
   
    if (isCreature(getThingfromPos(NESTSPAWN[2]).uid) == FALSE) then
    local nestteleport =    {
                            {x = 514, y = 828, z = 7},
                            {x = 534, y = 848, z = 7}
                            }
    local prizeteleport =    { {x = 502, y = 832, z = 7}    }
    for xcord = nestteleport[1].x , nestteleport[2].x do
        for ycord = nestteleport[1].y, nestteleport[2].y do
            local teleporthere = { {x = xcord, y = ycord, z = 7, stackpos = STACKPOS_TOP_CREATURE}}
            if isPlayer(getThingfromPos(teleporthere[1]).uid) == TRUE then
                doSendMagicEffect(teleporthere[1], CONST_ME_POFF)
                doTeleportThing(getThingfromPos(teleporthere[1]).uid, prizeteleport[1])
                doSendMagicEffect(prizeteleport[1], CONST_ME_ENERGYAREA)
                addEvent(broadcastMessage, 150 , "You Killed The Beast", MESSAGE_EVENT_ADVANCE)
            end
           
        end
    end
end
end

so any ideas?
 
Is it Registered in login.lua?
Second Look At This Part
Code:
local prizeteleport = { {x = 502, y = 832, z = 7} }
Must be Like this
Code:
local prizeteleport = {x = 502, y = 832, z = 7}
 
Is it Registered in login.lua?
Second Look At This Part
Code:
local prizeteleport = { {x = 502, y = 832, z = 7} }
Must be Like this
Code:
local prizeteleport = {x = 502, y = 832, z = 7}
yes it's registered in login and no that's not the problem, i put the code in the global event and it worked.
 
TFS 0.2.15 uses script instead of event and value.
Code:
<event type="kill" name="TamedTroll" script="test.lua"/>

It exists in TFS 0.2.15, creature event types in TFS 0.2.15:
Code:
login
logout
think
preparedeath
death
kill
advance
 
there are a few errors.
Code:
onKill()
missing it's params
Code:
onKill(cid, target)

why do you check an entire area to see if the monster is dead, if you already know that it's dead once the function executes.
just implement something like:
Code:
if getCreatureName(target) == nameofthemonster then

last you're missing a return value right before your last end.
 
Back
Top