Will my code work? [beginner]

First off all, i want a code that can give a specific playerid a weapon. (Donator thing so i can make a donator kit like assault kit wich gives a assault rifle etc…)

Ok, so the steamid is not real nor is the weapon id real, it’s just a example. Would this work? I am just starting out and barely learned any lua but will it work?

[lua]PlayerSpawn = function(ply) if userid == “steam_0:16627382” then ply:Give( “m9k_glock” ) end,[/lua]

Assuming “userid” was declared, and PlayerSpawn belongs in a table, then yes, the syntax seems correct, except you missed an “end” to close the function “PlayerSpawn”

Here’s the completed code:



PlayerSpawn = function( Player )
    if ( Player:SteamID() == "STEAM_0:16627382" ) then
        Player:Give( "m9k_glock" )
    end
end,


Or, as a line:



PlayerSpawn = function( Player ) if ( Player:SteamID() == "STEAM_0:16627382" ) then Player:Give("m9k_glock" ) end end,


Ok, so is there any other way to do this so i don’t have to place it in every single job?





hook.Add( "PlayerSpawn", "name whatever", function( ply )


    if ply:SteamID() == "STEAM_0:16627382" then

       ply:Give( "m9k_glock" )

    end


end )




better hook to use is

GM/PlayerLoadout



hook.Add( "PlayerLoadout", "name whatever", function( ply )

    if ply:SteamID() == "STEAM_0:16627382" then

       ply:Give( "m9k_glock" )

    end

end )


Where do i put this? Do i just put it somewhere in jobs.lua?

Anywhere serverside