ULX

Author Topic: Give Weapons on Spawn (Group Specific)  (Read 14936 times)

0 Members and 1 Guest are viewing this topic.

Offline -RJ-

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Give Weapons on Spawn (Group Specific)
« on: October 08, 2011, 11:36:09 AM »
This is more of a request than a suggestion, but I was wondering if anyone could make
it where a user is automatically given weapons when they spawn. Also if it could be group
specific, so you set a specific group to spawn with certain weapons and so when a person
spawns they'll be given the specified weapons. (I'm no pro but is it possible to make it so
it uses a "give" command when they spawn?)

If anyone can do this for me I'll greatly appreciate it! Thanks :)

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Give Weapons on Spawn (Group Specific)
« Reply #1 on: October 08, 2011, 12:40:08 PM »
http://forums.ulyssesmod.net/index.php/topic,3177.0.html
Though particular question in that FAQ is prevent specific, it leads to many discussions that might allow specific.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline -RJ-

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: Give Weapons on Spawn (Group Specific)
« Reply #2 on: October 08, 2011, 04:35:09 PM »
I don't necessarily want it so that it limits their loadout to only a select amount of weapons.
What I'm getting at is when the user that's in a specific group will have the default weapons
and will be given weapons that are specified.

The reason for this is because I'm running a Fretta server and I need it so that a group like
Donator would get some fun sweps but would also have the smg to kill props or if it were
Deathrun I'd need it so that they still get those fun sweps but won't have an smg.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Give Weapons on Spawn (Group Specific)
« Reply #3 on: October 08, 2011, 09:43:39 PM »
I understand what you're going for, and I still recommend you see the FAQ I suggested.
URS, part of the answer to that question, will allow for specific loadouts for each/every group.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Give Weapons on Spawn (Group Specific)
« Reply #4 on: October 08, 2011, 10:50:14 PM »
Here you go!

Code: [Select]
function Custom_Loadout( ply )

if ply:IsUserGroup("donator") then --checks to see if the player is a member of the group "donator"

ply:GiveAmmo(30,"buckshot",true) --Gives the player ammo type 'buckshot'
ply:Give("weapon_shotgun") --Gives the player weapon weapon_shotgun

end
 
end
 hook.Add( "PlayerLoadout", "CustomGamemodeLoadoutFunction", Custom_Loadout)

Place this code into a file called customloadout.lua and put that file in your garrysmod/lua/server folder.


You will need to have an if statement for each separate group you wish to give weapons to in this manner.

Individual ply:Give and ply:GiveAmmo can be on separate lines. Be sure you give the player ammo for the weapons you give them if applicable. You can find a list of all the ammo types and weapons here and here
« Last Edit: October 08, 2011, 10:52:19 PM by MrPresident »

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Give Weapons on Spawn (Group Specific)
« Reply #5 on: October 08, 2011, 10:51:36 PM »
If this is too complicated for you to do on your own, then be more specific with exactly you want and I will throw it together for you. It's very simple, but taking the time to make something that is robust and modular would take a while and I honestly don't have the time to work on something like that.

Offline -RJ-

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: Give Weapons on Spawn (Group Specific)
« Reply #6 on: October 09, 2011, 07:43:01 AM »
Work perfectly! Thanks! :D

Code: [Select]
function Custom_Loadout( ply )

if ply:IsUserGroup("superadmin") then

ply:Give("weapon_raveball")

        elseif ply:IsUserGroup("majordonator") then
 
          ply:Give("weapon_raveball")
 
end
 
end
 hook.Add( "PlayerLoadout", "CustomGamemodeLoadoutFunction", Custom_Loadout)

Tell me if I did anything wrong

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Give Weapons on Spawn (Group Specific)
« Reply #7 on: October 09, 2011, 11:37:05 AM »
No, that will work.. but it would be more efficient to do it this way.

Code: [Select]
function Custom_Loadout( ply )

if ( ply:IsUserGroup( "superadmin" ) or ply:IsUserGroup( "majordonator" ) ) then

ply:Give( "weapon_raveball" )
 
end
 
end
hook.Add( "PlayerLoadout", "CustomGamemodeLoadoutFunction", Custom_Loadout )