Jump to content

Making it work for only one player..


Xeno

Recommended Posts

I made a script that changes the players skin on GUI Click and it triggers a serverSided event.... For some reason it works for everyone, I have tried changing the Element bit to "player" "thePlayer" "source" and it still doesnt work...

Here is the code:

  
function activateTheBomb() 
triggerServerEvent("bomb", getLocalPlayer()) 
end 
  

function bomb(source) 
fadeCamera(source, true) 
spawnPlayer(source, 0,0,5) 
setCameraTarget(source) 
setElementModel(source, 1) 
  
end 
addEvent("bomb", true) 
addEventHandler("bomb", getRootElement(), bomb) 

Link to comment

I cant really show the hole Client, its quite big... But ill give you select parts that involve this code...

  
  
function evenTeams(thePlayer) 
    local ali = getTeamFromName ( "" ) 
   pred = getTeamFromName ( "" ) 
    local aliCount = countPlayersInTeam ( ali ) 
    local predCount = countPlayersInTeam ( pred ) 
  
    if aliCount == predCount then 
   
setPlayerTeam (source, pred) 
triggerClientEvent("onSpawn2", getRootElement()) 
--outputChatBox("Debug test2" , 255,0,0) 
  elseif predCount > aliCount then 
triggerClientEvent("evenTeamsMessage2", getRootElement()) 
  elseif predCount < aliCount then 
 setPlayerTeam (source, pred) 
triggerClientEvent("onSpawn", getRootElement()) 
end 
end 
addEvent("evenTeams", true) 
addEventHandler("evenTeams", getRootElement(), evenPredTeams) 

  
function onSpawn2() 
guiSetVisible(ali, false) 
guiSetVisible(startImage, false) 
guiSetVisible(pred, false) 
guiSetVisible(label1, false) 
guiSetVisible(label2, false) 
guiSetVisible(label3, false) 
guiSetVisible(label4, false) 
guiSetVisible(label5, false) 
guiSetVisible(label6, false) 
showCursor(false)  
triggerServerEvent("spawnHerePlayer", getLocalPlayer()) 
end 
addEvent("onSpawn2", true) 
addEventHandler("onSpawn2", getRootElement(), onSpawn2) 

  
function spawnHerePlayer(source) 
fadeCamera(source, true) 
spawnPlayer(source, 0,0,5) 
setCameraTarget(source) 
setElementModel(source, 22) 
end 
addEvent("spawnHerePlayer", true) 
addEventHandler("spawnHerePlayer", getRootElement(), spawnHerePlayer) 

Its really confusing and hurts my head xP

Link to comment

So you trigger all in root http://wiki.multitheftauto.com/wiki/Element_tree

triggerClientEvent("onSpawn2", getRootElement()) 

replace with:

triggerClientEvent( thePlayer,"onSpawn2",thePlayer ) 

or

if thePlayer nil ( idk thePlayer is empty not used argument in your function i not see how you trigger event "evenTeams" and what is source in your event( player,ped or something ) )

triggerClientEvent( source,"onSpawn2",source ) 

and replace

  
function spawnHerePlayer(source) 
fadeCamera(source, true) 
spawnPlayer(source, 0,0,5) 
setCameraTarget(source) 
setElementModel(source, 22) 
end 
addEvent("spawnHerePlayer", true) 
addEventHandler("spawnHerePlayer", getRootElement(), spawnHerePlayer) 

with this

  
function spawnHerePlayer( ) 
    fadeCamera( source, true ) 
    spawnPlayer( source, 0,0,5 ) 
    setCameraTarget( source ) 
    setElementModel( source, 22 ) 
end 
addEvent( "spawnHerePlayer", true ) 
addEventHandler( "spawnHerePlayer",root, spawnHerePlayer ) 

if it not working show how you trigger event "evenTeams" or send me in pm your resource.

Edited by Guest
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...