Open Exmirai opened 10 years ago
Yeah, it'll come eventually. Just wondering what issues it'll cause between entities/ and players, considering players are entities. Hopefully none.
plz add that in clientside :)
What about this thing?)
some working Entity API code and maker mod plugin :) https://www.dropbox.com/s/nvn6a7ke43kp7cq/game.zip Please, can you improve code ( if needed ) and add them to serverside
Particularly done in ac33e2856c01d30b4ad1f9088a2dc94ec565b5e9 But... i can't test refEntities and client side features et all...blow up my videocard
done localentities and refentities in ef7a2df1a0ce79bceaac2a18a50c913f7e604539
Can you give me examples how to use the entity api in server side lua script? Also I was trying to use the JPLUA_ENTITY_USE event with a listener but it didn't seem to work. How should I use it?
entity:SetUseFunction(function() print('hello world') end)
all listeners described here: https://github.com/Razish/japp/blob/master/game/bg_luaentity.cpp#L1076
So the setusefunction is executed when the entity is being used. Is this function has parameters like self, other, activator? And Is there a command to get a list of entities on the server to find and id for an entity?
I have no luck with entities..
I tried this but didn't work, when I use the command nothing happens.
AddClientCommand( 'test', function(player) local clientNum = player.id local entities = FindEntityByClassName("info_null") for k, v in pairs(entities) do SendReliableCommand( clientNum, 'print "'..k..'-'..v..'\n"' ) end end )
It would have been much easier if there was a command which simply list all entities on the map with their id. You also gave me link on the previous post for EntitiesInBox and CreateEntity but without saying what is the EntitiesInBox for or how to use the CreateEntitiy it's not much help man.
info_null entities do not exist. They are removed 1 frame after game has loaded.
I tired it with other entity like func_door as well:
AddClientCommand( 'test', function(player)
local entities = FindEntityByClassName("func_door")
for k, v in pairs(entities) do
SendReliableCommand( player.id, 'print "id: '.. v.id ..' classname:'.. v.classname ..'\n"' )
end
end )
Still shows nothing. On the other hand I fixed this issue by adding a lua function which lists all the entities.
Now I'm stucked with the SetUseFunction. I have a trigger_multiple which target is a target_teleporter and that is linked to a misc_teleporter_dest. I would like to add some code when a player is using the trigger_multiple(like it could change the target on specific circumtances) and I just added a simple text print for this function but it doesn't show up when the player is using the trigger_multiple.
AddClientCommand( 'test2', function(player)
local ent = GetEntity(151)
ent:SetUseFunction(function()
SendReliableCommand( player.id, 'print "Entity 151 was used by player.\n"' )
end)
end )
use != touch, aren't triggers specifically entities that are touched?
Well you may be right. I just thought the player is using the use button when interacting with the trigger so that's why I went for the use function. I will try with the touch function then.
As for FindEntityByClassName
maybe ipairs
would work better
what about entity api?here are some functions: GetEntity() ent:GetType() (grenades, npc, etc...) ent:SetHealth() (if npc / breakable object) ent:GetHealth() ent:Teleport() ent:GetPosition ent:SetSpeed() / GetSpeed etc....