Jump to content

motax

Members
  • Posts

    28
  • Joined

  • Last visited

Everything posted by motax

  1. I just made a script where you can lock or unlock your own car by click on the vehicle and choose to lock or unlock it. The script is working fine, except that if a player clicks on the vehicle more times it will run the script as many times he clicked on the car. Server: function car_click ( button, buttons, player ) car = getElementType(source) if(car == "vehicle") then if(buttons == "up") then triggerClientEvent ( "onCar", getRootElement(), source,player) end end end addEventHandler ( "onElementClicked",getRootElement() ,car_click ) Client: addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () car_info = guiCreateWindow ( 200, 200, 200, 200,"Car Menu", false ) lock = guiCreateButton ( 5, 30, 170, 30, "Unlock Car", false, car_info ) lock1 = guiCreateButton ( 5, 61, 170, 30, "Lock Car", false, car_info ) guiSetVisible(car_info, false) end ) function car_window ( car,player ) local playerID = getElementData(player, "ID") local carID = getElementData(car, "ID") local own = getElementData(car, "owner") local kx,ky,kz = getElementPosition(car) local px,py,pz = getElementPosition(player) local dst = getDistanceBetweenPoints2D ( px, py, kx, ky ) if(dst < 5) then if (player ~= localPlayer) then return end guiSetVisible(car_info, true) if(own == playerID)then function open(button, state) setVehicleLocked ( car, false ) outputChatBox("Vehicle succesfully unlocked!",player) guiSetVisible(car_info, false) end function close(button, state) setVehicleLocked ( car, true ) outputChatBox("Vehicle succesfully locked!!",player) guiSetVisible(car_info, false) end addEventHandler ( "onClientGUIClick", lock, open, true ) addEventHandler ( "onClientGUIClick", lock1, close, true ) else outputChatBox("This isn't your car!",player) end end end addEvent( "onCar", true ) addEventHandler( "onCar", getRootElement(), car_window ) I can't figure it out, how to solve this.
  2. After creating a new edit box with, guiCreateEdit and get the value of it, with guiGetText, I get a string variable which is useless because i want to compare it with an integer later. Is it possible somehow to get an integer from gui?
×
×
  • Create New...