Jump to content

Client side & server side


Lordkrypton

Recommended Posts

Hi,

This is the first time i create a script with both server side & client side.

It's like a vip panel, and only players for are vip ( meaning are friendly ) can open it.

I don't understand how to make the jetpack button call a function in the server side ( givePedJetPack ).

Can someone help me ?

Thank you

window = guiCreateWindow(0.25,0.25,0.1,0.5,"Vip Panel",true) 
guiSetAlpha( window, 1 ) 
guiWindowSetMovable(window,true) 
guiWindowSetSizable(window,false) 
guiSetVisible(window,false) 
showCursor(false) 
  
button = guiCreateButton( 0.05, 0.1, 1, 0.1, "Jetpack", true, window ) 
button = guiCreateButton( 0.05, 0.3, 1, 0.1, "blablabla", true, window ) 
  
--Binding to set window visible 
bindKey('k','down', 
function() 
guiSetVisible(window, not guiGetVisible(window)) 
showCursor(not isCursorShowing()) 
end 
) 

Link to comment

Thank you :D

But i don't understand how to use the button.

Look at what i did.

Client :

window = guiCreateWindow(0.25,0.25,0.1,0.5,"Vip Panel",true) 
guiSetAlpha( window, 1 ) 
guiWindowSetMovable(window,true) 
guiWindowSetSizable(window,false) 
guiSetVisible(window,false) 
showCursor(false) 
  
  
buttonjet = guiCreateButton( 0.05, 0.1, 1, 0.1, "Jetpack", true, window ) 
addEventHandler ( "onClientGUIClick", buttonjet, givejetpack, false ) 
  
  
function givejetpack () 
triggerServerEvent ( "onGiveJet", resourceRoot ) 
end 
  
--Binding to set window visible 
bindKey('k','down', 
function() 
guiSetVisible(window, not guiGetVisible(window)) 
showCursor(not isCursorShowing()) 
end 
) 

server :

function putjet() 
    outputChatBox ( "test") 
end 
addEvent( "onGiveJet", true ) 
addEventHandler( "onGiveJet", resourceRoot, putjet ) 

Help me to link the button to the event putjet on server-side :)

Thank you

Link to comment

addEventHandler is called before giveJetpack is even declared.

buttonjet = guiCreateButton( 0.05, 0.1, 1, 0.1, "Jetpack", true, window )  
  
function givejetpack () 
triggerServerEvent ( "onGiveJet", resourceRoot ) 
end 
addEventHandler ( "onClientGUIClick", buttonjet, givejetpack, false ) 
  

Link to comment

Give the jetpack to client, it is the variable representing the game client that called the request/event. However, using some cheats, people might be able to fraudulently call this event despite the fact they're not actually VIP, so you should further check if the request originated from a VIP player.

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