Sign in to follow this  
Suerte

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

Recommended Posts

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

Share this post


Link to post

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 ) 

Share this post


Link to post
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

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.