Spawn Custom Mob Example
#2
I wrote a example that spawns a sheep and set's the speed to zero.

Register the command handler in a plugin:
Code:
cPluginManager:BindCommand("/spawnmob", "spawnmob", CommandSpawnMob, "spawns a mob")


Code:
function CommandSpawnMob(a_Split, a_Player) -- I created a command handler, that will spawn a sheep and sets the speed to 0.
    local mobID = a_Player:GetWorld():SpawnMob(a_Player:GetPosX(), a_Player:GetPosY(), a_Player:GetPosZ(), mtSheep) -- Spawns a sheep at player's position
    
    assert(mobID ~= -1, "Mob spawn failed") -- This can happen, if for example a plugin denies the spawning of monsters
    
    a_Player:GetWorld():DoWithEntityByID(mobID,
        function(Entity)
            Entity:SetRelativeWalkSpeed(0)
        end)
    
    
    a_Player:SendMessage("Spawned sheep.")
    return true
end


Sources:
cMonster
SpawnMob
DoWithEntityByID
Reply
Thanks given by:


Messages In This Thread
Spawn Custom Mob Example - by djlw78 - 04-30-2017, 12:01 PM
RE: Spawn Custom Mob Example - by Seadragon91 - 04-30-2017, 02:58 PM
RE: Spawn Custom Mob Example - by Seadragon91 - 04-30-2017, 03:15 PM
RE: Spawn Custom Mob Example - by xoft - 04-30-2017, 06:11 PM
RE: Spawn Custom Mob Example - by Seadragon91 - 04-30-2017, 06:14 PM
RE: Spawn Custom Mob Example - by djlw78 - 05-01-2017, 01:57 AM



Users browsing this thread: 2 Guest(s)