Jump to content

[HELP] getAlivePlayers


GrubaS

Recommended Posts

Hello, i have problem with getAlivePlayers because if someone come join the server it's not adding the point. it's code.

 

function autopts()
local pTeam = getPlayerTeam(source)
aPs = #getAlivePlayersInTeam(pTeam) or 0
if not (#getAlivePlayers() == 0) then
if not ( getTeamName(getPlayerTeam(source)) == "Spectators" ) then
if aPs == 0 then
if pTeam == homeTeam then
visitPoints = visitPoints + 1
outputChatBox(hexColorVisit .. visitName .."#FFFFFF won the round! "..hexColorVisit..visitPoints.."#ffffff : "..hexColorHome..homePoints, root, 255,255,255, true)
elseif pTeam == visitTeam then
homePoints = homePoints + 1
outputChatBox(hexColorHome .. homeName .."#FFFFFF won the round! "..hexColorHome..homePoints.."#ffffff : "..hexColorVisit..visitPoints, root,255,255,255, true)
end
 triggerClientEvent("sync:points", root, homePoints, visitPoints)
 
 setTimer(playSoundFrontEnd, 1000, 1,root, 16 )
if not matchEnded then setTimer(nextMap, 2000, 1, playedRounds or nil) 
outputDebugString("redo_Map(CWS)", 3)
else
outputDebugString("didn't_redo_Map(CWS)", 1)
end
end
end
end
end
addEvent("onPlayerRaceWasted",true)
addEventHandler("onPlayerRaceWasted",root,autopts)






function getAlivePlayersInTeam(theTeam)
    local theTable = { }
    local players = getPlayersInTeam(theTeam)

    for i,v in pairs(players) do
        if not isPedDead(v) then
            theTable[#theTable+1]=v
        end
    end

    return theTable
end

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...