Jump to content

What is wrong with my script?


mcer

Recommended Posts

The idea of ​​the script is to create a button, which when you click it to close the window and the user appear on the map.

The only thing I fails here is the spawn.

ClientSide

addEventHandler ("onClientGUIClick", getRootElement(), 
function () 
if ( source ==  MilitaryB ) then 
guiSetVisible ( TeaSelectorWin,false) 
showCursor (false) 
triggerEvent ( "MilitarySpawnEvent", getRootElement(), "test" ) 
end 
end 
) 

ServerSide

addEvent ( "MilitarySpawnEvent", true ) 
function MilitarySpawn(source) 
    if source then 
    thePlayer = source 
else 
    thePlayer = player 
end 
    spawnPlayer( thePlayer, 2314.75+math.random(-1,1), -6.43+math.random(-1,1), 26.74, 180, 285, 0, 0, Military) 
    fadeCamera( thePlayer, true) 
    setCameraTarget( thePlayer, source) 
end 
addEventHandler ( "MilitarySpawnEvent", getRootElement(), MilitarySpawn ) 
addCommandHandler("asd",MilitarySpawn) 

Link to comment
function MilitarySpawn( ) 
    local thePlayer = source 
    spawnPlayer( thePlayer, 2314.75+math.random(-1,1), -6.43+math.random(-1,1), 26.74, 180, 285, 0, 0, Military) 
    fadeCamera( thePlayer, true) 
    setCameraTarget( thePlayer, source) 
end 

Link to comment
function MilitarySpawn( ) 
    local thePlayer = source 
    spawnPlayer( thePlayer, 2314.75+math.random(-1,1), -6.43+math.random(-1,1), 26.74, 180, 285, 0, 0, Military) 
    fadeCamera( thePlayer, true) 
    setCameraTarget( thePlayer, source) 
end 

The spawn don't have any problems, What I would like to know is how to turn this function on clientside.

Thanks fot that too! :D

Link to comment

SOLVED!!! Thanks a lot. :D:D

Replace this
triggerEvent ( "MilitarySpawnEvent", getRootElement(), "test" ) 

with this:

triggerServerEvent ( "MilitarySpawnEvent", getLocalPlayer() ) 

function MilitarySpawn( ) 
    local thePlayer = source 
    spawnPlayer( thePlayer, 2314.75+math.random(-1,1), -6.43+math.random(-1,1), 26.74, 180, 285, 0, 0, Military) 
    fadeCamera( thePlayer, true) 
    setCameraTarget( thePlayer, source) 
end 

The spawn don't have any problems, What I would like to know is how to turn this function on clientside.

Thanks fot that too!

Link to comment

Its server side, obviously...

Idk how to put a trigger in Clientside, Please help me.
bool triggerClientEvent ( [element sendTo=getRootElement()], string name, element theElement, [arguments...] ) 

Example:

triggerClientEvent ( root, "theClientSideEvent", root ) 

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