Jump to content

[Help]OnPlayerTeamChange ???


Recommended Posts

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

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
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

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

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

-- 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

i just copied your code exactly, and nothing :S

    _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
  • Moderators
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...