spawning certain groups with certain weapon lua problems

So I am trying to do what the title says I have tryed the following code sets

the first one spawns weapons for owners the second no one help me make my shitty coding work

if SERVER then
AddCSLuaFile(“custom.lua”)

local function BuzzIsBadAtLua(ply)
if ply:IsUserGroup("owner") then
	ply:Give("weapon_ttt_mp7")
	ply:GiveAmmo(60, "smg1")
	ply:Give("weapon_ttt_siltmp")
	ply:GiveAmmo(60, "pistol")
	elseif ply:IsUserGroup("user") then
	ply:Give("weapon_zm_pistol")
	
	ply:ServerMessage("For being all stupid you have been given awesome weapons to start with.")
end

end
hook.Add(“PlayerLoadout”, “BuzzIsBadAtLua”, BuzzIsBadAtLua)
end

if CLIENT then
local function BuzzIsDumb( data )
message = data:ReadString()
chat.AddText(Color(255, 0, 0), "[Buzz]: ", Color(0, 255, 0), message )

end
usermessage.Hook( “SpawnWeapons”, BuzzIsDumb )
end

==============================================================================================

if SERVER then
AddCSLuaFile(“custom.lua”)

function SpawnGuns( ply )
if ply:IsUserGroup(“owner”) then
ply:Give(“weapon_ttt_mp7”)
ply:Give(“weapon_ttt_siltmp”)
elseif ply:IsUserGroup(“admin”) then
ply:Give(“weapon_ttt_m16”)
ply:Give(“weapon_zm_revolver”)
elseif ply:IsUserGroup(“user”)
ply:Give(“weapon_zm_pistol”)
end
end
hook.Add(“PlayerSpawn”, “SpawnWithGuns”, SpawnGuns)
end

if CLIENT then
local function BuzzIsDumb( data )
message = data:ReadString()
chat.AddText(Color(255, 0, 0), "[Buzz]: ", Color(0, 255, 0), message )

end
usermessage.Hook( “SpawnWeapons”, BuzzIsDumb )
end

Can you explain what you want?

i WANT OWNER/ALL DONATOR RANKS TO SPAWN TO SPAWN WITH WEAPON x WITH X AMOUNT OF AMMO
i WANT OTHER STAFF TO SPAWN WITH WEAPON Y WITH Y AMOUNT OF AMMO
AND LASTLY i WANT USERS TO SPAWN WITH WEAPON Z WITH Z AMOUNT OF AMMO
sorry for caps lock & for wasting your time not knowing this

Ok, 1) Please wrap your code in [lua] or


 tags.
We may or may not have mentioned this previously to you; we have to many many many others :-)

PlayerLoadout is SERVERside, so you don't need to call it on the CLIENT.

Use net messages instead of umsg; the difference is umsg is limited to something like 255 bytes or something really small, and it's sent on the next frame whereby net messages are sent instantly and have a size capacity of 64kb. It's VERY EASY to switch from umsg to net; in addition, the CLIENT can use net to SendToServer( ) whereby with umsg you could not and many relied on console commands to do that work.

Ok, on to the code. Very simple, all it does is define a table of usergroups. The usergroup names are strings, they can be initialized in tables this way such as owner, admin, user. The weapons they're to spawn with on PlayerLoadout is a sub-table next to them. The ammo they spawn with is automatically retrieved from the Weapons table, 60 per.

Is this what you were looking to achieve?

[lua]	local PlayerLoadoutWeaponsForGroupSystem = {
		owner = { "weapon_ttt_mp7", "weapon_ttt_siltmp" };
		admin = { "weapon_ttt_m16", "weapon_zm_revolver" };
		user = { "weapon_zm_pistol" };	
	};

	hook.Add( "PlayerLoadout", "PlayerLoadout:GroupWeapons", GAMEMODE, function( _p )
		local _group = _p:GetNWString( "UserGroup" );
		for k, _w in pairs( PlayerLoadoutWeaponsForGroupSystem[ _group ] ) do
			local _wInfo = weapons.Get( _w );
			if ( !_wInfo ) then continue; end

			_p:Give( _w );
			_p:GiveAmmo( 60, _wInfo.Primary.Ammo );
		end
	end );[/lua]