Converting cEntity to cPlayer
#1
Hey,

I am messing arount with your software as it seems pretty nice and powerful.

But I have one problem: How do I convert an entity from the hook to a player?

In Java I get an Entity object from the Event (PlayerInteractEntityEvent in this case).
And then I can convert that to a Player: (Player)event.getEntity()

How do I do that in Lua?
Code:
function PlayerInteract(Player, Entity)
  if Entity:GetEntityType() == cEntity.etPlayer and Player:GetInventory():GetEquippedItem().m_ItemType == 369 then
    Player:SendMessage("§a" .. "..Name of Entity")
  end
end

Sorry for my nooby questions, but I am new to Lua and MCServer :)
Reply
Thanks given by:
#2
You should use cChatColour, it's clearer.

If you don't already have the API docs, they are here: http://mc-server.xoft.cz/LuaAPI/
Reply
Thanks given by:
#3
One should do this:

tolua.cast(Entity, "cPlayer"):GetInventory()...
Reply
Thanks given by:
#4
Thank you for the quick answers :), it is working now
Reply
Thanks given by:




Users browsing this thread: 4 Guest(s)