Author Topic: ulx_ent Command  (Read 2866 times)

0 Members and 4 Guests are viewing this topic.

Offline Chicken132

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
ulx_ent Command
« on: April 28, 2006, 06:12:40 PM »
I have been setting up a large amount of path tracks in configuration files to be executed and spawn a path_track with the specified keys and values problem is the entities are supposed to stay at the player origin, and I can't for the life of me figure out how to set ulx to spawn the entity at user origin is there any way to do this.

I was looking at the code for the ulx_util.lua

Quote
function cc_ulxEnt( userid, args, argv, argc )
   ulx_log( "Admin " .. ulx_playerString( userid ) .. " created an ent, using these arguments: " .. args ) -- Log first incase it crashes
   local class = argv[ 1 ]
   table.remove( argv, 1 ) -- We already have the first now
   newEnt = _EntCreate( class )

   local pos = _PlayerGetShootPos( userid )
   local ang = _PlayerGetShootAng( userid )
   _TraceLine( pos, ang, 4096, userid )
   local vector = _TraceEndPos()
   vector.z = vector.z + 20
   debug( tostring( vector ) )
   _EntSetKeyValue( newEnt, "origin", vector.x .. " " .. vector.y .. " " .. vector.z ) -- Note that the position can be overridden by the users's flags

   for i,v in ipairs( argv ) do -- Loop through them
      local key = string.sub( v, 1, string.find( v, ":" ) - 1 )
      local value = string.sub( v, string.find( v, ":" ) + 1 )
      _EntSetKeyValue( newEnt, key, value )
   end

   _EntSpawn( newEnt )
end

ULX_CONCOMMAND( "ulx_ent", cc_ulxEnt, ACCESS_ENT, "<classname> <flag> .. - spawn an ent, separate flag and value with : ( IE: ulx_ent prop_ragdoll model:models/alyx.mdl )", 1 )

This portion of the line
Quote
Note that the position can be overridden by the users's flags
leads me to believe that you can some how

if it isnt possible with the current command code is it possible for someone to rewrite the code here to do so so that i can add it to the ulx_util.lua file as another command

Thanks

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ulx_ent Command
« Reply #1 on: April 28, 2006, 06:27:50 PM »
It wouldn't be possible directly from console... but in lua:

[lua]
   newEnt = _EntCreate( "path_track" )

   local pos = _PlayerGetShootPos( userid )
   _EntSetKeyValue( newEnt, "origin", pos.x .. " " .. pos.y .. " " .. pos.z )
[/lua]

And then set any other keyvalues you want as well.
Experiencing God's grace one day at a time.

Offline Chicken132

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: ulx_ent Command
« Reply #2 on: April 28, 2006, 06:47:52 PM »
Now if I wanted to keep the entity creation so that I would be able to spawn different entities other than just path_track i should keep the "path_track" at "class" instead of replacing it with "path_track".

Also since I am most likely not the only one that would need this is it possible that this could be added to the next release as well?

Thanks Meg

Btw that Ultimate NPC Spawning Script for version 7 totally kicked ass Great work