Check if there are mobs alive - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: Check if there are mobs alive (/thread-874.html) |
RE: Check if there are mobs alive - NiLSPACE - 05-07-2013 no each entity in the server has a unique ID. that way you can separate them. RE: Check if there are mobs alive - xoft - 05-07-2013 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!) RE: Check if there are mobs alive - tonibm19 - 05-07-2013 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 endIt gives me Unknown command RE: Check if there are mobs alive - NiLSPACE - 05-07-2013 do "return true" before the last end RE: Check if there are mobs alive - xoft - 05-07-2013 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 RE: Check if there are mobs alive - tonibm19 - 05-07-2013 (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() RE: Check if there are mobs alive - tonibm19 - 05-08-2013 It gives me an error with GetWorld RE: Check if there are mobs alive - xoft - 05-08-2013 It's broken RE: Check if there are mobs alive - tonibm19 - 05-08-2013 (05-08-2013, 05:31 AM)xoft Wrote: It's brokenGetWorld? With other plugins work RE: Check if there are mobs alive - xoft - 05-08-2013 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. |