Hell-Mate Posted February 25, 2014 Share Posted February 25, 2014 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
xXMADEXx Posted February 25, 2014 Share Posted February 25, 2014 use tonumber, guiGetText and triggerServerEvent. Link to comment
Hell-Mate Posted February 26, 2014 Author Share Posted February 26, 2014 use tonumber, guiGetText and triggerServerEvent. Can you give me an example script ? Link to comment
xXMADEXx Posted February 26, 2014 Share Posted February 26, 2014 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
Hell-Mate Posted February 26, 2014 Author Share Posted February 26, 2014 Well another two questions First : what if i want it to getText of the ammo is that code right ? >> giveWeapon ( thePlayer, 31, num ) Second : what if i want it letters not numbers ? does it be > toletter ? totext ?, and what if i want it letters and numbers ? . Thank you Link to comment
Hell-Mate Posted February 26, 2014 Author Share Posted February 26, 2014 tostring Thank you very much WhoAmI and xxMadexx but can any one answer my first question ? First : what if i want it to getText of the ammo is that code right ? >> giveWeapon ( thePlayer, 31, num ) Link to comment
WhoAmI Posted February 26, 2014 Share Posted February 26, 2014 If num is defined as nuber, yea it's good. Link to comment
Hell-Mate Posted February 27, 2014 Author Share Posted February 27, 2014 Well, all is ok now. but i want to ask a last question. How to make it auto detect nearest string or number i wrote? for example i wrote "Hel" so it can detect "Hello". Help please. Thank You Link to comment
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