ULX

Author Topic: ULX Respawn  (Read 29978 times)

0 Members and 1 Guest are viewing this topic.

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
ULX Respawn
« on: February 22, 2012, 03:26:08 PM »
I was talking to one of the other Co-Owners of the server I'm on, during this talk he brought to my attention a command he had saw in another server something like "!spawn playername" it got me thinking, I would like to have a command like that on my server so If I see someone dead on the ground not re spawning I could just "!spawn" them myself, hypothetically could I just reverse the "!slay" command? or would I have to go further in to it? I basically have a code looking like this.

function ulx.spawn( calling_ply, target_plys )
   local affected_plys = {}
   
         table.insert( affected_plys, v )
      end
   end

   ulx.fancyLogAdmin( calling_ply, "#A spawned #T", affected_plys )
end
local slay = ulx.command( CATEGORY_NAME, "ulx spawn", ulx.spawn, "!spawn" )
spawn:addParam{ type=ULib.cmds.PlayersArg }
spawn:defaultAccess( ULib.ACCESS_ADMIN )
spawn:help( "Spwaned target(s)." )

am I naming the "spawn" incorrectly?

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX Respawn
« Reply #1 on: February 22, 2012, 03:34:10 PM »
Code: [Select]
function ulx.spawn( calling_ply, target_plys )
local affected_plys = {}
for k,v in pairs(target_plys) do
if !v:Alive() then
v:Spawn()
table.insert(affected_plys, v)
end
end
ulx.fancyLogAdmin( calling_ply, "#A spawned #T", affected_plys )
end
local spawn = ulx.command( CATEGORY_NAME, "ulx spawn", ulx.spawn, "!spawn" )
spawn:addParam{ type=ULib.cmds.PlayersArg }
spawn:defaultAccess( ULib.ACCESS_ADMIN )
spawn:help( "Spawnd target(s)." )

You'll have to make sure that CATEGORY_NAME is set.  Otherwise just change it to "Utility" or something.

Also... You can remove the Alive part if you don't want to check that.

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
Re: ULX Respawn
« Reply #2 on: February 22, 2012, 04:27:03 PM »
Well, I added a fixed version of ulx spawn to my server  under the tab "fun" and when I restarted the server the only command that work where the "slap" and "whip" command.

-EDIT-

Okay, I renamed the CATEGORY_NAME to Utility like you suggested now I'm just wondering if this is correct I also decided to keep the Alive part since I would like it to check if they are already alive (even though I'm missing a message saying the player is already alive)
Code: [Select]
function ulx.spawn( calling_ply, target_plys )
local affected_plys = {}
for k,v in pairs(target_plys) do
if !v:Alive() then
v:Spawn()
table.insert(affected_plys, v)
end
end
ulx.fancyLogAdmin( calling_ply, "#A spawned #T", affected_plys )
end
local spawn = ulx.command( Utility, "ulx spawn", ulx.spawn, "!spawn" )
spawn:addParam{ type=ULib.cmds.PlayersArg }
spawn:defaultAccess( ULib.ACCESS_ADMIN )
spawn:help( "Spawnd target(s)." )
« Last Edit: February 22, 2012, 06:27:04 PM by JamminR »

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
Re: ULX Respawn
« Reply #3 on: February 22, 2012, 05:50:25 PM »
^ Would the above command work?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX Respawn
« Reply #4 on: February 22, 2012, 06:29:00 PM »
If you place your category name in quotes, it has more chance.
It does look like it should work after that.

Also, when posting code here, use the [code] and [/code] tags.
Makes it easier to read, and places a 'select' link to highlight it all when needed.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
Re: ULX Respawn
« Reply #5 on: February 22, 2012, 07:29:38 PM »
So I should put "Utility" in quotes like that and then place it into  "/garrysmod/addons/ulx/lua/ulx/modules/sh"  under the .lua file "fun" ? Or shall I make a new .lua file with just this command?

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX Respawn
« Reply #6 on: February 22, 2012, 07:47:29 PM »
So I should put "Utility" in quotes like that and then place it into  "/garrysmod/addons/ulx/lua/ulx/modules/sh"  under the .lua file "fun" ? Or shall I make a new .lua file with just this command?
Either will work.

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
Re: ULX Respawn
« Reply #7 on: February 22, 2012, 07:57:06 PM »
Okay, I shall try it tonight and see what happens! I'll edit this if something goes wrong or if it works!

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX Respawn
« Reply #8 on: February 22, 2012, 08:46:07 PM »
LIke Aaron states, both should work.
However, I'd even go one step further.
Make your own ULX addons modules folder.
Editing 'our' fun.lua file, your changes would be overwritten (or file not updated, depending on your SVN installation) when you next update ULX.
Make a folder in addons called "MyULXStuff" or something like that. (Any name, as long as it doesn't match an existing gmod folder, would work)
Within that folder, create a folder structure "/lua/ulx/modules/sh" (So, if you used myulxstuff, it would look like "/garrysmod/addons/myulxstuff/lua/ulx/modules/sh"
Create your .lua file in that sh folder.
Copy an info.txt from gmod/addons/ulx to your /addons/myulxstuff folder.
Edit the .txt to match your author/credits, description, time and date etc.
Something like below should work as the info.txt
Code: [Select]
"AddonInfo"
{
"name" "MyULXStuff"
"version" "1.0"
"up_date" "02/23/12"
"author_name" "Digital Spit, Ulysses Community"
"author_url" "http://www.ulyssesmod.net/"
"info" "My ULX Module addition hacks"
"override" "0"
}

Now, you can update ULX without worry of it breaking your own edits.
You can develop your own ULX commands and add to your own 'addon' area without having to edit our files.
« Last Edit: February 22, 2012, 08:47:55 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
Re: ULX Respawn
« Reply #9 on: February 22, 2012, 09:04:53 PM »
<- That would be the directory I used...if you can't read it...it's "/garrysmod/addons/MyULXStuff/lua/ulx/modules/sh" with info.txt and respawn.lua in the sh folder

It still isn't working, I don't know what I'm doing wrong! :/

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: ULX Respawn
« Reply #10 on: February 22, 2012, 09:32:16 PM »
info.txt would go in addons/MyULXStuff/ not in /sh/

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
Re: ULX Respawn
« Reply #11 on: February 22, 2012, 09:38:20 PM »
It works now! Thank you guys for all of your help!!!!!!!!!

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: ULX Respawn
« Reply #12 on: February 23, 2012, 06:34:12 PM »
You're welcome.  Love helping people with Lua.

Offline Rodenknight

  • Newbie
  • *
  • Posts: 4
  • Karma: -2
Re: ULX Respawn
« Reply #13 on: July 16, 2015, 08:10:11 PM »
Can someone show me how to have only twenty seconds to respawn for my Deathrun server?

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: ULX Respawn
« Reply #14 on: July 16, 2015, 10:46:17 PM »
Welcome to the ULX Forums.

1. Please do not bump threads that are this old.
2. You will need to give a little more information when asking for help with something.

Please make a new thread in Off Topic with what you are requesting and I'm sure someone would be happy to assist. Remember, the more information you give, the more likely you are to find someone who can help you achieve your goal.