Sande Posted April 1, 2013 Share Posted April 1, 2013 Hey, i try to make payday for only team. How i can code the message only for the team, can someode code it? if there are something wrong please fix it thaanks Im new in scripting. - Sande ----Sande function teamPayday() local allPlayers = getElementsByType("player") for index,value in ipairs(allPlayers) do if getTeamName(getPlayerTeam(value)) == "Police" then givePlayerMoney ( value, 2000 ) end outputChatBox (" ------Police-bonus------ ", value, 255, 255, 255, false) outputChatBox ("|--------------------------|", value, 0, 100, 180, false) outputChatBox ("+2000$", value, 0, 255, 0, false) outputChatBox ("|--------------------------|", value, 0, 100, 180, false) end end function onResourceStart(thisResource) setTimer ( teamPayday, 990000, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) Link to comment
ALE34 Posted April 1, 2013 Share Posted April 1, 2013 function teamPayday( src) local allPlayers = getElementsByType("player") for index,value in ipairs(allPlayers) do if getTeamName(getPlayerTeam(value)) == "Police" then givePlayerMoney ( value, 2000 ) end outputChatBox (" ------Police-bonus------ ", value, src, 255, 255, 255, false) outputChatBox ("|--------------------------|", value, src, 0, 100, 180, false) outputChatBox ("+2000$", value, src, 0, 255, 0, false) outputChatBox ("|--------------------------|", value, src, 0, 100, 180, false) end end function onResourceStart(thisResource) setTimer ( teamPayday, 990000, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) Try this one Link to comment
Sande Posted April 1, 2013 Author Share Posted April 1, 2013 This is works, but the message shows everyone, i wanna it for team, if team Police, then this message show only police. function teamPayday( src) local allPlayers = getElementsByType("player") for index,value in ipairs(allPlayers) do if getTeamName(getPlayerTeam(value)) == "Police" then givePlayerMoney ( value, 2000 ) end outputChatBox (" ------Police-bonus------ ", value, src, 255, 255, 255, false) outputChatBox ("|--------------------------|", value, src, 0, 100, 180, false) outputChatBox ("+2000$", value, src, 0, 255, 0, false) outputChatBox ("|--------------------------|", value, src, 0, 100, 180, false) end end function onResourceStart(thisResource) setTimer ( teamPayday, 990000, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) Link to comment
manve1 Posted April 1, 2013 Share Posted April 1, 2013 thats because your using "value" argument which in "for" function gets every single player Link to comment
Vision Posted April 1, 2013 Share Posted April 1, 2013 Try this function teamPayday ( ) for _, players in ipairs ( getPlayersInTeam ( getTeamFromName ( "Police" ) ) ) do if ( players ) then givePlayerMoney ( players, 2000 ) outputChatBox (" ------Police-bonus------ ", players, 255, 255, 255, false) outputChatBox ("|--------------------------|", players, 0, 100, 180, false) outputChatBox ("+2000$", players, 0, 255, 0, false) outputChatBox ("|--------------------------|", players, 0, 100, 180, false) end end end function onResourceStart(thisResource) setTimer ( teamPayday, 990000, 0 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) 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