Bean666 Posted February 10, 2021 Share Posted February 10, 2021 hi, how do i do if it detects the colshape has less than 2 people, it will output a message for everyone? because if i put the output after that line it just does it to people inside the colshape(I know that) so how do i make the outputChatBox visible for everyone? not just people inside the colshape. local players = getElementsWithinColShape ( rc, "player" ) for _, thePlayer in ipairs( players ) do if #players < 2 then --?? outputChatBox("test", --??) end Link to comment
SpecT Posted February 10, 2021 Share Posted February 10, 2021 (edited) For the players within colshape: outputChatBox("text", thePlayer) For everyone (but OUTSIDE the loop): outputChatBox("text for everyone", root) Edited February 10, 2021 by SpecT Link to comment
Bean666 Posted February 10, 2021 Author Share Posted February 10, 2021 (edited) 20 minutes ago, SpecT said: For the players withing colshape: outputChatBox("text", thePlayer) For everyone (but OUTSIDE the loop): outputChatBox("text for everyone", root) already did this, thePlayer works but only if player inside in the colshape(Obviously), then for root, it doesn't really output anything, despite me being outside the colshape. and how do i put the outputChatBox outside the loop that detects if there are less than 2 people?, if i put it outside the loop then it wont recognize if theres less than 2 people in the colshape? EDIT: nvm lol, solved, im so slow hahaha! thankyou, and btw last, how do i add two teams to detect here, like besides team1, team2 can see the message too. how do i add another team, do i create another loop for that? for k, v in ipairs(getPlayersInTeam(getTeamFromName ("team1"))) do outputChatBox("Test.", root, 255, 255, 255, true) end and also, how do i make the getElementsWithinColShape detect if the player is in a certain team? like it won't detect people inside the colshape that's not in the "team1", help would be appreciated. local players = getElementsWithinColShape ( rc, "player" ) if #players < 1 then Edited February 10, 2021 by Shaman123 Link to comment
Bean666 Posted February 10, 2021 Author Share Posted February 10, 2021 (edited) nvm about question #1, just added "and" and it worked, can't edit the reply anymore so sorry for the "spam", i guess, move forward to question 2. thanks! 43 minutes ago, Shaman123 said: how do i add two teams to detect here, like besides team1, team2 can see the message too. how do i add another team, do i create another loop for that? for k, v in ipairs(getPlayersInTeam(getTeamFromName ("team1"))) do outputChatBox("Test.", root, 255, 255, 255, true) end and also, how do i make the getElementsWithinColShape detect if the player is in a certain team? like it won't detect people inside the colshape that's not in the "team1", help would be appreciated. local players = getElementsWithinColShape ( rc, "player" ) if #players < 1 then EDIT: i have problem in question 1 again now for k, v in ipairs(getPlayersInTeam(getTeamFromName ("team1") and getTeamFromName("team2"))) do outputChatBox("works", v, 255, 255, 255, true) end the outputChatBox only works for team2, not team1. guess i'll need to create 2 loops instead? Edited February 10, 2021 by Shaman123 Link to comment
Furzy Posted February 10, 2021 Share Posted February 10, 2021 (edited) 50 minutes ago, Shaman123 said: nvm about question #1, just added "and" and it worked, can't edit the reply anymore so sorry for the "spam", i guess, move forward to question 2. thanks! EDIT: i have problem in question 1 again now for k, v in ipairs(getPlayersInTeam(getTeamFromName ("team1") and getTeamFromName("team2"))) do outputChatBox("works", v, 255, 255, 255, true) end the outputChatBox only works for team2, not team1. guess i'll need to create 2 loops instead? try to make a table put the teams and then make a loop Edited February 10, 2021 by Furzy Link to comment
Bean666 Posted February 10, 2021 Author Share Posted February 10, 2021 (edited) 1 hour ago, Furzy said: try to make a table put the teams and then make a loop local testteams = { {"team1"}, {"team2"} } for k, v in ipairs(getPlayersInTeam(getTeamFromName(testteams[1]))) do setElementVisibleTo (rcblip, v, true) setElementVisibleTo(arearadar, v, true) outputChatBox("test", v, 255, 255, 255, true) end I tried getting teamnames using table but i'm having error: getTeamFromName[Expected string at arg 1, got table] getPlayersInTeam(Expected team at arg 1, got boolean) bad arg#1 to ipairs table expected got boolean. EDIT: Nvm i fixed it, i used this, but im not sure if it's clean? it seems to be working fine for i, c in ipairs(testteams) do for k, v in ipairs(getPlayersInTeam(getTeamFromName((c)[1]))) do setElementVisibleTo (rcblip, v, true) setElementVisibleTo(arearadar, v, true) outputChatBox("#54F764[Rescue] #FFFFFFSome civilians have requested for help, go to the red cross location to help them", v, 255, 255, 255, true) end end Edited February 10, 2021 by Shaman123 Link to comment
Furzy Posted February 10, 2021 Share Posted February 10, 2021 26 minutes ago, Shaman123 said: local testteams = { {"team1"}, {"team2"} } for k, v in ipairs(getPlayersInTeam(getTeamFromName(testteams[1]))) do setElementVisibleTo (rcblip, v, true) setElementVisibleTo(arearadar, v, true) outputChatBox("test", v, 255, 255, 255, true) end I tried getting teamnames using table but i'm having error: getTeamFromName[Expected string at arg 1, got table] getPlayersInTeam(Expected team at arg 1, got boolean) bad arg#1 to ipairs table expected got boolean. EDIT: Nvm i fixed it, i used this, but im not sure if it's clean? it seems to be working fine for i, c in ipairs(testteams) do for k, v in ipairs(getPlayersInTeam(getTeamFromName((c)[1]))) do setElementVisibleTo (rcblip, v, true) setElementVisibleTo(arearadar, v, true) outputChatBox("#54F764[Rescue] #FFFFFFSome civilians have requested for help, go to the red cross location to help them", v, 255, 255, 255, true) end end If the loop is not executing all time its ok Link to comment
Bean666 Posted February 10, 2021 Author Share Posted February 10, 2021 (edited) thank you and yes its not, its like every 10-20 minutes so i guess i'll be fine? and can the function getElementWithinColShape be set to a team? like the function won't detect a player in a colshape if he's not in "team1" or something like that. EX: local players = getElementsWithinColShape ( rc, "player" ) if #players < 1 then Ex: if player is in colshape but not in team "team1", he wont be counted as a number of players inside the colshape. Edited February 10, 2021 by Shaman123 Link to comment
Furzy Posted February 10, 2021 Share Posted February 10, 2021 (edited) 12 minutes ago, Shaman123 said: thank you and yes its not, its like every 10-20 minutes so i guess i'll be fine? and can the function getElementWithinColShape be set to a team? like the function won't detect a player in a colshape if he's not in "team1" or something like that. EX: local players = getElementsWithinColShape ( rc, "player" ) if #players < 1 then Ex: if player is in colshape but not in team "team1", he wont be counted as a number of players inside the colshape. if ( players and getTeamName ( players ) == "Team1" ) then You can try it but '''if player is in colshape but not in team "team1", he wont be counted as a number of players inside the colshape.'' idk if its possible, only if you create a table and insert just the players that are in team inside table and then get the players. Edited February 10, 2021 by Furzy 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