Jump to content
  • 0

client to server spawnPlayer - bad 'player' pointer. (easy)


Suerte

Question

Posted

CLIENT:

 --gui button leads to 
 triggerServerEvent ( "onChooseSpawn", getRootElement(), 105 )  

SERVER:

addEvent( "onChooseSpawn", true ) 
function spawnHandler ( skinID ) 
    setCameraTarget ( getRootElement() ) 
    fadeCamera(getRootElement(), true ) 
    spawnPlayer(getRootElement(), 2495, -1685, 14) 
end 
addEventHandler( "onChooseSpawn", getRootElement(), spawnHandler ) 

The event is triggered and the function starts. This part works.

The command spawnPlayer(getRootElement(), 2495, -1685, 14) does not work however giveWeapon( getRootElement(), 34, 1000 ) does work?

Note: I used "onPlayerJoin" and "onPlayerDeath" and spawnPlayer(source, 2495, -1685, 14), and that works. But I need it to work with the GUI :)

2 answers to this question

Recommended Posts

  • 0
Posted

This should be moved to the Scripting section

Anyway, you should use the source of the event to pass on the player element, and then you can use it to spawn him.

--gui button leads to 
 triggerServerEvent ( "onChooseSpawn", getLocalPlayer(), 105 )  --set "source" to local player element  

addEvent( "onChooseSpawn", true ) 
function spawnHandler ( skinID ) 
    local player = source 
    setCameraTarget ( player ) 
    fadeCamera ( player, true ) 
    spawnPlayer ( player, 2495, -1685, 14, 0, skinID) 
end 
addEventHandler( "onChooseSpawn", getRootElement(), spawnHandler ) 

  • 0
Posted
This should be moved to the Scripting section

Anyway, you should use the source of the event to pass on the player element, and then you can use it to spawn him.

Yes, you are right. I was about to request it moved.

Also, thank you very much!!!!!! :D

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