Broadcast message
#1
im trying to broadcast a message when an entity dies (yes i have the hook connected to the function bla bla) and i get an error when trying to execute 

my code:
Code:
function OnKilled(World)
    World:BroadcastChat("Death Lingers...");
    return true;
end

my error:
Code:
LUA: Plugins/CustomPlugin/CustomPlugin.lua:25: attempt to call method 'BroadcastChat' (a nil value)
Stack trace:   Plugins/CustomPlugin/CustomPlugin.lua(25): (no name)
Stack trace end
Error in <attached> calling function <callback>()

any help is greatly appreciated Smile
Reply
Thanks given by:
#2
This should work:
Message when mobs and players die:
Code:
function OnKilled(Victim)
    Victim:GetWorld():BroadcastChat("Death Lingers...")
end

Message when players die:
Code:
function OnKilled(Victim)
    if Victim:IsPlayer() then
        Victim:GetWorld():BroadcastChat("Death Lingers...")
    end
end
Reply
Thanks given by:




Users browsing this thread: 2 Guest(s)