Jump to content

gui button

John Smith

Recommended Posts

tried doing that,successfully made a button,but i got few problems.

client side

button = guiCreateButton( 0.45, 0.5, 0.1, 0.1, "Spawn!", true ) 
function testFunction () 
addEventHandler ( "onClientPlayerJoin", button, testFunction ) 
function otherTestFunction() 

server side(1 part of script file)

function buttonSumoSpawn() 
function otherSumoFunction() 
spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) )--loading it from a table(other part of code) 
setCameraTarget ( source, source )  

When i come ingame,i see a button which says "Spawn!" but i dont see cursor,and when i get cursor with F8 key,it doesnt do anything when i click the button.

please help me

Link to comment

-- client side:

button = guiCreateButton( 0.45, 0.5, 0.1, 0.1, "Spawn!", true ) 
fadeCamera ( false ) 
showCursor ( true ) 
function otherTestFunction ( ) 
    triggerServerEvent ( "spawnButtonSumoPlayer",true ) 
    showCursor ( false ) 
addEventHandler ( "onClientGUIClick", button, otherTestFunction, false ) 

-- server side:

function otherSumoFunction ( ) 
    spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) 
    setCameraTarget ( source, source ) 
    fadeCamera ( source, true ) 
addEvent ( "spawnButtonSumoPlayer", true ) 
addEventHandler ( "spawnButtonSumoPlayer",root,otherSumoFunction ) 

Problems I found:

1º The event "onClientPlayerJoin" is only triggered by remote players, you should use "onClientResourceStart" instead.

2º showCursor has no player argument when used client side.

3º If you use "false" in fadeCamera, it'll fade the camera out, meaning you won't be able to see.

Link to comment

error was bad argument triggerServerEvent instead of element it got boolean(true)

you've put this line in script which confused me as soon as i saw your script but i've trusted u so i didn't change the line

triggerServerEvent ( "spawnButtonSumoPlayer",true ) 

but it should be

triggerServerEvent ( "spawnButtonSumoPlayer",localPlayer ) 

anyway,you've fixed my other problems so,thank you very much!

1 more question.

could you please tell me whats wrong in here?

im trying to warp player into vehicle when he spawns

warpPedIntoVehicle ( source, vehicle ) 

vehicle is defined in here

local vehicle = createVehicle ( model, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) 

error is this

[01:26:20] WARNING: [gamemodes]\[sumo]\sumo\load_map\spawn_s.lua:47: Bad argument @ 'warpPedIntoVehicle'
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...