ULX

Author Topic: ulx luarun question (coding)  (Read 5203 times)

0 Members and 1 Guest are viewing this topic.

Offline Solunae

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
ulx luarun question (coding)
« on: June 12, 2013, 01:04:49 PM »
So I wrote a simple Lua to spawn a entity.

Code: [Select]
c4 = ents.Create("ttt_c4")
aPlayer=ply:GetShootPos()
c4:SetPos(aPlayer)
c4:Spawn()
c4:SetDetonateTimer(100)
c4:SetArmed(true)

Entering this with the normal Lua_run in console on my listen server it will work as it should and spawn the entity on my shootpos.

But when I use this with the ulx luarun on a dedicated server it will not spawn this as ply is empty (I understand this).

Is there anyway I could have it spawn on me or by entering a player name using the ULX luarun?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ulx luarun question (coding)
« Reply #1 on: June 12, 2013, 02:19:12 PM »
If you're the first person to join the server since it has started (or possibly changed maps, not sure), you can use "Entity(1)" (or if you know your entid, use that instead). Otherwise, you could use ULib.getUser to do name matching.
Experiencing God's grace one day at a time.

Offline Solunae

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: ulx luarun question (coding)
« Reply #2 on: June 12, 2013, 02:25:25 PM »
So basically I would need something like.

Code: [Select]
c4 = ents.Create("ttt_c4")
Target = ULib.getUser("Solunae")
aPlayer = Target:GetShootPos()
c4:SetPos(aPlayer)
c4:Spawn()
c4:SetDetonateTimer(100)
c4:SetArmed(true)

Correct? or am I missing something.


*Edit*
The following code was the first Lua I ever made and it worked. But the problem in this one was finding a specific player entity ID. If there is a easy way to retrieve someones ID off a dedicated server with ULX installed that would work fine too. (I'm not the owner off this server but a superadmin with lua, rcon, exec)

Also they don't seem to work with the ulx luarun (might have format wrong) in console, but they do work in the ULX menu Lua run

Code: [Select]
c4=ents.Create("ttt_c4")
Target=player.GetByID(1):GetShootPos()
c4:Spawn() c4:SetPos(Target)
c4:SetDetonateTimer(100)
c4:SetArmed(true)

Code: [Select]
c4=ents.Create("ttt_c4")
Target=player.GetAll()
c4:Spawn()
c4:SetPos(Target[5]:GetShootPos())
c4:SetDetonateTimer(1)
c4:SetArmed(true)




Alright, this code works with the name finding. At first it seemed to fail untill I tried it in the actual ULX menu and not the ulx luarun in console.

Code: [Select]
c4 = ents.Create("ttt_c4")
Target = ULib.getUser("Solunae")
aPlayer = Target:GetShootPos()
c4:SetPos(aPlayer)
c4:Spawn()
c4:SetDetonateTimer(100)
c4:SetArmed(true)

Thanks for the assistance.
« Last Edit: June 12, 2013, 03:22:59 PM by Solunae »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ulx luarun question (coding)
« Reply #3 on: June 12, 2013, 03:30:27 PM »
See MrPresident's "ulx explode" in our releases section.
Though written in ULX command format, it passes players (plural) in a table to the function, then uses for loop to do various fun things.
Also, it's not been touched since years before Gmod13 came out.
Don't expect it to work as-is, just use it as an example of passing in the playerid.
Seems your idea wants to do the same...explode a player or something like that.
« Last Edit: June 12, 2013, 03:33:19 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: ulx luarun question (coding)
« Reply #4 on: June 12, 2013, 03:48:00 PM »
He wants to do it specifically from his console, JamminR.
Experiencing God's grace one day at a time.