Jump to content

TriggerServerEvent editBox


BriGhtx3

Recommended Posts

My files :

client :

  
function createFreikaufGUI() 
  
gWindow["freikaufen"] = guiCreateWindow(250,162,310,331,"Auto freikaufen",false) 
freiKaufLb = guiCreateLabel(26,22,253,47,"Auto freikaufen",false,gWindow["freikaufen"]) 
guiSetFont(freiKaufLb,"sa-gothic") 
fText = guiCreateLabel(33,78,234,85,"Hier kannst du dein beschlagnahmtes\nAuto freikaufen! Die Gebühren liegen bei\n200$ pro Freikauf! Gehe anschließend zur\nVerwahrungsstelle um dein Auto\nabzuholen. Der Eintritt liegt bei 150$!",false,gWindow["freikaufen"]) 
guiSetFont(fText,"default-bold-small") 
fSlot = guiCreateLabel(37,184,235,35,"Slot des Autos? (1-9) : ",false,gWindow["freikaufen"]) 
guiSetFont(fSlot,"sa-header") 
fEdit = guiCreateEdit(38,231,233,34,"",false,gWindow["freikaufen"]) 
fBtn = guiCreateButton(41,274,228,40,"Auto freikaufen",false,gWindow["freikaufen"]) 
guiSetFont(fBtn,"sa-header") 
guiSetVisible(gWindow["freikaufen"], true) 
showCursor(true) 
addEventHandler("onClientGUIClick", fBtn, 
                function() 
                triggerServerEvent ( "freiKauf", lp, guiGetText ( fEdit ) ) 
                end) 
end 
addCommandHandler("buykaution", createFreikaufGUI) 
  

server :

function freiKaufS(theplayer, text) 
local player = getPlayerName( source ) 
    --[[if slot > 9 or slot < 1 then 
        triggerClientEvent ( player, "infobox_start", getRootElement(), "Slot nicht verfügbar!", 5000, 125, 0, 0 ) 
    else 
  
        local money = tonumber( vioGetElementData ( player, "money" ) ) 
        local preis = 200 
        if money >= preis then 
            vioSetElementData ( player, "money", money - preis ) 
            MySQL_SetString("vehicles", "Beschlagnahmt", "0", "Besitzer LIKE '" ..player.."' AND Slot LIKE '" ..slot.. "' ") 
            outputChatBox("Erfolgreich freigekauft!", player, 0, 255, 0) 
  
        else 
            triggerClientEvent ( player, "infobox_start", getRootElement(), "\nDu hast nicht genug\nGeld!", 5000, 125, 0, 0 ) 
        end 
    end]]-- 
    outputChatBox(text) 
    outputChatBox(player) 
    end 
addEvent( "freiKauf", true ) 
addEventHandler( "freiKauf", getRootElement(), freiKaufS ) 

When I type "/buykaution" the gui window opens. Then when I click on the Button, the event triggers. When I output the results, it outputs the name which is triggered, but not the text in the editBox.

Everything is in the meta.xml.

Link to comment
function createFreikaufGUI() 
  
gWindow["freikaufen"] = guiCreateWindow(250,162,310,331,"Auto freikaufen",false) 
freiKaufLb = guiCreateLabel(26,22,253,47,"Auto freikaufen",false,gWindow["freikaufen"]) 
guiSetFont(freiKaufLb,"sa-gothic") 
fText = guiCreateLabel(33,78,234,85,"Hier kannst du dein beschlagnahmtes\nAuto freikaufen! Die Gebühren liegen bei\n200$ pro Freikauf! Gehe anschließend zur\nVerwahrungsstelle um dein Auto\nabzuholen. Der Eintritt liegt bei 150$!",false,gWindow["freikaufen"]) 
guiSetFont(fText,"default-bold-small") 
fSlot = guiCreateLabel(37,184,235,35,"Slot des Autos? (1-9) : ",false,gWindow["freikaufen"]) 
guiSetFont(fSlot,"sa-header") 
fEdit = guiCreateEdit(38,231,233,34,"",false,gWindow["freikaufen"]) 
fBtn = guiCreateButton(41,274,228,40,"Auto freikaufen",false,gWindow["freikaufen"]) 
guiSetFont(fBtn,"sa-header") 
guiSetVisible(gWindow["freikaufen"], true) 
showCursor(true) 
addEventHandler("onClientGUIClick", fBtn, 
                function() 
                triggerServerEvent ( "freiKauf", getLocalPlayer(), getLocalPlayer(),guiGetText ( fEdit ) ) 
                end) 
end 
addCommandHandler("buykaution", createFreikaufGUI) 

it output the name bk you trigger the Serer event whit only 1 argument "guiGetText ( fEdit )" and on the server side you get 2 argument's function(player,txt) and then the player get the fEdit txt and the txt is nil

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