How do I make a certain ULX group spawn with a certain weapon?

How do I make a certain ULX group spawn with a certain weapon?
I want my “vip” ULX group to spawn with a certain weapon, but when I use a loadout mod it just makes them spawn with what I set and none of the tools that their darkrp job should spawn with. What do I do?

Use the PlayerLoadout Hook.

For example:


hook.Add("PlayerLoadout", "VIP_Loadout", function(ply)
    if ply:CheckGroup("vip") then -- CheckGroup is a ULib function
        ply:Give("weapon_physgun")
    end
end)

So would I just make something like vip_loadout.lua and put it in the autorun folder of my server?
Thanks for the quick reply btw

Yes.
This had to be run server side.
Then it should work. But I haven’t tested it.

Notice how on http://wiki.garrysmod.com/page/GM/PlayerLoadout the color of the box is blue/the text of the function? That means it’s only serverside. You should put it in autorun/server.

Blue = Serverside
Orange = Clientside
Blue/Orange = Shared
Green = Menustate

Alright, so I’ll do that. How do I make it so only a certain player will spawn with the weapon? I assume I’ll need their SteamID?

You’ll need to use https://wiki.garrysmod.com/page/Player/SteamID

/garrysmod/lua/autorun/server
correct?




VIPSteamIDs = {

	"SteamID1",
	
	"SteamID2",
	
	"SteamID3",



}

hook.Add("PlayerLoadout", "VIP_Loadout", function(ply)

	for k,v in pairs(VIPSteamIDs) do
	
	if ply:SteamID() == v then
	
		ply:Give("weapon_357")
		
		end
	
	end
end)


put the table in a shared file or just leave it in the server file, shared is recommended though.
Put the load out in a server file.

[editline]27th July 2016[/editline]

/garrysmod/lua/autorun/server
That would be the server yes

You don’t need to do a for loop through the table, couldn’t you just do
[lua]VIPSteamIDs = {
[“SteamID1”] = true,
[“SteamID3”] = true,
[“STEAMID3”] = true
}

hook.Add(“PlayerLoadout”, “VIP_Loadout”, function(ply)
if VIPSteamIDs[ply:SteamID()] then
ply:Give(“weapon_ak472”)
end
end)

– For Choosing Certain Weapons For Certain SteamIDS

VIPSteamIDs = {
[“SteamID1”] = {
gun = “weapon_357”
},
[“SteamID2”] = {
gun = “weapon_shit1”
},
[“SteamID3”] = {
gun = “weapon_shit2”
}
}

hook.Add(“PlayerLoadout”, “VIP_Loadout”, function(ply)
if VIPSteamIDs[ply:SteamID()] then
ply:Give(VIPSteamIDs[ply:SteamID()].gun)
end
end)[/lua]

This didn’t work for me.