Jump to content

Need help in Client Side [GUI]


Hell-Mate

Recommended Posts

Hello community i just faced a problem when scripting GUI, the problem is > Well, i will give an example for what i want to do.

for example i want to make a weapons shop, for example this GUI >

[Write how much ammo u want] Ammo M4 "BUY"

Well the problem is,for example some one wrote 5 ammo of M4 how to detect how much he wrote ? all what i know about the server side is that i should write the amount of the ammo to give the player but idk how i let it detect what the player wrote then give thePlayer the amount he wrote Like this script it gives the player 600 ammo per click

giveWeapon ( thePlayer, 31, 600 ) 

i think i should add something instead of 600 to let it detect what the player wrote in the text.

i hope someone help me :)

if it possible if someone write me an example for client and server side it will be a favor :), thank you

Link to comment

Here's a basic example you can go off:

-- Client 
local edit = guiCreateEdit ( 0, 0, 500, 20, "", false ) 
local btn = guiCreateButton ( 0, 30, 70, 20, "Submit", false ) 
  
addEventHandler ( "onClientGUIClick", btn, function ( ) 
    local num = tonumber ( guiGetText ( edit ) ) 
    if not num then 
        return outputChatBox ( "Invalid number." ) 
    end 
    triggerServerEvent ( "onNumberSubmitted", localPlayer, num ) 
end ) 
  
-- server 
addEvent ( "onNumberSubmitted", true ) 
addEventHandler ( "onNumberSubmitted", root, function ( num ) 
    outputChatBox ( getPlayerName ( source ).." says "..num.."!", root ) 
end ) 

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