.:HyPeX:. Posted February 13, 2014 Share Posted February 13, 2014 Guys, im stuck, totally. The idea of this podium is to get the current players still alive racing with getAlivePlayers. Yeah it works. Now the problem is: getAlivePlayers will include also joined and waiting players. So, if a player joins while the race, he's counted as an alive player, and the rank 1 is never reached. So, how can i fix this? i appreaciate any help script: function AutomaticSetPlayer() if get("AutomaticPodium") == "true" then local players = getAlivePlayers() local playerRank = #players if playerRank == 2 then outputChatBox("#00cc55Player "..getPlayerNametagText(source).." Finished third!", getRootElement(), 255,255,255,true) triggerClientEvent("PlayerPosWasted", getRootElement(), source, "3") elseif playerRank == 1 then outputChatBox("#00cc55Player "..getPlayerNametagText(source).." Finished second!", getRootElement(), 255,255,255,true) triggerClientEvent("PlayerPosWasted", getRootElement(), source, "2") elseif playerRank == 0 then outputChatBox("#00cc55Player "..getPlayerNametagText(source).." Finished First!", getRootElement(), 255,255,255,true) triggerClientEvent("PlayerPosWasted", getRootElement(), source, "1") else outputChatBox("#00cc55Player "..getPlayerNametagText(source).." Died!", getRootElement(), 255,255,255,true) end end end addEventHandler("onPlayerWasted", getRootElement(), AutomaticSetPlayer) Thanks in advance, HyPeX Link to comment
TrapLord Studios™ Posted February 13, 2014 Share Posted February 13, 2014 Try adding a new event or function for example : is:PlayerLoggedIn = 1 then Link to comment
Bonsai Posted February 13, 2014 Share Posted February 13, 2014 Write your own getAlivePlayers function, that checks for the "state" data and only includes players that got the state "alive". Link to comment
.:HyPeX:. Posted February 13, 2014 Author Share Posted February 13, 2014 Hmm i thought about creating a table on map start.. and only use that table..but then the problem is that i dont have how to calculate how many of them are dead.. EDIT: Should this work? DeadTable = {} function AutomaticSetPlayer() DeadTable[source] = source if get("AutomaticPodium") == "true" then local TotalPlayers = #PlayingTable local DeadPlayers = #DeadTable local playerRank = TotalPlayers - DeadPlayers if playerRank == 2 then outputChatBox("#00cc55Player "..getPlayerNametagText(source).." Finished third!", getRootElement(), 255,255,255,true) triggerClientEvent("PlayerPosWasted", getRootElement(), source, "3") elseif playerRank == 1 then outputChatBox("#00cc55Player "..getPlayerNametagText(source).." Finished second!", getRootElement(), 255,255,255,true) triggerClientEvent("PlayerPosWasted", getRootElement(), source, "2") elseif playerRank == 0 then outputChatBox("#00cc55Player "..getPlayerNametagText(source).." Finished First!", getRootElement(), 255,255,255,true) triggerClientEvent("PlayerPosWasted", getRootElement(), source, "1") else outputChatBox("#00cc55Player "..getPlayerNametagText(source).." Died!", getRootElement(), 255,255,255,true) end end end addEventHandler("onPlayerWasted", getRootElement(), AutomaticSetPlayer) function SetPlayerTable() PlayingTable = nil PlayingTable = {} for v,i in ipairs(getElementsByType("players")) do PlayingTable[v] = v DeadTable[v] = nil end end addEventHandler("onMapStarting", getRootElement(), SetPlayerTable) Link to comment
Bonsai Posted February 13, 2014 Share Posted February 13, 2014 function getAlivePlayers() local playerTable = {} for i, p in ipairs(getElementsByType("player")) do if getElementData(p, "state") == "alive" then table.insert(playerTable, p) end end return playerTable end Link to comment
.:HyPeX:. Posted February 13, 2014 Author Share Posted February 13, 2014 function getAlivePlayers() local playerTable = {} for i, p in ipairs(getElementsByType("player")) do if getElementData(p, "state") == "alive" then table.insert(playerTable, p) end end return playerTable end Im gonna test it, thanks! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now