Jump to content

Gui Choose Function


Bean666

Recommended Posts

hi , my gui , help please , i have server.lua ready but idk if i have some mistakes there but , is there anway if a player clicks choose button in my gui then it will do the functions in my server.lua , ik it's triggerserverevent , but i'm having problems with it.

Client.lua:

local marker = createMarker( 203.68948364258, 1913.0572509766, 17.640625, "Cylinder", 2, 6, 240, 226, 255) 
  
GUIEditor = { 
    button = {}, 
    window = {}, 
    memo = {} 
} 
        GUIEditor.window[1] = guiCreateWindow(428, 169, 485, 449, "Survivors", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1], false) 
        GUIEditor.button[1] = guiCreateButton(148, 307, 194, 57, "Choose", false, GUIEditor.window[1]) 
        GUIEditor.memo[1] = guiCreateMemo(9, 24, 466, 247, "Survivors.... Allied With Military , if you choose this side , you will be spawned to the Military & Survivors Base. and there is no going back. and as a survivor , you will need to survive and explore san andreas while killing zombies and surviving for better experience.", false, GUIEditor.window[1]) 
        guiMemoSetReadOnly(GUIEditor.memo[1], true)     
        GUIEditor.button[2] = guiCreateButton(150, 379, 192, 52, "Cancel", false, GUIEditor.window[1])     
  
addEventHandler("onClientMarkerHit", marker, function(player) 
         if (player == localPlayer) then 
             guiSetVisible(GUIEditor.window[1], true) 
             showCursor(true) 
         end 
 end) 

Server.lua:

function createSurvivorTeam () 
    SurvivorTeam = createTeam ("Survivors", 255, 200, 0) 
end 
addEventHandler ("onResourceStart", resourceRoot, createSurvivorTeam) 
  
function joinSurvivor() 
     setPlayerTeam(source,SurvivorTeam) 
    setPlayerNametagColor ( source, 255, 200, 0 ) 
     setElementModel(source,127) 
      giveWeapon ( source, 31, 200 ) 
     outputChatBox("You have chosen to be a Survivor!",source,255,200,0) 
end 
addEvent("setSurvivor", true) 
addEventHandler("setSurvivor",root,joinSurvivor) 

Link to comment

you mean like this :

client.lua

  
local marker = createMarker( 203.68948364258, 1913.0572509766, 17.640625, "Cylinder", 2, 6, 240, 226, 255) 
  
GUIEditor = { 
    button = {}, 
    window = {}, 
    memo = {} 
} 
        GUIEditor.window[1] = guiCreateWindow(428, 169, 485, 449, "Survivors", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetVisible(GUIEditor.window[1], false) 
        GUIEditor.button[1] = guiCreateButton(148, 307, 194, 57, "Choose", false, GUIEditor.window[1]) 
        GUIEditor.memo[1] = guiCreateMemo(9, 24, 466, 247, "Survivors.... Allied With Military , if you choose this side , you will be spawned to the Military & Survivors Base. and there is no going back. and as a survivor , you will need to survive and explore san andreas while killing zombies and surviving for better experience.", false, GUIEditor.window[1]) 
        guiMemoSetReadOnly(GUIEditor.memo[1], true)     
        GUIEditor.button[2] = guiCreateButton(150, 379, 192, 52, "Cancel", false, GUIEditor.window[1])     
  
addEventHandler("onClientMarkerHit", marker, function(player) 
         if (player == localPlayer) then 
             guiSetVisible(GUIEditor.window[1], true) 
             showCursor(true) 
         end 
 end) 
  
 addEventHandler("onClientGUIClick",GUIEditor.button[1],function() 
        if ( source == GUIEditor.button[1]) then  
           triggerServerEvent("setSurvivor",getLocalPlayer(),getLocalPlayer()) 
        end 
    end ) 

server.lua

function createSurvivorTeam () 
    SurvivorTeam = createTeam ("Survivors", 255, 200, 0) 
end 
addEventHandler ("onResourceStart", resourceRoot, createSurvivorTeam) 
  
function joinSurvivor() 
     setPlayerTeam(source,SurvivorTeam) 
    setPlayerNametagColor ( source, 255, 200, 0 ) 
     setElementModel(source,127) 
      giveWeapon ( source, 31, 200 ) 
     outputChatBox("You have chosen to be a Survivor!",source,255,200,0) 
end 
addEvent("setSurvivor", true) 
addEventHandler("setSurvivor",root,joinSurvivor) 

Link to comment
  
  
function some_function(button, state) 
    if (source == some_btn) then 
      triggerServerEvent("name_of_event", getLocalPlayer(),arg,arg2) 
end 
addEventHandler ( "onClientGUIClick",some_btn, some_function,false) 
  

Edited by Guest
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...