How would I go about making a certain rank spawn with a certain SWEP on DarkRP?

I have a rank called “VIP” on my DarkRP server, and I would like them to spawn with a certain SWEP called buddy_finder. How would I go about doing this? I’ve tried searching for a code like this in the DarkRP files that I could edit (copied and pasted from gmod lua wiki), but to no avail:
[lua]function GM:PlayerLoadout( ply ) // What should the player recieve when joining a team?

if ply:Team() == 1 then //If he is team 1, then give him the following items

	ply:Give( "weapon_physcannon" ) // A Gravity gun
	ply:Give( "weapon_physgun" ) // A Physics gun
	ply:Give( "gmod_tool" ) // and don't forget the tool gun!


elseif ply:Team() == 2 then // So if he isn't team 1, he could be team 2?

	ply:Give( "weapon_physcannon" ) //Assuming he is, then give him Gravity gun
	ply:Give( "weapon_physgun" ) // Physics gun
	ply:Give( "weapon_ar2" ) // AR2 
	ply:Give( "gmod_tool" ) // and the gmod tool

end //right here.

end // End the function

[/lua]

I hardly have any Lua experience, so if you feel kind enough to answer, please tell me exactly what to do with the code :slight_smile: Many thanks in advance! Also, if there’s an easier way to do this in DarkRP, please don’t keep it to yourself :D.

The “VIP” rank is a rank in ULX and Fadmin.

From my experience FAdmin causes problems with ULX so i would suggest removing it. But aside from that this should work (Not tested)
[lua]
hook.Add(“PlayerSpawn”,“givevipweapons”,function(ply)
if ply:IsUserGroup(“VIP”) then
ply:Give(“buddy_finder”)
end
end)
[/lua]

Thanks very much for the help, but where exactly do I put that code :)?

just make a new .lua file in garrysmod\lua\autorun

Just tried it and I can’t get it to work :confused: No errors or anything with it. If I try to do “rcon lua_openscript vip.lua”, this comes up :Couldn’t include file ‘vip.lua’ (File not found) (<nowhere>).
Not sure if that is supposed to happen or not. I put it in garrysmod/lua/autorun as you said.

Thanks for the help though mate :)!

[editline]10th February 2011[/editline]

Going to sleep now, will try again tomorrow if you or anyone else has more ideas :slight_smile:

lua_openscript autorun/vip.lua

Do you know why it was put in the autorun folder? So it could run auto.

I’ve just been fiddling around with it and I got your code working MayorBee, thank you so much! The weapon is actually called “weapon_buddyfinder” not “buddy_finder” (my bad, sorry). You’re a life saver! I edited it so that admins, superadmins and the root_user spawn with it also. If anyone reading this needs the full, tested code I am using is (thank you MayorBee!):

[lua]hook.Add(“PlayerSpawn”,“givevipweapons”,function(ply)
if ply:IsUserGroup(“vip”) or ply:IsUserGroup(“admin”) or ply:IsUserGroup(“superadmin”) or ply:IsUserGroup(“root_user”) then
ply:Give(“weapon_buddyfinder”)
end
end)[/lua]

garrysmod\lua\autorun\server

ply:IsAdmin() would work for super as well.

Hey all, anyway to prevent normal players form picking up the weapon, i got donator weps but t’s keep targetting the people with the gun to get it.