Castillo Posted February 22, 2013 Posted February 22, 2013 You forgot to pass the player argument here: beachturfTimer = setTimer ( function ( player ) setRadarAreaColor ( beachTurfA, tonumber(r), tonumber(g), tonumber(b), 100 ) exports ["guimessages"] : outputServer ( player, "Congratulations,your gang take this turf!" , 255, 0, 0 ) givePlayerMoney ( player, 2000 ) setRadarAreaFlashing ( beachTurfA, false ) end ,10000, 1 ) Like this: ,10000, 1, player
TheIceman1 Posted February 22, 2013 Author Posted February 22, 2013 You forgot to pass the player argument here: beachturfTimer = setTimer ( function ( player ) setRadarAreaColor ( beachTurfA, tonumber(r), tonumber(g), tonumber(b), 100 ) exports ["guimessages"] : outputServer ( player, "Congratulations,your gang take this turf!" , 255, 0, 0 ) givePlayerMoney ( player, 2000 ) setRadarAreaFlashing ( beachTurfA, false ) end ,10000, 1 ) Like this: ,10000, 1, player Working,how to do that all players in the turf receive money and messages from my gang?
Castillo Posted February 22, 2013 Posted February 22, 2013 getElementColShape -- To obtain marker colshape. getElementsWithinColShape -- To obtain a table with player elements inside colshape.
TheIceman1 Posted February 22, 2013 Author Posted February 22, 2013 Is it good? function beachTurf ( player ) local playerGang = getElementData ( player, "gang" ) if ( playerGang ) then local beachTurfCplayers = getElementColShape( beachTurfC ) local players = getElementsWithinColShape ( beachTurfC, "player" ) local r, g, b = unpack ( exports [ "gang_system" ]:getGangColor ( playerGang ) ) setRadarAreaFlashing ( beachTurfA, true ) exports ["guimessages"] : outputServer ( player, "You entered the turf!" , 255, 0, 0 ) beachturfTimer = setTimer ( function ( player ) setRadarAreaColor ( beachTurfA, tonumber(r), tonumber(g), tonumber(b), 100 ) exports ["guimessages"] : outputServer ( players, "Congratulations,your gang take this turf!" , 255, 0, 0 ) givePlayerMoney ( players, 2000 ) setRadarAreaFlashing ( beachTurfA, false ) end ,10000, 1, player ) end end addEventHandler ( "onColShapeHit", beachTurfC, beachTurf )
Castillo Posted February 22, 2013 Posted February 22, 2013 No, "players" is a table of elements, you must loop it.
TheIceman1 Posted February 23, 2013 Author Posted February 23, 2013 How to do that, only players from my gang get the message and the money? if isElementWithinColShape( player, beachTurfC ) then exports ["guimessages"] : outputServer ( player, "Congratulations,your gang take this turf!" , 255, 0, 0 ) givePlayerMoney ( player, 2000 )
Castillo Posted February 23, 2013 Posted February 23, 2013 function beachTurf ( player ) local playerGang = getElementData ( player, "gang" ) if ( playerGang ) then if ( isTimer ( beachturfTimer ) ) then return end local r, g, b = unpack ( exports [ "gang_system" ]:getGangColor ( playerGang ) ) setRadarAreaFlashing ( beachTurfA, true ) exports ["guimessages"] : outputServer ( player, "You entered the turf!" , 255, 0, 0 ) beachturfTimer = setTimer ( function ( ) local beachTurfCplayers = getElementColShape ( beachTurfC ) local players = getElementsWithinColShape ( beachTurfC, "player" ) setRadarAreaColor ( beachTurfA, tonumber(r), tonumber(g), tonumber(b), 100 ) for _, player in ipairs ( players ) do exports ["guimessages"] : outputServer ( player, "Congratulations, your gang take this turf!" , 255, 0, 0 ) givePlayerMoney ( player, 2000 ) end setRadarAreaFlashing ( beachTurfA, false ) end ,10000, 1 ) end end addEventHandler ( "onColShapeHit", beachTurfC, beachTurf )
TheIceman1 Posted February 23, 2013 Author Posted February 23, 2013 function beachTurf ( player ) local playerGang = getElementData ( player, "gang" ) if ( playerGang ) then if ( isTimer ( beachturfTimer ) ) then return end local r, g, b = unpack ( exports [ "gang_system" ]:getGangColor ( playerGang ) ) setRadarAreaFlashing ( beachTurfA, true ) exports ["guimessages"] : outputServer ( player, "You entered the turf!" , 255, 0, 0 ) beachturfTimer = setTimer ( function ( ) local beachTurfCplayers = getElementColShape ( beachTurfC ) local players = getElementsWithinColShape ( beachTurfC, "player" ) setRadarAreaColor ( beachTurfA, tonumber(r), tonumber(g), tonumber(b), 100 ) for _, player in ipairs ( players ) do exports ["guimessages"] : outputServer ( player, "Congratulations, your gang take this turf!" , 255, 0, 0 ) givePlayerMoney ( player, 2000 ) end setRadarAreaFlashing ( beachTurfA, false ) end ,10000, 1 ) end end addEventHandler ( "onColShapeHit", beachTurfC, beachTurf ) Working,thanks!
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