Jump to content

[Help]OnPlayerTeamChange ???


Recommended Posts

Posted
Instead of
    setPlayerTeam ( source, getTeamFromName ( "Civilian" ) ) 

And chagnder resource_name to name of resource, where you got this event.

Error : trashman/trash_s.lua:20: exports : Call to non-running server resource (resource_name)

EDIT : And chagnder resource_name to name of resource, where you got this event. ( i dont understand what u mean )

Posted

I fixed it by adding

--Client

addEvent ( "destroyonleave", true ) 
function destroyonleave () 
destroyElement ( robhouseMarker ) 
destroyElement ( robhouseBlip ) 
end 
addEventHandler ( "destroyonleave", getRootElement (), destroyonleave ) 

--Server

_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 
         triggerClientEvent ( "destroyonleave", theNewTeam, theOldTeam, teamName ) 
        end 
    end 
) 

and thank you very much bro for telling me the exporting thingy :) Thanks :)

Posted
Oh, my bad, change to
type="server" 

i also tried this and nothing so i did like i posted in the previous reply, and also made the type="server" and now worked but i still dont know if it will destroy for only me or all players .. will test it when any friend join my server later.

Posted

Well, you have to change that

triggerClientEvent ( "destroyonleave", theNewTeam, theOldTeam, teamName ) 

to

triggerClientEvent ( source, "destroyonleave", root ) 

Posted
Well, you have to change that
triggerClientEvent ( "destroyonleave", theNewTeam, theOldTeam, teamName ) 

to

triggerClientEvent ( source, "destroyonleave", root ) 

it worked without this change .. can u explain what this change will edit please ?

and im really very sorry for wasting your time :(

Posted

Couse if you use this 1st trigger it will trigger this event for ALL player on server, but if you use 2nd one it will do event only for player, who changed team.

Posted
Couse if you use this 1st trigger it will trigger this event for ALL player on server, but if you use 2nd one it will do event only for player, who changed team.

Okay Thanks bro :), #Solved #LockRequest

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