Jump to content

GUI Data to server?


megaman54

Recommended Posts

see GUI functions in wiki: https://wiki.multitheftauto.com/wiki/Cli ... _functions

basically you'll need to get values from your gui element and trigger a server event to send it:

  
local someGUIeditValue = guiGetText(someGUIelement) -- works for windows/buttons/edits/etc 
local someGUIscrollValue = guiScrollBarGetScrollPosition(someGUIscrollbar) -- scrollbar position 
local someGUIcheckboxValue = guiCheckBoxSetSelected(someGUIcheckbox) -- true/false from checkbox 
-- etc 
triggerServerEvent("someGUI2ServerEvent", getLocalPlayer(), someGUIeditValue, someGUIscrollValue, someGUIcheckboxValue) -- event needs to be added/handled on the server 
  

Link to comment

Ok thanks :D i'm making a moderator panel so this was needed. :)

EDIT: When data is in server side, transferred with event, how to handle it server side?

Like this: i have a edit box and a button. I write someones name to the edit box and press the button. Event gets triggerded and data went to server side script, and now the server should kick that player with the name i typed in the edit box. How to make this happen?

Link to comment

well you have to handle this event:

function adminKickPlayer(editbox) -- here's the editbox value you've passed from client 
  local player = getPlayerFromName(editbox) -- getting the player from name containd in editbox 
  if player then  
    -- player found, kick him: 
    kickPlayer(player)  
  else 
    -- output to event source (you) that player not found: 
    outputChatBox("Player with name '"..editbox.."' not found", source)  
  end 
end 
  
addEvent("someGUI2ServerEvent", true) -- adds event on the server, so it could be triggered 
addEventHandler("someGUI2ServerEvent", getRootElement(), adminKickPlayer) -- attached event handler 

its all on the wiki, actually.

Link to comment
why you making moderator panel ? :P

Admin panel is already a moderator panel too, with some thing's accec denied.....

Well, i'm making a smaller admin/moderator panel because some of my admins and moderators got a slow computer so the big admin panel lags for them. Only basic things in my panel :D

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