• How to exclude give of 1 player
    9 replies, posted
How to exclude give of 1 player? If the code: [lua] local noobs = table.Copy(players) table.RemoveByValue(noobs, error) local weapon1 = table.Random(noobs) if IsValid(weapon1) then weapon1:Give("weapon_1") end local noobs = table.Copy(players) table.RemoveByValue(noobs, murderer) local weapon2 = table.Random(noobs) if ( team.NumPlayers( 2 ) >= 2 ) then if IsValid(weapon2) then weapon2:Give("weapon_2") end end local weapon3 = table.Random(noobs) if ( team.NumPlayers( 2 ) >= 3 ) then if IsValid(weapon3) then spy:Give("weapon_3") end end [/lua]
What?
If you don't want to give a weapon to one specific player you could check for his SteamID I guess. What you're asking doesn't make too much sense.
Is it not possible 1 player did not give?
[QUOTE=giraff;48886873]Is it not possible 1 player did not give?[/QUOTE] It might be possible. We can not understand you. Sorry.
Here is a shot in the dark: [code] -- So first it looks like we want to get all players local playerList = players.GetAll() -- We will remove a player from the list who is known as a error, otherwise find someone's Steam ID table.RemoveByValue( playerList, IsValid( error ) and error or player.GetBySteamID( "STEAM_0:0:1" ) ) -- After removing the player we're going to give a random player a weapon local randomPlayer1 = table.Random( playerList ) -- Make sure the random player we selected is valid, they should be, then give them a weapon if IsValid( randomPlayer1 ) then randomPlayer1:Give( "weapon_1" ) end -- Now we will refresh the list of players local playerList = players.GetAll() -- We will again remove a player from the list who is known as a murderer, otherwise lets go with a Steam ID again table.RemoveByValue( playerList, IsValid( murderer ) and murderer or player.GetBySteamID( "STEAM_0:0:1" ) ) -- After removing the player, we will check to see if team 2 has at least 2 players if team.NumPlayers( 2 ) >= 2 then -- If team 2 does have 2 or more players, select a random player from our list local randomPlayer2 = table.Random( playerList ) -- Make sure the random player we selected is valid, they should be, then give them a weapon if IsValid( randomPlayer2 ) then randomPlayer2:Give( "weapon_2" ) end end -- Finally we have our third weapon, but first we have to check if team 2 has more than 3 players if team.NumPlayers( 2 ) >= 3 then -- If team 2 does have 3 or more players, select a random player from our list without refreshing the player list local randomPlayer3 = table.Random( playerList ) -- Lets check to see if the player we just selected is valid, it should be if IsValid( randomPlayer3 ) then -- If 'spy' is valid lets give the weapon to the 'spy' entity if it exists, otherwise lets use our random player if IsValid( spy ) then -- The spy entity exists and is being given the weapon spy:Give( "weapon_3" ) else -- The spy entity doesn't exist and so we're giving the weapon to our random player randomPlayer3:Give( "weapon_3" ) end end end [/code]
I already told you to look at the [URL="https://facepunch.com/showthread.php?t=1460926"]Translators [/URL]thread. We can't understand what you're saying ._.
[CODE]local faggots = { "STEAM_1337" } for _, ply in pairs(player.GetAll()) do if table.HasValue( faggots, v:SteamID() ) then continue end -- skip blacklisted players print("wew") end[/CODE]
[QUOTE=legendofrobbo;48899434][CODE]local faggots = { "STEAM_1337" } for _, ply in pairs(player.GetAll()) do if table.HasValue( faggots, v:SteamID() ) then continue end -- skip blacklisted players print("wew") end[/CODE][/QUOTE] You forgot the STEAM_0:X:
[QUOTE=SexyBeast70;48900380]You forgot the STEAM_0:X:[/QUOTE] ok
Sorry, you need to Log In to post a reply to this thread.