Jump to content

triggerClientEvent


Dannz0r

Recommended Posts

So I have this Roleplay script I started to make from scratch and I have a panel where you press on a 'Team' and when you press select button it sends you to that team, but there is a small problem, if you don't choose a team and just press the button then it just closes the window and your ped is in the same place and not in any team, so I tried to fix it by doing this

Client-side

  
function stupidBUG() 
    guiSetVisible(JobsWin, true) 
    showCursor(true) 
    outputChatBox ( "RP: Select a team!", player, 255, 0, 0 ) 
end 
addEvent( "blahBlahBlah", true ) 
addEventHandler( "blahBlahBlah", getRootElement(), stupidBUG ) 

Server-side

addEvent ( "onPlayerChooseTeam" , true ) 
addEventHandler ( "onPlayerChooseTeam" , root , 
function ( teamName ) 
local playerTeam = getPlayerTeam ( source )  -- Check if the player is on a team 
if playerTeam then                         -- this player is on a team, so we can remove them from it 
local oldTeamName = getTeamName ( playerTeam ) 
else 
triggerClientEvent ( player, "blahBlahBlah", getRootElement() ) 
end 
end) 

But now the problem is, it will give me error on line 8 (server-side) that string is needed, got a nil, but if I remove 'player' it works but then it triggers the event to the whole server not just that 1 player. how can I fix it?

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