So I have the following script:
[CODE]---Weapon Loadout - Master -----------------------------------
local Coder = player.GetBySteamID( "STEAM_0:1:41036632" )
local ValidRanks = {
"kittenkingdonator",
"director",
"donator2",
"owner",
"alpha",
"donatoradmin",
"coder",
"superadmin",
"donator",
"limbo"
}
hook.Add( "TTTBeginRound", "loadout_masterhook", function()
if SERVER then
Coder:PrintMessage( HUD_PRINTTALK, "Step 1" )
for _, pl in pairs(player.GetAll()) do
Coder:PrintMessage( HUD_PRINTTALK, "Step 2" )
if (table.HasValue(ValidRanks, pl:GetUserGroup())) then
Coder:PrintMessage( HUD_PRINTTALK, "Step 3" )
local identifier = pl:SteamID64()
local primary = pl:GetInfo( "ttt_loadout_primary" )
local secondary = pl:GetInfo( "ttt_loadout_secondary" )
local equipment = pl:GetInfo( "ttt_loadout_equipment" )
file.CreateDir( "loadout/" .. identifier )
file.Write( "loadout/" .. identifier .. "/primary.txt", primary )
file.Write( "loadout/" .. identifier .. "/pistol.txt", secondary )
file.Write( "loadout/" .. identifier .. "/equipment.txt", equipment )
if pl:IsSpec() ~= true then
Coder:PrintMessage( HUD_PRINTTALK, "Step 3.5" )
local identifier = pl:SteamID64()
if file.Exists( "loadout/" .. identifier .. "/primary.txt", "DATA" ) then
Coder:PrintMessage( HUD_PRINTTALK, "Step 4" )
local weapon = file.Read( "loadout/" .. identifier .. "/primary.txt", "DATA" )
Coder:PrintMessage( HUD_PRINTTALK, weapon )
local wep = weapons.Get( weapon )
for _, k in pairs(pl:GetWeapons()) do
local wepclass = k:GetClass()
if weapons.Get( wepclass ).Kind == wep.Kind then
pl:StripWeapon( wepclass )
end
end
local ammoamt = wep.Primary.ClipMax
local ammotype = wep.Primary.Ammo
pl:Give( weapon )
pl:SelectWeapon( weapon )
pl:SetAmmo( ammoamt, ammotype, true )
end
if file.Exists( "loadout/" .. identifier .. "/pistol.txt", "DATA" ) then
Coder:PrintMessage( HUD_PRINTTALK, "Step 5" )
local weapon = file.Read( "loadout/" .. identifier .. "/pistol.txt", "DATA" )
Coder:PrintMessage( HUD_PRINTTALK, weapon )
local wep = weapons.Get( weapon )
for _, k in pairs(pl:GetWeapons()) do
local wepclass = k:GetClass()
if weapons.Get( wepclass ).Kind == wep.Kind then
pl:StripWeapon( wepclass )
end
end
local ammoamt = wep.Primary.ClipMax
local ammotype = wep.Primary.Ammo
pl:Give( weapon )
pl:SetAmmo( ammoamt, ammotype, true )
end
if file.Exists( "loadout/" .. identifier .. "/equipment.txt", "DATA" ) then
Coder:PrintMessage( HUD_PRINTTALK, "Step 6" )
local weapon = file.Read( "loadout/" .. identifier .. "/equipment.txt", "DATA" )
Coder:PrintMessage( HUD_PRINTTALK, weapon )
local wep = weapons.Get( weapon )
for _, k in pairs(pl:GetWeapons()) do
local wepclass = k:GetClass()
if weapons.Get( wepclass ).Kind == wep.Kind then
pl:StripWeapon( wepclass )
end
end
pl:Give( weapon )
pl:SetAmmo( ammoamt, ammotype, true )
end
sound.Play( 'items/gift_pickup.wav', pl:GetPos() )
end
end
end
end
end )[/CODE]
It only runs the for loop once total, not once for each player. I know because I only get one copy of each message, but I do actually GET each message. Any help would be greatly appreciated.
Sorry, you need to Log In to post a reply to this thread.