saluta Posted July 16, 2021 Share Posted July 16, 2021 Hello everyone, help me please, I want to make sure that when you click buy, the money is withdrawn and not just the component is installed for free. Spoiler Garage = { label = {}, button = {}, window = {}, scrollbar = {}, gridlist = {}, row = {}, checkbox = {} } whl = { {1025}, {1073}, {1074}, {1075}, {1076}, {1077}, {1078}, {1079}, {1080}, {1081}, {1082}, {1083}, {1084}, {1085}, {1096}, {1097}, {1098}, {1087} } local Gpos = { {2240.43, -1793.72, 20} } local Lpos = { {2240.43, -1793.72, 20} } localPlayer = getLocalPlayer() addEventHandler("onClientResourceStart", resourceRoot, function(res) if res == getThisResource() then Garage.window[1] = guiCreateWindow(101, 15, 399, 424, "Customs", false) guiWindowSetSizable(Garage.window[1], false) Garage.gridlist[1] = guiCreateGridList(10, 24, 165, 287, false, Garage.window[1]) guiGridListAddColumn(Garage.gridlist[1], "Wheels", 0.9) Garage.row[1] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[2] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[3] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[4] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[5] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[6] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[7] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[8] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[9] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[10] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[11] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[12] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[13] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[14] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[15] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[16] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[17] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[18] = guiGridListAddRow(Garage.gridlist[1]) Garage.row[19] = guiGridListAddRow(Garage.gridlist[1]) guiGridListSetItemText(Garage.gridlist[1], Garage.row[1], 1, "Wheel 1", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[2], 1, "Wheel 2", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[3], 1, "Wheel 3", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[4], 1, "Wheel 4", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[5], 1, "Wheel 5", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[6], 1, "Wheel 6", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[7], 1, "Wheel 7", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[8], 1, "Wheel 8", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[9], 1, "Wheel 9", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[10], 1, "Wheel 10", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[11], 1, "Wheel 11", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[12], 1, "Wheel 12", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[13], 1, "Wheel 13", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[14], 1, "Wheel 14", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[15], 1, "Wheel 15", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[16], 1, "Wheel 16", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[17], 1, "Wheel 17", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[18], 1, "Relatives Wheel", false, false) guiGridListSetItemText(Garage.gridlist[1], Garage.row[19], 1, "Hydraulic", false, false) Garage.button[1] = guiCreateButton(10, 325, 165, 32, "Buy 10000₽", false, Garage.window[1]) guiSetFont(Garage.button[1], "default-bold-small") guiSetProperty(Garage.button[1], "NormalTextColour", "FFFFFFFF") Garage.button[2] = guiCreateButton(212, 371, 165, 32, "Exit the garage", false, Garage.window[1]) guiSetFont(Garage.button[2], "default-bold-small") guiSetProperty(Garage.button[2], "NormalTextColour", "FFFFFFFF") Garage.button[6] = guiCreateButton(195, 60, 165, 32, "Fix the car - 0₽", false, Garage.window[1]) guiSetFont(Garage.button[6], "default-bold-small") guiSetProperty(Garage.button[6], "NormalTextColour", "FFFFFFFF") Garage.button[4] = guiCreateButton(212, 325, 165, 32, "Repaint", false, Garage.window[1]) guiSetFont(Garage.button[4], "default-bold-small") guiSetProperty(Garage.button[4], "NormalTextColour", "FFFFFFFF") guiSetVisible(Garage.window[1], false) showCursor(false) end end ) addEventHandler("onClientResourceStop", resourceRoot, function(res) if res == getThisResource() then if isElement(Garage.window[1]) then destroyElement(Garage.window[1]) end if isElement(Garage.gridlist[1]) then destroyElement(Garage.gridlist[1]) end if isElement(Garage.row[1]) then destroyElement(Garage.row[1]) end if isElement(Garage.row[2]) then destroyElement(Garage.row[2]) end if isElement(Garage.row[3]) then destroyElement(Garage.row[3]) end if isElement(Garage.row[4]) then destroyElement(Garage.row[4]) end if isElement(Garage.row[5]) then destroyElement(Garage.row[5]) end if isElement(Garage.row[6]) then destroyElement(Garage.row[6]) end if isElement(Garage.row[7]) then destroyElement(Garage.row[7]) end if isElement(Garage.row[8]) then destroyElement(Garage.row[8]) end if isElement(Garage.row[9]) then destroyElement(Garage.row[9]) end if isElement(Garage.row[10]) then destroyElement(Garage.row[10]) end if isElement(Garage.row[11]) then destroyElement(Garage.row[11]) end if isElement(Garage.row[12]) then destroyElement(Garage.row[12]) end if isElement(Garage.row[13]) then destroyElement(Garage.row[13]) end if isElement(Garage.row[14]) then destroyElement(Garage.row[14]) end if isElement(Garage.row[15]) then destroyElement(Garage.row[15]) end if isElement(Garage.row[16]) then destroyElement(Garage.row[16]) end if isElement(Garage.row[17]) then destroyElement(Garage.row[17]) end if isElement(Garage.row[18]) then destroyElement(Garage.row[18]) end if isElement(Garage.row[18]) then destroyElement(Garage.row[19]) end if isElement(Garage.button[1]) then destroyElement(Garage.button[1]) end if isElement(Garage.button[2]) then destroyElement(Garage.button[2]) end if isElement(Garage.button[4]) then destroyElement(Garage.button[4]) end if isElement(Garage.button[6]) then destroyElement(Garage.button[6]) end Garage.window[1] = nil Garage.gridlist[1] = nil Garage.row[1] = nil Garage.row[2] = nil Garage.row[3] = nil Garage.row[4] = nil Garage.row[5] = nil Garage.row[6] = nil Garage.row[7] = nil Garage.row[8] = nil Garage.row[9] = nil Garage.row[10] = nil Garage.row[11] = nil Garage.row[12] = nil Garage.row[13] = nil Garage.row[14] = nil Garage.row[15] = nil Garage.row[16] = nil Garage.row[17] = nil Garage.row[18] = nil Garage.row[19] = nil Garage.button[1] = nil Garage.button[2] = nil Garage.button[4] = nil Garage.button[6] = nil end end ) function onGuiClickGrid (button, state, absoluteX, absoluteY) veh = getPedOccupiedVehicle(localPlayer) if source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[1]) then addVehicleUpgrade(veh, tonumber(whl[1][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[2]) then addVehicleUpgrade(veh, tonumber(whl[2][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[3]) then addVehicleUpgrade(veh, tonumber(whl[3][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[4]) then addVehicleUpgrade(veh, tonumber(whl[4][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[5]) then addVehicleUpgrade(veh, tonumber(whl[5][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[6]) then addVehicleUpgrade(veh, tonumber(whl[6][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[7]) then addVehicleUpgrade(veh, tonumber(whl[7][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[8]) then addVehicleUpgrade(veh, tonumber(whl[8][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[9]) then addVehicleUpgrade(veh, tonumber(whl[9][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[10]) then addVehicleUpgrade(veh, tonumber(whl[10][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[11]) then addVehicleUpgrade(veh, tonumber(whl[11][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[12]) then addVehicleUpgrade(veh, tonumber(whl[12][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[13]) then addVehicleUpgrade(veh, tonumber(whl[13][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[14]) then addVehicleUpgrade(veh, tonumber(whl[14][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[15]) then addVehicleUpgrade(veh, tonumber(whl[15][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[16]) then addVehicleUpgrade(veh, tonumber(whl[16][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[17]) then addVehicleUpgrade(veh, tonumber(whl[17][1])) elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[18]) then for k, u in ipairs ( getVehicleUpgrades ( veh ) ) do if getVehicleUpgradeSlotName ( u ) == "Wheels" then removeVehicleUpgrade(veh, u) end end end end addEventHandler ("onClientGUIClick", getRootElement(), onGuiClickGrid) function onGuiClickPanel (button, state, absoluteX, absoluteY) veh = getPedOccupiedVehicle(localPlayer) if (source == Garage.button[4]) then veh = getPedOccupiedVehicle(localPlayer) if veh and getVehicleController(veh) == localPlayer then if (not colorPicker.isSelectOpen) then r, g, b = getVehicleColor ( veh, true ) colorPicker.openSelect(r, g, b, 255) else colorPicker.closeSelect() end end elseif (source == Garage.button[6]) then veh = getPedOccupiedVehicle(localPlayer) if veh and getVehicleController(veh) == localPlayer then if getElementHealth(veh) < 1000 then triggerServerEvent("serverRepairVehicle", getRootElement(), veh, localPlayer, math.floor((1000-getElementHealth(veh))*10)) else outputChatBox("Машина не нуждается в починке!",0,150,255,true) exports.guimessages2:Draw("The machine not need to be repaired") end end elseif (source == Garage.button[1]) then if Garage.row[1] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[1][1])) setElementData(veh,"wheel", tonumber(whl[1][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[2] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[2][1])) setElementData(veh,"wheel", tonumber(whl[2][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[3] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[3][1])) setElementData(veh,"wheel", tonumber(whl[3][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[4] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[4][1])) setElementData(veh,"wheel", tonumber(whl[4][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[5] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[5][1])) setElementData(veh,"wheel", tonumber(whl[5][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[6] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[6][1])) setElementData(veh,"wheel", tonumber(whl[6][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[7] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[7][1])) setElementData(veh,"wheel", tonumber(whl[7][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[8] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[8][1])) setElementData(veh,"wheel", tonumber(whl[8][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[9] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[9][1])) setElementData(veh,"wheel", tonumber(whl[9][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[10] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[10][1])) setElementData(veh,"wheel", tonumber(whl[10][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[11] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[11][1])) setElementData(veh,"wheel", tonumber(whl[11][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[12] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[12][1])) setElementData(veh,"wheel", tonumber(whl[12][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[13] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[13][1])) setElementData(veh,"wheel", tonumber(whl[13][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[14] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[14][1])) setElementData(veh,"wheel", tonumber(whl[14][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[15] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[15][1])) setElementData(veh,"wheel", tonumber(whl[15][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[16] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[16][1])) setElementData(veh,"wheel", tonumber(whl[16][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[17] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then if getPlayerMoney(player) > 9999 then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[17][1])) setElementData(veh,"wheel", tonumber(whl[17][1])) outputChatBox("You purchased a Wheel for $ 10,000",0,150,255,true) else outputChatBox("Insufficient funds", 0, 100, 255, true) end elseif Garage.row[18] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[1][1])) for k, u in ipairs ( getVehicleUpgrades ( veh ) ) do if getVehicleUpgradeSlotName ( u ) == "Wheels" then triggerServerEvent("serverRemoveVehicleUpgrade", getRootElement(), veh, u) setElementData(veh,"wheel", 0) outputChatBox("You have installed the native Wheel (free)",0,150,255,true) end end elseif Garage.row[19] == guiGridListGetSelectedItem ( Garage.gridlist[1] ) then triggerServerEvent("serverAddVehicleUpgradeH", getRootElement(), veh) else outputChatBox("Not selected Wheel", 0, 100, 255, true) end elseif (source == Garage.button[2]) then guiSetVisible(Garage.window[1], false) showCursor(false) setCameraTarget ( localPlayer ) whll = tonumber( getElementData(veh, "wheel") ) if whll == 0 or not whll then for k, u in ipairs ( getVehicleUpgrades ( veh ) ) do if getVehicleUpgradeSlotName ( u ) == "Wheels" then removeVehicleUpgrade(veh, u) end end else triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, whll) end end end addEventHandler ("onClientGUIClick", getRootElement(), onGuiClickPanel) function showGarageMenu(player, camera) guiSetVisible(Garage.window[1], true) showCursor(true) setCameraMatrix(Gpos[camera][1], Gpos[camera][2], Gpos[camera][3], Lpos[camera][1], Lpos[camera][2], Lpos[camera][3]) end addEvent("showGarageMenu", true) addEventHandler("showGarageMenu",getRootElement(), showGarageMenu) function updateSalon () veh = getPedOccupiedVehicle(localPlayer) if veh and getVehicleController(veh) == localPlayer then guiSetText(Garage.button[6], "Fix the car - "..math.floor((1000-getElementHealth(veh))*10).."$") end if ( colorPicker.isSelectOpen) then r, g, b = colorPicker.updateTempColors() veh = getPedOccupiedVehicle(localPlayer) if veh and getVehicleController(veh) == localPlayer then r1, g1, b1, r2, g2, b2 = getVehicleColor(veh, true) if (guiCheckBoxGetSelected(checkColor1)) then r1, g1, b1 = r, g, b end if (guiCheckBoxGetSelected(checkColor2)) then r2, g2, b2 = r, g, b end if (guiCheckBoxGetSelected(checkColor3)) then setVehicleHeadLightColor(veh, r, g, b) end triggerServerEvent("serverSetVehicleColor", getRootElement(), veh, r1, g1, b1, r2, g2, b2) end end end addEventHandler ( "onClientRender", root, updateSalon ) client.lua Spoiler local Gmark = {} local GMpos = { {2240.43, -1793.72, 20} } addEventHandler ( "onResourceStart", getResourceRootElement(), function (res) if res == getThisResource() then Gmark[1] = createMarker( GMpos[1][1], GMpos[1][2], GMpos[1][3], "cylinder", 2, 0, 150, 255, 170 ) end end) addEventHandler ( "onResourceStop", getResourceRootElement(), function (res) if res == getThisResource() then destroyElement(Gmark[1]) Gmark[1] = nil end end) function markerGarage(marker) for k in ipairs(Gmark) do if marker == Gmark[k] then veh = getPedOccupiedVehicle(source) if veh and getVehicleController(veh) == source then triggerClientEvent (source, "showGarageMenu", getRootElement(), source, k ) end end end end addEventHandler("onPlayerMarkerHit",getRootElement(),markerGarage) function getVehicleHandlingProperty ( element, property ) if isElement ( element ) and getElementType ( element ) == "vehicle" and type ( property ) == "string" then handlingTable = getVehicleHandling ( element ) value = handlingTable[property] if value then return value end end return false end function math.round(number, decimals, method) decimals = decimals or 0 factor = 10 ^ decimals if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor else return tonumber(("%."..decimals.."f"):format(number)) end end function serverAddVehicleUpgrade(vehicle, upgrade, player, price) if isElement(vehicle) and getElementType(vehicle) == "vehicle" then if getPlayerMoney(player) > price then addVehicleUpgrade(vehicle, upgrade) takePlayerMoney(player, price) end end end addEvent("serverAddVehicleUpgrade", true) addEventHandler("serverAddVehicleUpgrade", getRootElement(), serverAddVehicleUpgrade) function serverAddVehicleUpgradeH(vehicle) if not isFoundHydra(vehicle) then addVehicleUpgrade(vehicle, 1087) outputChatBox("Гидравлика установлена(бесплатно)", getVehicleController(vehicle), 0,150,255,true) else removeVehicleUpgrade(vehicle, 1087) outputChatBox("Гидравлика снята", getVehicleController(vehicle), 0,150,255,true) end end addEvent("serverAddVehicleUpgradeH", true) addEventHandler("serverAddVehicleUpgradeH", getRootElement(), serverAddVehicleUpgradeH) function isFoundHydra(vehicle) check = 0 for k, v in ipairs(getVehicleUpgrades(vehicle)) do if v == 1087 then check = 1 end end if check == 1 then return true else return false end end function serverRemoveVehicleUpgrade(vehicle, upgrade) removeVehicleUpgrade(vehicle, upgrade) end addEvent("serverRemoveVehicleUpgrade", true) addEventHandler("serverRemoveVehicleUpgrade", getRootElement(), serverRemoveVehicleUpgrade) function serverRepairVehicle(vehicle, player, price) if isElement(vehicle) and getElementType(vehicle) == "vehicle" then if getPlayerMoney(player) > price then fixVehicle(vehicle) takePlayerMoney(player, price) outputChatBox("Вы починили машину!", player, 0, 150, 255, true) exports.guimessages:Draw("You fixed the car") setVehicleEngineState(vehicle,true) else outputChatBox("Недостаточно средств!", player, 0, 150, 255, true) exports.guimessages2:Draw("U no have money") end end end addEvent("serverRepairVehicle", true) addEventHandler("serverRepairVehicle", getRootElement(), serverRepairVehicle) function serverSetVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) end addEvent("serverSetVehicleColor", true) addEventHandler("serverSetVehicleColor", getRootElement(), serverSetVehicleColor) server.lua Spoiler screenshot debugscript 3 Link to comment
DiSaMe Posted July 16, 2021 Share Posted July 16, 2021 You trigger the event like this: triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[1][1])) Arguments for handler function start at argument 3. Therefore, two arguments are passed, veh and tonumber(whl[1][1]). However, the handler function looks like this: function serverAddVehicleUpgrade(vehicle, upgrade, player, price) There are four arguments - more than were passed from the client. Only vehicle and upgrade get assigned. player and price default to nil. Link to comment
saluta Posted July 17, 2021 Author Share Posted July 17, 2021 8 hours ago, CrystalMV said: Вы запускаете событие следующим образом: Аргументы для функции-обработчика начинаются с аргумента 3. Следовательно, передаются два аргумента, veh и tonumber (whl [1] [1]). Однако функция-обработчик выглядит так: Есть четыре аргумента - больше, чем было передано от клиента. Присваиваются только машина и улучшение. player и цена по умолчанию равна нулю. what am I supposed to do? explanation as on wiki mta, but what's the point? I don't see the fix in the code. I need help. Link to comment
SpecT Posted July 17, 2021 Share Posted July 17, 2021 (edited) As @CrystalMV explained you have missing arguments in the client side triggerServerEvents where you call the "serverAddVehicleUpgrade" event. You miss the player and price arguments. You can easily add the player (localPlayer) element to the calls BUT you don't have the prices specified anywhere. So until you put all the prices of each upgrade in each of all those triggerServerEvent calls (or store them in a table) you can set a default price in the server side function and remove the price from the function arguments. Also no offense but you are again just throwing a large amount lines of script and expecting someone to address the problem and fix it all for you without an effort from your side. We are giving you directions which in my opinion should be enough to understand what you are supposed to do. Edited July 17, 2021 by SpecT Link to comment
saluta Posted July 17, 2021 Author Share Posted July 17, 2021 7 hours ago, SpecT said: As @CrystalMV explained you have missing arguments in the client side triggerServerEvents where you call the "serverAddVehicleUpgrade" event. You miss the player and price arguments. You can easily add the player (localPlayer) element to the calls BUT you don't have the prices specified anywhere. So until you put all the prices of each upgrade in each of all those triggerServerEvent calls (or store them in a table) you can set a default price in the server side function and remove the price from the function arguments. Also no offense but you are again just throwing a large amount lines of script and expecting someone to address the problem and fix it all for you without an effort from your side. We are giving you directions which in my opinion should be enough to understand what you are supposed to do. It does not work, I tried to attribute not the player but the localplayer to the events on the client side. I still can't try to remove the price arguments in the function, leave three arguments, in general I tried all those and those again and the same errors. Link to comment
saluta Posted July 18, 2021 Author Share Posted July 18, 2021 and what to do, you people are so interesting and why is this section of the forum made? To solve the problem, I know that this post has been viewed by more experienced Lua programmers than I am, I have only 1 year of experience in LUA, and you have more somewhere and you are crazy about me and stupidly skip the topic, cool. Link to comment
DiSaMe Posted July 18, 2021 Share Posted July 18, 2021 The purpose of this forum section is to allow people to lead other people on the right track, which is exactly what I'm trying to do. The problem isn't that the number of arguments doesn't match, the problem is that in the end the operations get performed on values that are invalid for those operations. triggerServerEvent("serverAddVehicleUpgrade", getRootElement(), veh, tonumber(whl[1][1]) ) ? ? | | | | +-------------------------------+ | | | | | | | | +--------------------------------------+ | | | | | | | | +----------------------------------------------------+ | | | | | | | | +------------------------------------------------------+ | | | | V V V V function serverAddVehicleUpgrade(vehicle, upgrade, player, price) | | +----------------------------+ | | | | | +--------------------------+ | | | | V V | | if getPlayerMoney(player) > price then | | | | +--------------------------+ | | | | +--------------------------+ | | V V takePlayerMoney(player, price) 1 Link to comment
saluta Posted July 18, 2021 Author Share Posted July 18, 2021 7 hours ago, CrystalMV said: Цель этого раздела форума - позволить людям вести других по правильному пути, что я и пытаюсь сделать. Проблема не в том, что количество аргументов не совпадает, проблема в том, что в конце операции выполняются со значениями, недопустимыми для этих операций. tried it, it doesn't work, maybe I'll pay you to fix the bugs of my script completely? 1 $ Link to comment
saluta Posted July 18, 2021 Author Share Posted July 18, 2021 $ 1 just for fixing a small script, are you going to waste? I offered you, as it were, for a paid correction Link to comment
saluta Posted July 18, 2021 Author Share Posted July 18, 2021 In general, I fixed now the money is removed when you click buy and the disc is bought everything is normal, but now another error when I go to the marker opens the same goo window, and when I buy the disc it writes the error warning: bad argument @ 'addvehicleupgrade' function serverAddVehicleUpgrade(veh, localplayer, price) if getPlayerMoney(localplayer) > price then addVehicleUpgrade(veh) takePlayerMoney(localplayer, price) end end addEvent("serverAddVehicleUpgrade", true) addEventHandler("serverAddVehicleUpgrade", getRootElement(), serverAddVehicleUpgrade) Spoiler elseif source == Garage.gridlist[1] and (guiGridListGetSelectedItem ( Garage.gridlist[1] ) == Garage.row[2]) then addVehicleUpgrade(veh, tonumber(whl[2][1])) client.. Link to comment
saluta Posted July 20, 2021 Author Share Posted July 20, 2021 Why keep quiet, I am waiting for an answer from you, dear programmers. If we create another topic the same, they will put a ban on me, but why do I need it? answer me here a solution to my problem please, urgently needed. Link to comment
saluta Posted July 20, 2021 Author Share Posted July 20, 2021 I already figured it out myself, I just hid the addvehicleupgrade code in the server side and did nothing else, like there are no bugs and errors, everything works fine and it is saved and money is withdrawn for binding to my car dealership system, everything is clear, what is similar to the system with samp rp. We will open soon wait 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