Jump to content

[help]problem in guiGetText


Recommended Posts

hello community i have problem in this code .. i will not post the whole script.

--client

GUIEditor.edit[1] = guiCreateEdit(116, 286, 149, 28, "", false, GUIEditor.window[1]) 
GUIEditor.button[1] = guiCreateButton(276, 278, 95, 46, "Buy wine", false, GUIEditor.window[1]) 
  
addEventHandler ( "onClientGUIClick", GUIEditor.button[1], function ( ) 
    num = tonumber ( guiGetText ( GUIEditor.edit[1] ) ) 
    if not num then 
        return outputChatBox ( "Invalid number.", 255,0,0 ) 
    elseif num > 50000 then 
    return outputChatBox ( "Maximum time is 50000 (50 secs)", 255,0,0 ) 
    end 
    triggerServerEvent ( "onbuywine", localPlayer ) 
end) 

--server

function drunk  ( num ) 
setTimer ( removeElementData, num, 1, source, "drunk" ) 
setTimer ( setPedWalkingStyle, num, 1, source, 0 ) 
outputChatBox ( "Press alt to walk on drunk mode, you have " .. num .. " mili-seconds to be normal!",source,255,0,255, false ) 
end 
addEvent( "onbuywine", true ) 
addEventHandler( "onbuywine", root, drunk ) 

Errors/Warnings when pressing button : argument 2 ( got nil ) line 1 and 2 and attemp to concatenate a 'local' num ( a nil value )

some one help please

Link to comment
    GUIEditor.edit[1] = guiCreateEdit(116, 286, 149, 28, "", false, GUIEditor.window[1]) 
    GUIEditor.button[1] = guiCreateButton(276, 278, 95, 46, "Buy wine", false, GUIEditor.window[1]) 
      
    addEventHandler ( "onClientGUIClick", GUIEditor.button[1], function ( ) 
        num = tonumber ( guiGetText ( GUIEditor.edit[1] ) ) 
        if not num then outputChatBox ( "Invalid number.", 255,0,0 ) return end 
        if num > 50000 then 
            outputChatBox ( "Maximum time is 50000 (50 secs)", 255,0,0 ) 
        end 
        triggerServerEvent ( "onbuywine", localPlayer, num ) 
    end) 

And serverside looks fine.

Link to comment
  
GUIEditor.edit[1] = guiCreateEdit(116, 286, 149, 28, "", false, GUIEditor.window[1]) 
GUIEditor.button[1] = guiCreateButton(276, 278, 95, 46, "Buy wine", false, GUIEditor.window[1]) 
  
addEventHandler ( "onClientGUIClick", GUIEditor.button[1], function ( ) 
    num = tonumber ( GUIEditor.edit[1]  ) 
    if not num then 
        outputChatBox ( "Invalid number.", 255,0,0 ) 
        return  
    elseif num > 50000 then 
    return outputChatBox ( "Maximum time is 50000 (50 secs)", 255,0,0 ) 
    end 
    triggerServerEvent ( "onbuywine", localPlayer ) 
end) 
  

You used > instead of <. If you would use it will output it because it will be less.

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