I want to give a steam id a specific weapon on every spawn, will this work?
[CODE]function Custom_Loadout( ply )
if ply:SteamID() == "STEAM_0:1:16352908", then --checks steamID
ply:Give("m9k_rpg7") --Gives the player rpg
end
end
hook.Add( "PlayerLoadout", "CustomGamemodeLoadoutFunction", Custom_Loadout)[/CODE]
remove comma after the steamid string, and localize the function. Yep, should work.
Yep, should work.
Examples:
[code]if ply:SteamID() == "STEAM_0:1:2" or ply:SteamID() == "STEAM_0:1:1" or ply:SteamID() == "STEAM_0:1:3" then[/code]
or
[code]local tbl_steamids = { "STEAM_0:1:1", "STEAM_0:1:2", "STEAM_0:1:3" }
if table.HasValue(tbl_steamids, ply:SteamID()) then[/code]
[QUOTE=Pypsikan;52427340][code]local tbl_steamids = { "STEAM_0:1:1", "STEAM_0:1:2", "STEAM_0:1:3" }
if table.HasValue(tbl_steamids, ply:SteamID()) then[/code][/QUOTE]
Please don't do that.
[code]local ids = {["id 1"] = true, ["id 2"] = true,}
if ids[ply:SteamID()] then[/code]
--snip--
If i wanted to add another steamID (with a different weapon) could I paste the code underneath this current one, or would i need to make a new file?
[QUOTE=Slyde;52427634]If i wanted to add another steamID (with a different weapon) could I paste the code underneath this current one, or would i need to make a new file?[/QUOTE]
[lua]local ids = {
["id 1"] = "weapon_name",
["id 2"] = "other_weapon_name",
}
hook.Add( "PlayerLoadout", "CustomGamemodeLoadoutFunction", function( ply )
local wepForPly = ids[ply:SteamID()]
if wepForPly then
ply:Give( wepForPly )
end
end )[/lua]
No, you could make it modular and have a table of ID->weapons:
[code]local tIDWeapons = {
["STEAM_0:1:16352908"] = "m9k_rpg7",
["STEAM_0:1:00000000"] = "blah",
-- Give multiple weapons to one player with a table
["STEAM_0:1:11111111"] = {
"blah",
"m9k_rpg7",
"a_third_weapon"
}
}
hook.Add("PlayerLoadout", "CustomGamemodeLoadoutFunction", function(ply)
local weapon = tIDWeapons[ply:SteamID()]
if (weapon ~= nil) then
if (isstring(weapon)) then
ply:Give(weapon)
else
for i = 1, #weapon do
ply:Give(weapon[i])
end
end
end
end)[/code]
[editline]3rd July 2017[/editline]
Ninja'd
Function id (ply)
If ply:SteamID = SteamID(0.1.1) then
Get.Weapon("m9k")
end
Sorry, you need to Log In to post a reply to this thread.