Jump to content

[Help] Learning to Script GUI panels


Wisam

Recommended Posts

Hi there...

So a while ago i decided to start learning to script and everything is going well i learned fast.. i can make server side scripts, i know almost all the functions and events, i made small, simple working scripts but im bored of doing little boring server side script and i wanted to learn to make client+server side scripts and gui stuff.. What i want to learn is How to connect server side functions to a gui so the buttons and other stuff in it will work, im good with building gui panels its really easy with "Gui Editor" , but what i don't know is how to connect the server side functions to the buttons, gridlists..etc as i said before. so if you know anything could help me like an example for a simple small script or a tutorial please post here.

I wanna give you an example for what i mean so you understand me:

I made a small gui panel with the buttons "Kill Me" , "Freeze Me and "Close" , so i want to connect the server side functions to the buttons like: killPlayer , setElementFrozen , guiSetVisible .

Link to comment

Hello ,

these are the functions and events you need :

  
onClientGUIClick 
triggerServerEvent 
killPed 
setElementFrozen 
guiSetVisible 
  

this is a simple example:

  
--client side 
window = guiCreateWindow ( 0.3, 0.3, 0.5, 0.4, "window", true )  
closebutton = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "close", true,window ) 
freezebutton = guiCreateButton( 0.2, 0.1, 0.2, 0.1, "freeze", true,window ) 
killbutton = guiCreateButton( 0.2, 0.5, 0.2, 0.1, "kill", true,window ) 
  
addEventHandler("onClientGUIClick",root, 
function () 
if source == closebutton then 
guiSetVisible(window,false) 
elseif source == freezebutton then 
setElementFrozen ( localPlayer, true ) 
elseif source == killbutton then 
triggerServerEvent("killplayer",localPlayer,localPlayer) 
end 
end) 
  
--server side 
  
function killplayer(thePlayer) 
  
killPed(thePlayer,thePlayer) 
  
end 
addEvent("killplayer",true) 
addEventHandler("killplayer",root,killplayer) 
  

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