Hell-Mate Posted March 2, 2014 Share Posted March 2, 2014 Hey community, i need someone's help. i tried to find any event for when a player change his team but i failed. i made a robber job which create some markers and blips and i want to destroyElement of this Markers and Blips on Player team change i need any Event that can help. Thanks function removeblips () local playerTeam = getPlayerTeam ( source ) if playerTeam ~= "Criminal" then destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) end end Which Event should i add ? Link to comment
WhoAmI Posted March 2, 2014 Share Posted March 2, 2014 I don't know if It works, but _setPlayerTeam = setPlayerTeam addEvent( "onPlayerChangeTeam", true ) function setPlayerTeam ( thePlayer, theTeam ) triggerEvent ( "onPlayerChangeTeam", root, thePlayer, theTeam ) return _setPlayerTeam ( thePlayer, theTeam ) end And then addEventHandler ( "onPlayerChangeTeam", root, function ( player, team ) outputChatBox ( getPlayerName ( player ) .. ": " .. getTeamName ( team ) ) end ) It should output message 'nick: team name'. Link to comment
Hell-Mate Posted March 2, 2014 Author Share Posted March 2, 2014 WhoAmI, do u understand what i mean ? i mean if a Player in Criminal Team and changed his Team to any other team for example like civilian, if so then destroyElement ( Element ) that what i mean. Link to comment
WhoAmI Posted March 2, 2014 Share Posted March 2, 2014 So use my event. addEventHandler ( "onPlayerChangeTeam", root, function ( player, team ) --here destroyElement end ) Link to comment
Hell-Mate Posted March 2, 2014 Author Share Posted March 2, 2014 So use my event. addEventHandler ( "onPlayerChangeTeam", root, function ( player, team ) --here destroyElement end ) well, what about the first code ? >> _setPlayerTeam = setPlayerTeam addEvent( "onPlayerChangeTeam", true ) function setPlayerTeam ( thePlayer, theTeam ) triggerEvent ( "onPlayerChangeTeam", root, thePlayer, theTeam ) return _setPlayerTeam ( thePlayer, theTeam ) end i really dont understand this setPlayerTeam thingy ?? Can u explain ? Link to comment
WhoAmI Posted March 2, 2014 Share Posted March 2, 2014 Well, the event 'onPlayerChangeTeam' will be active when you would use setPlayerTeam. Link to comment
Hell-Mate Posted March 2, 2014 Author Share Posted March 2, 2014 hmm so this will be how it looks ? addEventHandler ( "onPlayerChangeTeam", root, function ( player, team ) local playerTeam = getPlayerTeam ( source ) if playerTeam ~= "Criminal" then destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) end end) Link to comment
WhoAmI Posted March 2, 2014 Share Posted March 2, 2014 It will looks like this addEventHandler ( "onPlayerChangeTeam", root, function ( player, team ) local teamName = getTeamName ( team ) if teamName ~= "Criminal" then destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) end end ) Link to comment
Hell-Mate Posted March 2, 2014 Author Share Posted March 2, 2014 -- Tested but not working i just changed my team from admin panel to another team but Element not destroyed .. _setPlayerTeam = setPlayerTeam addEvent( "onPlayerChangeTeam", true ) function setPlayerTeam ( thePlayer, theTeam ) triggerEvent ( "onPlayerChangeTeam", root, thePlayer, theTeam ) return _setPlayerTeam ( thePlayer, theTeam ) end addEventHandler ( "onPlayerChangeTeam", root, function ( player, team ) local playerTeam = getTeamName ( team ) if playerTeam ~= "Criminal" then destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) end end) Link to comment
WhoAmI Posted March 2, 2014 Share Posted March 2, 2014 It will works, If you change team by using setPlayerTeam function. Link to comment
Hell-Mate Posted March 2, 2014 Author Share Posted March 2, 2014 i just copied your code exactly, and nothing _setPlayerTeam = setPlayerTeam addEvent( "onPlayerChangeTeam", true ) function setPlayerTeam ( thePlayer, theTeam ) triggerEvent ( "onPlayerChangeTeam", root, thePlayer, theTeam ) return _setPlayerTeam ( thePlayer, theTeam ) end addEventHandler ( "onPlayerChangeTeam", root, function ( player, team ) local teamName = getTeamName ( team ) if teamName ~= "Criminal" then destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) end end ) Link to comment
WhoAmI Posted March 2, 2014 Share Posted March 2, 2014 But read my post again. If you want it works, you must use setPlayerTeam function, not from admin panel!! Link to comment
Hell-Mate Posted March 2, 2014 Author Share Posted March 2, 2014 Same. i just have another job that have this > setPlayerTeam ( source, getTeamFromName ( "Civilian" ) ) i got the job and my team has been civilian and elements didn't destroy Link to comment
Moderators Citizen Posted March 2, 2014 Moderators Share Posted March 2, 2014 It will looks like this addEventHandler ( "onPlayerChangeTeam", root, function ( player, team ) local teamName = getTeamName ( team ) if teamName ~= "Criminal" then destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) end end ) No, more like this: (I modified a bit the setPlayerTeam from WhoAmI) _setPlayerTeam = setPlayerTeam addEvent( "onPlayerChangeTeam", true ) function setPlayerTeam ( thePlayer, theTeam ) if not thePlayer or not theTeam then return false end local oldTeam = getPlayerTeam( thePlayer ) triggerEvent ( "onPlayerChangeTeam", thePlayer, theTeam, oldTeam ) return _setPlayerTeam ( thePlayer, theTeam ) end addEventHandler ( "onPlayerChangeTeam", root, function ( theNewTeam, theOldTeam ) local teamName = getTeamName( theNewTeam ) if teamName ~= "Criminal" then destroyElement ( robhouseMarker ) destroyElement ( robhouseBlip ) end end ) Link to comment
Hell-Mate Posted March 2, 2014 Author Share Posted March 2, 2014 Tested and nothings Elements not getting destroyed Link to comment
WhoAmI Posted March 2, 2014 Share Posted March 2, 2014 How you are setting player team? Link to comment
Hell-Mate Posted March 2, 2014 Author Share Posted March 2, 2014 with another job, with this line >> setPlayerTeam ( source, getTeamFromName ( "Civilian" ) ) Link to comment
WhoAmI Posted March 2, 2014 Share Posted March 2, 2014 If it doesn't work try to export that function. Link to comment
Hell-Mate Posted March 2, 2014 Author Share Posted March 2, 2014 I have no idea about exporting Link to comment
WhoAmI Posted March 2, 2014 Share Posted March 2, 2014 exports.resource_name:setPlayerTeam( source, getTeamFromName ( "Civilian" ) ) Link to comment
Hell-Mate Posted March 2, 2014 Author Share Posted March 2, 2014 (edited) and remove the other lines that you wrote ? and the team is Criminal not Civilian .. Edited March 2, 2014 by Guest Link to comment
Hell-Mate Posted March 2, 2014 Author Share Posted March 2, 2014 then where should i add this line ? Link to comment
WhoAmI Posted March 2, 2014 Share Posted March 2, 2014 Instead of setPlayerTeam ( source, getTeamFromName ( "Civilian" ) ) And chagnder resource_name to name of resource, where you got this event. 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