Cuberite Forum

Full Version: Check if there are mobs alive
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
no each entity in the server has a unique ID. that way you can separate them.
Yes. A number that uniquely identifies the mob throughout its life. It's used for networking and it's also used if you need to "remember" an entity between different callbacks in the plugin (you cannot store the entity object!)
What's wrong with this?
function HandleCheckCommand( Player )
	local EachEntity = function( Entity )
		if Entity:IsMob() == true then
		       Mobs = Mobs + 1
              end
       end

       local loopPlayer = function ( Player )
              Player:SendMessage( "Killed " .. Mobs .. " mobs." )
              return true
       end
end
It gives me Unknown command
do "return true" before the last end
Currently your code does nothing. You declare two local functions, but never use them.
Also, don't compare boolean vars to constants, use them directly.
And last but not least, the code won't do what you want - supposing you fix everything, the first function will count all the *living* mobs.

function HandleCheckCommand(Player)
    local CountIfMob = function(Entity)
        if Entity:IsMob() then
              Mobs = Mobs + 1;
        end
    end

    Player:GetWorld():ForEachEntity(CountIfMob);
 
    Player:SendMessage("There are currently " .. Mobs .. " mobs." );

    return true;
end
(05-07-2013, 05:44 AM)xoft Wrote: [ -> ]the code won't do what you want - supposing you fix everything, the first function will count all the *living* mobs.
I know it, to kill all mobs is Entity:Destroy()
It gives me an error with GetWorld
It's brokenTongue
(05-08-2013, 05:31 AM)xoft Wrote: [ -> ]It's brokenTongue
GetWorld?
With other plugins work
What else can I tell you? You didn't say what the error was, you didn't post your code, nothing. So there's really nothing else I can say.
Pages: 1 2 3