Lordkrypton Posted September 5, 2015 Posted September 5, 2015 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 )
Dealman Posted September 5, 2015 Posted September 5, 2015 Use triggerServerEvent, read the information and examples thoroughly and it's rather easy to understand. Simply put, you have a server-side function which is remotely triggered by a client. You use addEvent to create a custom event for that function, then trigger that event via triggerServerEvent. Same logic applies for triggerClientEvent.
Lordkrypton Posted September 6, 2015 Author Posted September 6, 2015 Thank you 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
JR10 Posted September 6, 2015 Posted September 6, 2015 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 )
Lordkrypton Posted September 6, 2015 Author Posted September 6, 2015 Thank you but, i mean, how to link the ped who click in client-side to server-side, i know i can add arguments to triggerServerEvent but wich one ? Excuse my bad english Thnak you
Addlibs Posted September 6, 2015 Posted September 6, 2015 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now