TheMta Posted December 17, 2019 Posted December 17, 2019 It gives an error on line 359: attempt to compare number with nil line : 18 ( here only posted function ) Quote function buy( root, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice ) if getPlayerMoney(root) >= tonumber(gheymat) then local query = dbQuery(exports.mysql:getMySQLC(), "SELECT * FROM vehicles;" ) local result, numrows = dbPoll(query, dbpTime) if (result and numrows > 0) then setElementData(root,"carsnumber",0) for index, row in pairs(result) do local owner = row['vOwner'] if owner == getPlayerName(root) then local chanta = getElementData(root,"carsnumber") local chantabadi = tonumber(chanta) + 1 setElementData(root,"carsnumber",chantabadi) end end dbFree(query) end if tonumber(getElementData(root,"carsnumber")) < tonumber(getElementData(accSys:getPlayerAcc(root), "pSlot")) then outputChatBox("#00ff00[Auto Gallery]: #ffffffKhodroye Jadid'e Shoma Amade Shod, Mobarake!", root, 255, 255, 255, true) takePlayerMoney ( root, tonumber(gheymat) ) local NewCar = createVehicle ( idecar, carx, cary, carz, 0, 0, carrot ) setVehicleColor( NewCar, 255, 255, 255, 255, 255, 255) local dscolor = setVehicleHeadLightColor ( NewCar, 255, 255, 255 ) local slot = getElementData(root,"carsnumber") setVehicleLocked ( NewCar, true ) setElementData(NewCar, "owner",getPlayerName(root)) setElementData(NewCar, "vehicleSlot",slot+1) local slot1 = tonumber(slot)+1 local QueryMashinSazBaradarGhooleCheragheJado = dbQuery(exports.mysql:getMySQLC(), "INSERT INTO `vehicles` SET `vOwner` = ?, `vModel`= ?, `vLocationX` = ?, `vLocationY` = ?, `vLocationZ` = ?, `vRotationZ` = ?, `vPrice` = ?, `vSlot` = "..slot1.."", getPlayerName(root), idecar, carx, cary, carz, carrot, sellprice, 0) dbFree(QueryMashinSazBaradarGhooleCheragheJado) local query = dbQuery(exports.mysql:getMySQLC(), "SELECT * FROM vehicles;" ) local result, numrows = dbPoll(query, dbpTime) if (result and numrows > 0) then setElementData(root,"carsnumber",0) for index, row in pairs(result) do local owner = row['vOwner'] if owner == getPlayerName(root) then local slot2 = row['vSlot'] if slot2 == slot1 then local vID = row['vID'] createPlateStage1(vID) setElementData(NewCar,"vehicleID",vID) local vPlate = row['vPlate'] setVehiclePlateText( NewCar, vPlate ) local vBime = row['vBime'] setElementData(NewCar,"bime",vBime) end end end
Motar2k Posted December 17, 2019 Posted December 17, 2019 Use this before line 359 if tonumber(getElementData(root,"carsnumber")) and tonumber(getElementData(accSys:getPlayerAcc(root), "pSlot")) then This verifies if the 2 values to compare are numbers
TheMta Posted December 17, 2019 Author Posted December 17, 2019 (edited) 27 minutes ago, Avival said: Use this before line 359 if tonumber(getElementData(root,"carsnumber")) and tonumber(getElementData(accSys:getPlayerAcc(root), "pSlot")) then This verifies if the 2 values to compare are numbers i give an error on line 397 : Quote setElementData(root,"carsnumber",nil) Error : attempt to concatenate a boolean value Edited December 17, 2019 by TheMta
TheMta Posted December 17, 2019 Author Posted December 17, 2019 4 minutes ago, Avival said: Paste the line 397 @TheMta Quote setTimer( function() SortPlayerVehiclesID(thePlayer) end, 7000, 1) else outputChatBox("#ff0000Shoma Dar Hale Hazer "..getElementData(root,"carsnumber").." Mashin Darid!", root, 255, 255, 255, true) setElementData(root,"carsnumber",nil) end else outputChatBox("#ff0000Shoma Poole Kafi Nadarid!", root, 255, 255, 255, true) end end line 6 : line 397
Motar2k Posted December 18, 2019 Posted December 18, 2019 4 minutes ago, TheMta said: line 6 : line 397 setTimer( function() SortPlayerVehiclesID(thePlayer) end, 7000, 1) else outputChatBox("#ff0000Shoma Dar Hale Hazer "..tostring(getElementData(root,"carsnumber")).." Mashin Darid!", root, 255, 255, 255, true) setElementData(root,"carsnumber",nil) end else outputChatBox("#ff0000Shoma Poole Kafi Nadarid!", root, 255, 255, 255, true) end end
TheMta Posted December 18, 2019 Author Posted December 18, 2019 17 minutes ago, Avival said: setTimer( function() SortPlayerVehiclesID(thePlayer) end, 7000, 1) else outputChatBox("#ff0000Shoma Dar Hale Hazer "..tostring(getElementData(root,"carsnumber")).." Mashin Darid!", root, 255, 255, 255, true) setElementData(root,"carsnumber",nil) end else outputChatBox("#ff0000Shoma Poole Kafi Nadarid!", root, 255, 255, 255, true) end end Not working When i buy a car servere say Now You Have Nil Cars! This is car shop script I have problem at this script please help me see this : Quote local accSys = exports["accounts-system"] local miscSys = exports["misc"] local vehSys = exports["Dealer-Ship"] function isVehicleOccupied(vehicle) assert(isElement(vehicle) and getElementType(vehicle) == "vehicle", "Bad argument @ isVehicleOccupied [expected vehicle, got " .. tostring(vehicle) .. "]") local _, occupant = next(getVehicleOccupants(vehicle)) return occupant and true, occupant end function fixMashinayeDs() setTimer(function() for index, mashinayeDs in ipairs(getElementsByType("vehicle")) do local vehid = getElementID ( mashinayeDs ) if vehid == "dscar1" or vehid == "dscar2" or vehid == "dscar3" or vehid == "dscar4" or vehid == "dscar5" or vehid == "dscar6" or vehid == "dscar7" or vehid == "dscar8" or vehid == "dscar9" or vehid == "dscar10" or vehid == "dscar11" or vehid == "dscar12" or vehid == "dscar13" or vehid == "dscar14" or vehid == "dscar15" or vehid == "dscar16" or vehid == "dscar17" or vehid == "dscar18" or vehid == "dscar19" or vehid == "dscar20" or vehid == "dscar21" or vehid == "dscar22"or vehid == "dscar23" or vehid == "dscar24" or vehid == "dscar25" or vehid == "dscar26" or vehid == "dscar27" or vehid == "dscar28" or vehid == "dscar29" or vehid == "dscar30" or vehid == "dscar31" or vehid == "dscar32" or vehid == "dscar33" or vehid == "dscar34" or vehid == "dscar35" or vehid == "dscar36" or vehid == "dscar37" or vehid == "dscar38" or vehid == "dscar39" or vehid == "dscar40" or vehid == "dscar41" or vehid == "dscar42" or vehid == "dscar43" or vehid == "dscar44" or vehid == "dscar45" or vehid == "dscar46" or vehid == "dscar47" or vehid == "dscar48" or vehid == "dscar49" or vehid == "dscar50" or vehid == "dscar51" or vehid == "dscar52" or vehid == "dscar53" or vehid == "dscar54" or vehid == "dscar55" or vehid == "dscar56" or vehid == "dscar57" or vehid == "dscar58" or vehid == "dscar59" or vehid == "dscar60" or vehid == "dscar61" or vehid == "dscar62" or vehid == "dscar63" or vehid == "dscar64" or vehid == "dscar65" or vehid == "dscar66" or vehid == "dscar67" or vehid == "dscar68" or vehid == "dscar69" or vehid == "dscar70" or vehid == "dscar71" or vehid == "dscar72" or vehid == "dscar73" or vehid == "dscar74" or vehid == "dscar75" or vehid == "dscar76" or vehid == "dscar77" or vehid == "dscar78" or vehid == "dscar79" or vehid == "dscar80" or vehid == "dscar81" or vehid == "dscar82" or vehid == "dscar83" or vehid == "dscar84" or vehid == "dscar85" or vehid == "dscar86" or vehid == "dscar87" or vehid == "dscar88" or vehid == "dscar89" or vehid == "dscar90" then respawnVehicle(mashinayeDs) fixVehicle(mashinayeDs) setTimer(function() setElementFrozen ( mashinayeDs, true ) setVehicleLocked ( mashinayeDs, true ) setVehicleDamageProof( mashinayeDs,true) end, 4000, 1) end end end, 2000, 1) end addEventHandler ( "onResourceStart", getRootElement(), fixMashinayeDs) function getcar( button, state, player ) if button == "left" and state == "down" then if getElementType( source ) == "vehicle" then local x, y, z = getElementPosition( player ) local x1, y1, z1 = getElementPosition( source ) local fasele = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ) local gheymat = getElementData(source, "gheymat") if fasele < 4 then idveh = getElementID ( source ) if idveh == "dscar1" then local gheymat = 1000000 local gheymatgold = 1000 local shetab = 6 local sorat = 120 local idecar = 471 local carx = 2363.5673828125 local cary = -1358.3271484375 local carz = 23.482931137085 local carrot = 0 local sellprice = 540000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar2" then local gheymat = 2100000 local gheymatgold = 2100 local shetab = 16 local sorat = 200 local idecar = 522 local carx = 2363.5673828125 local cary = -1358.3271484375 local carz = 23.482931137085 local carrot = 0 local sellprice = 1100000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar3" then local gheymat = 800000 local gheymatgold = 800 local shetab = 7 local sorat = 140 local idecar = 461 local carx = 2363.5673828125 local cary = -1358.3271484375 local carz = 23.482931137085 local carrot = 0 local sellprice = 450000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar4" then local gheymat = 50000 local gheymatgold = 50 local shetab = 6 local sorat = 100 local idecar = 462 local carx = 2363.5673828125 local cary = -1358.3271484375 local carz = 23.482931137085 local carrot = 0 local sellprice = 20000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar5" then local gheymat = 1500000 local gheymatgold = 1500 local shetab = 12 local sorat = 180 local idecar = 581 local carx = 2363.5673828125 local cary = -1358.3271484375 local carz = 23.482931137085 local carrot = 0 local sellprice = 800000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar6" then local gheymat = 700000 local gheymatgold = 700 local shetab = 8 local sorat = 140 local idecar = 468 local carx = 2363.5673828125 local cary = -1358.3271484375 local carz = 23.482931137085 local carrot = 0 local sellprice = 400000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar7" then local gheymat = 1300000 local gheymatgold = 1300 local shetab = 10 local sorat = 160 local idecar = 586 local carx = 2363.5673828125 local cary = -1358.3271484375 local carz = 23.482931137085 local carrot = 0 local sellprice = 670000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar8" then local gheymat = 1100000 local gheymatgold = 1100 local shetab = 8 local sorat = 160 local idecar = 463 local carx = 2363.5673828125 local cary = -1358.3271484375 local carz = 23.482931137085 local carrot = 0 local sellprice = 510000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar9" then local gheymat = 800000 local gheymatgold = 800 local shetab = 10 local sorat = 180 local idecar = 466 local carx = 965.6103515625 local cary = -1215.8759765625 local carz = 16.771820068359 local carrot = 90 local sellprice = 450000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar12" then local gheymat = 1000000 local gheymatgold = 1000 local shetab = 10 local sorat = 180 local idecar = 516 local carx = 965.6103515625 local cary = -1215.8759765625 local carz = 16.771820068359 local carrot = 90 local sellprice = 600000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar13" then local gheymat = 2400000 local gheymatgold = 2400 local shetab = 14 local sorat = 220 local idecar = 551 local carx = 965.6103515625 local cary = -1215.8759765625 local carz = 16.771820068359 local carrot = 90 local sellprice = 1350000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar14" then local gheymat = 400000 local gheymatgold = 400 local shetab = 6 local sorat = 140 local idecar = 404 local carx = 965.6103515625 local cary = -1215.8759765625 local carz = 16.771820068359 local carrot = 90 local sellprice = 250000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar15" then local gheymat = 250000 local gheymatgold = 250 local shetab = 6 local sorat = 120 local idecar = 566 local carx = 965.6103515625 local cary = -1215.8759765625 local carz = 16.771820068359 local carrot = 90 local sellprice = 120000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar16" then local gheymat = 450000 local gheymatgold = 450 local shetab = 6 local sorat = 140 local idecar = 543 local carx = 965.6103515625 local cary = -1215.8759765625 local carz = 16.771820068359 local carrot = 90 local sellprice = 280000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar17" then local gheymat = 300000 local gheymatgold = 300 local shetab = 8 local sorat = 140 local idecar = 600 local carx = 965.6103515625 local cary = -1215.8759765625 local carz = 16.771820068359 local carrot = 90 local sellprice = 170000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar18" then local gheymat = 1500000 local gheymatgold = 1500 local shetab = 12 local sorat = 200 local idecar = 405 local carx = 965.6103515625 local cary = -1215.8759765625 local carz = 16.771820068359 local carrot = 90 local sellprice = 900000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar19" then local gheymat = 1800000 local gheymatgold = 1800 local shetab = 12 local sorat = 220 local idecar = 426 local carx = 965.6103515625 local cary = -1215.8759765625 local carz = 16.771820068359 local carrot = 90 local sellprice = 1100000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar20" then local gheymat = 900000 local gheymatgold = 900 local shetab = 12 local sorat = 200 local idecar = 445 local carx = 965.6103515625 local cary = -1215.8759765625 local carz = 16.771820068359 local carrot = 90 local sellprice = 500000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar22" then local gheymat = 7000000 local gheymatgold = 7000 local shetab = 16 local sorat = 260 local idecar = 477 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 4500000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar23" then local gheymat = 4800000 local gheymatgold = 4800 local shetab = 12 local sorat = 220 local idecar = 555 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 2500000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar24" then local gheymat = 8000000 local gheymatgold = 8000 local shetab = 24 local sorat = 300 local idecar = 502 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 4500000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar25" then local gheymat = 5350000 local gheymatgold = 5350 local shetab = 14 local sorat = 240 local idecar = 411 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 3100000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar26" then local gheymat = 6400000 local gheymatgold = 6400 local shetab = 16 local sorat = 280 local idecar = 458 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 3800000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar27" then local gheymat = 7100000 local gheymatgold = 7100 local shetab = 16 local sorat = 300 local idecar = 451 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 4900000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar28" then local gheymat = 3200000 local gheymatgold = 3200 local shetab = 8 local sorat = 220 local idecar = 491 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 1700000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar29" then local gheymat = 5100000 local gheymatgold = 5100 local shetab = 12 local sorat = 240 local idecar = 579 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 3200000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar30" then local gheymat = 4700000 local gheymatgold = 6200 local shetab = 12 local sorat = 220 local idecar = 418 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 2900000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar31" then local gheymat = 6200000 local gheymatgold = 6200 local shetab = 14 local sorat = 240 local idecar = 421 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 4100000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar32" then local gheymat = 2800000 local gheymatgold = 2800 local shetab = 8 local sorat = 200 local idecar = 489 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 1700000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar33" then local gheymat = 6500000 local gheymatgold = 6500 local shetab = 16 local sorat = 280 local idecar = 494 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 3900000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar34" then local gheymat = 5600000 local gheymatgold = 5600 local shetab = 12 local sorat = 260 local idecar = 603 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 3200000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar35" then local gheymat = 7000000 local gheymatgold = 7000 local shetab = 12 local sorat = 280 local idecar = 429 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 3800000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar36" then local gheymat = 4800000 local gheymatgold = 4800 local shetab = 14 local sorat = 240 local idecar = 533 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 2500000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar37" then local gheymat = 5400000 local gheymatgold = 5400 local shetab = 14 local sorat = 260 local idecar = 546 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 3200000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar38" then local gheymat = 8200000 local gheymatgold = 8200 local shetab = 18 local sorat = 300 local idecar = 559 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 5600000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar39" then local gheymat = 7500000 local gheymatgold = 7500 local shetab = 16 local sorat = 300 local idecar = 402 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 4200000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar40" then local gheymat = 4000000 local gheymatgold = 4000 local shetab = 12 local sorat = 240 local idecar = 602 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 2500000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar41" then local gheymat = 5400000 local gheymatgold = 5400 local shetab = 12 local sorat = 240 local idecar = 506 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 3200000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar42" then local gheymat = 6000000 local gheymatgold = 6000 local shetab = 12 local sorat = 280 local idecar = 415 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 3600000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar43" then local gheymat = 4300000 local gheymatgold = 4300 local shetab = 10 local sorat = 220 local idecar = 558 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 2400000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar44" then local gheymat = 4300000 local gheymatgold = 4300 local shetab = 10 local sorat = 220 local idecar = 562 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 2400000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar45" then local gheymat = 6800000 local gheymatgold = 6800 local shetab = 14 local sorat = 280 local idecar = 503 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 4700000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar46" then local gheymat = 4500000 local gheymatgold = 4500 local shetab = 12 local sorat = 220 local idecar = 589 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 2400000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar47" then local gheymat = 9000000 local gheymatgold = 9000 local shetab = 24 local sorat = 320 local idecar = 496 local carx = 544.416015625 local cary = -1258.5634765625 local carz = 16.340549468994 local carrot = 306.68130493164 local sellprice = 5700000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar63" then local gheymat = 60000 local gheymatgold = 60 local shetab = 6 local sorat = 120 local idecar = 422 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 35000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar64" then local gheymat = 75000 local gheymatgold = 75 local shetab = 6 local sorat = 130 local idecar = 554 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 42000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar65" then local gheymat = 375000 local gheymatgold = 375 local shetab = 6 local sorat = 160 local idecar = 436 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 195000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar66" then local gheymat = 450000 local gheymatgold = 450 local shetab = 7 local sorat = 150 local idecar = 474 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 300000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar67" then local gheymat = 90000 local gheymatgold = 90 local shetab = 6 local sorat = 150 local idecar = 483 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 56000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar68" then local gheymat = 280000 local gheymatgold = 280 local shetab = 6 local sorat = 160 local idecar = 542 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 160000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar69" then local gheymat = 330000 local gheymatgold = 330 local shetab = 8 local sorat = 160 local idecar = 527 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 210000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar70" then local gheymat = 920000 local gheymatgold = 920 local shetab = 10 local sorat = 200 local idecar = 587 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 570000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar71" then local gheymat = 200000 local gheymatgold = 200 local shetab = 6 local sorat = 120 local idecar = 545 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 110000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar72" then local gheymat = 450000 local gheymatgold = 450 local shetab = 6 local sorat = 180 local idecar = 549 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 250000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar73" then local gheymat = 1250000 local gheymatgold = 1250 local shetab = 10 local sorat = 220 local idecar = 475 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 700000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar74" then local gheymat = 680000 local gheymatgold = 680 local shetab = 8 local sorat = 160 local idecar = 412 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 380000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar75" then local gheymat = 750000 local gheymatgold = 750 local shetab = 8 local sorat = 200 local idecar = 518 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 430000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar76" then local gheymat = 1000000 local gheymatgold = 1000 local shetab = 10 local sorat = 200 local idecar = 534 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 600000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar77" then local gheymat = 800000 local gheymatgold = 800 local shetab = 6 local sorat = 160 local idecar = 535 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 450000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar78" then local gheymat = 1400000 local gheymatgold = 1400 local shetab = 10 local sorat = 240 local idecar = 536 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 850000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar79" then local gheymat = 900000 local gheymatgold = 900 local shetab = 6 local sorat = 200 local idecar = 585 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 500000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar80" then local gheymat = 1900000 local gheymatgold = 1900 local shetab = 12 local sorat = 200 local idecar = 580 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 1200000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar81" then local gheymat = 950000 local gheymatgold = 950 local shetab = 6 local sorat = 200 local idecar = 576 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 540000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar82" then local gheymat = 2150000 local gheymatgold = 2150 local shetab = 12 local sorat = 240 local idecar = 575 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 1400000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar83" then local gheymat = 1150000 local gheymatgold = 1150 local shetab = 6 local sorat = 220 local idecar = 567 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 620000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar84" then local gheymat = 200000 local gheymatgold = 200 local shetab = 6 local sorat = 140 local idecar = 482 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 120000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar85" then local gheymat = 280000 local gheymatgold = 280 local shetab = 6 local sorat = 160 local idecar = 419 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 150000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar86" then local gheymat = 880000 local gheymatgold = 880 local shetab = 8 local sorat = 200 local idecar = 565 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 490000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar87" then local gheymat = 150000 local gheymatgold = 150 local shetab = 10 local sorat = 160 local idecar = 561 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 90000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar88" then local gheymat = 570000 local gheymatgold = 570 local shetab = 8 local sorat = 200 local idecar = 479 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 340000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar89" then local gheymat = 370000 local gheymatgold = 370 local shetab = 8 local sorat = 180 local idecar = 507 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 210000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) elseif idveh == "dscar90" then local gheymat = 800000 local gheymatgold = 800 local shetab = 8 local sorat = 220 local idecar = 400 local carx = 2172.0859375 local cary = -1148.880859375 local carz = 24.876434707642 local carrot = 181.0 local sellprice = 500000 triggerClientEvent("dsgui", player, player, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice) end end end end end addEventHandler( "onElementClicked", getRootElement( ), getcar ) local dbpTime = 500 function buy( root, gheymat, gheymatgold, shetab, sorat, idecar, carx, cary, carz, carrot, sellprice ) if getPlayerMoney(root) >= tonumber(gheymat) then local query = dbQuery(exports.mysql:getMySQLC(), "SELECT * FROM vehicles;" ) local result, numrows = dbPoll(query, dbpTime) if (result and numrows > 0) then setElementData(root,"carsnumber",0) for index, row in pairs(result) do local owner = row['vOwner'] if owner == getPlayerName(root) then local chanta = getElementData(root,"carsnumber") local chantabadi = tonumber(chanta) + 1 setElementData(root,"carsnumber",chantabadi) end end dbFree(query) end if tonumber(getElementData(root,"carsnumber")) and tonumber(getElementData(accSys:getPlayerAcc(root), "pSlot")) then outputChatBox("#00ff00Mashine Jadid Mobarak!", root, 255, 255, 255, true) takePlayerMoney ( root, tonumber(gheymat) ) local NewCar = createVehicle ( idecar, carx, cary, carz, 0, 0, carrot ) setVehicleColor( NewCar, 255, 255, 255, 255, 255, 255) local dscolor = setVehicleHeadLightColor ( NewCar, 255, 255, 255 ) local slot = getElementData(root,"carsnumber") setVehicleLocked ( NewCar, true ) Object = createObject(1210,0,0,0) attachElements ( Object, NewCar, 0, 0, 0 ) setElementAlpha ( Object, 0 ) CarBlip = createBlipAttachedTo(Object,55,2,255,0,0,255,0,99999.0,root) setElementCollisionsEnabled(Object,false) setElementData(CarBlip,"owner",getPlayerName(root)) setElementData(NewCar, "owner",getPlayerName(root)) setElementData(NewCar, "vehicleSlot",slot+1) local slot1 = tonumber(slot)+1 local QueryMashinSazBaradarGhooleCheragheJado = dbQuery(exports.mysql:getMySQLC(), "INSERT INTO `vehicles` SET `vOwner` = ?, `vModel`= ?, `vLocationX` = ?, `vLocationY` = ?, `vLocationZ` = ?, `vRotationZ` = ?, `vPrice` = ?, `vSlot` = "..slot1.."", getPlayerName(root), idecar, carx, cary, carz, carrot, sellprice, 0) dbFree(QueryMashinSazBaradarGhooleCheragheJado) local query = dbQuery(exports.mysql:getMySQLC(), "SELECT * FROM vehicles;" ) local result, numrows = dbPoll(query, dbpTime) if (result and numrows > 0) then setElementData(root,"carsnumber",0) for index, row in pairs(result) do local owner = row['vOwner'] if owner == getPlayerName(root) then local slot2 = row['vSlot'] if slot2 == slot1 then local vID = row['vID'] createPlateStage1(vID) setElementData(NewCar,"vehicleID",vID) local vPlate = row['vPlate'] setVehiclePlateText( NewCar, vPlate ) end end end dbFree(query) end else outputChatBox("#ff0000Shoma Dar hale Hazer "..getElementData(root,"carsnumber").." Mashin Darid!", root, 255, 255, 255, true) setElementData(root,"carsnumber",nil) end else outputChatBox("#ff0000Shoma Poole Kafi Nadarid!", root, 255, 255, 255, true) end end addEvent("buydscar",true) addEventHandler("buydscar", root,buy) function createPlateStage1(vehicleID) local vehicleID = tonumber(vehicleID) local randNum = math.random(10000,99999) local nxPlate = "NX-"..randNum local query = dbQuery(exports.mysql:getMySQLC(), "SELECT * FROM vehicles;" ) local result, numrows = dbPoll(query, dbpTime) if (result and numrows > 0) then for index, row in pairs(result) do local vehiclesPlate = row['vPlate'] if vehiclesPlate == nxPlate then createPlateStage2(root) end local secQuery = dbQuery(exports.mysql:getMySQLC(), "UPDATE `vehicles` SET `vPlate` = '"..nxPlate.."' WHERE `vID` = '"..vehicleID.."'") dbFree(secQuery) end dbFree(query) end end function createPlateStage2(vehicleID) local vehicleID = tonumber(vehicleID) local randNum = math.random(10000,99999) local nxPlate = "NX-"..randNum local query = dbQuery(exports.mysql:getMySQLC(), "SELECT * FROM vehicles;" ) local result, numrows = dbPoll(query, dbpTime) if (result and numrows > 0) then for index, row in pairs(result) do local vehiclesPlate = row['vPlate'] if vehiclesPlate == nxPlate then createPlateStage1(root) end local secQuery = dbQuery(exports.mysql:getMySQLC(), "UPDATE `vehicles` SET `vPlate` = '"..nxPlate.."' WHERE `vID` = '"..vehicleID.."'") dbFree(secQuery) end dbFree(query) end end function getNearestVehicle(player,distance) local tempTable = {} local lastMinDis = distance-0.0001 local nearestVeh = false local px,py,pz = getElementPosition(player) local pint = getElementInterior(player) local pdim = getElementDimension(player) for _,v in pairs(getElementsByType("vehicle")) do local vint,vdim = getElementInterior(v),getElementDimension(v) if vint == pint and vdim == pdim then local vx,vy,vz = getElementPosition(v) local dis = getDistanceBetweenPoints3D(px,py,pz,vx,vy,vz) if dis < distance then if dis < lastMinDis then lastMinDis = dis nearestVeh = v end end end end return nearestVeh end function bazkardaneghofl(root) local nearveh = getNearestVehicle(root,20) if nearveh then if getPlayerName(root) == getElementData(nearveh, "owner") or getPlayerName(root) == getElementData(nearveh, "secondkeyowner") then if isVehicleLocked ( nearveh ) then setVehicleLocked ( nearveh, false ) outputChatBox("#00ff00Dar Haye Mashine Shoma Baz Shod!", root, 255, 255, 255, true) triggerClientEvent("sedayedozdgir", resourceRoot, nearveh) setVehicleOverrideLights(nearveh, 2) setTimer(function() setVehicleOverrideLights(nearveh, 1) end, 1000, 1) else setVehicleLocked ( nearveh, true ) outputChatBox("#ff0000Dar Haye Mashine Shoma Ghofl Shod!", root, 255, 255, 255, true) triggerClientEvent("sedayedozdgir", resourceRoot, nearveh) setVehicleOverrideLights(nearveh, 2) setTimer(function() setVehicleOverrideLights(nearveh, 1) end, 1000, 1) end local remote = createObject(1253, 0,0,0) setElementInterior ( remote, getElementInterior(root) ) setElementDimension(remote, getElementDimension ( root ) ) exports.bone_attach:attachElementToBone(remote,root,12,0,0.05,0.05,0,270,0) setPedAnimation( root, "graffiti", "spraycan_fire", -1, false, false ) setTimer( function() setPedAnimation ( root ) destroyElement (remote) end, 800, 1) end end end addEvent("opencar",true) addEventHandler("opencar", root, bazkardaneghofl) function bazkardaneghoflin(root) local theVehicle = getPedOccupiedVehicle ( root ) local playername = getPlayerName(root) if playername == getElementData(theVehicle, "owner") or playename == getElementData(theVehicle, "secondkeyowner") then local posX, posY, posZ = getElementPosition( theVehicle ) for index, toMashine in ipairs( getElementsByType("player") ) do if isPedInVehicle (toMashine) then local yourVehicle = getPedOccupiedVehicle(toMashine) --if theVehicle then if yourVehicle == theVehicle then triggerClientEvent("sedayeghoflin", resourceRoot, toMashine) end end end if isVehicleLocked ( theVehicle ) then setVehicleLocked ( theVehicle, false ) else setVehicleLocked ( theVehicle, true ) end end end addEvent("opencarin",true) addEventHandler("opencarin", root, bazkardaneghoflin) addCommandHandler("sellcar", function ( thePlayer, command) if isPedInVehicle (thePlayer) then local veh = getPedOccupiedVehicle(thePlayer) if getElementData(veh,"owner") and getElementData(veh,"owner") == getPlayerName(thePlayer) then local query = dbQuery(exports.mysql:getMySQLC(), "SELECT * FROM vehicles;" ) local result, numrows = dbPoll(query, dbpTime) if (result and numrows > 0) then setElementData(root,"carsnumber",0) for index, row in pairs(result) do local vID = row['vID'] if vID == getElementData(veh,"vehicleID") then local price = row['vPrice'] local vSlot = row['vSlot'] outputChatBox("#ffff00[Info]: #ffffffAya Mikhahid Mashin Khod Ra Ba Qeymate "..price.."$ Be Server Befroshid?", thePlayer, 255, 255, 255, true) outputChatBox("#ffff00[Info]: #ffffffBaraye Forosh /asell Va Baraye Cancel Kardan Forosh /rsell Bezanid!", thePlayer, 255, 255, 255, true) setElementData(thePlayer,"incarsell",true) setElementData(thePlayer,"Slot",vSlot) setElementData(thePlayer,"SellID",getElementData(veh,"vehicleID")) setElementData(thePlayer,"SellPrice", price) setElementFrozen(veh, true) end end dbFree(query) end else outputChatBox("#ff0000[Error]: #ffffffIn Mashine Shoma Nist!", thePlayer, 255, 255, 255, true) end else outputChatBox("#ff0000[Error]: #ffffffBaraye Inkar Bayad Dakhele Mashin Bashid!", thePlayer, 255, 255, 255, true) end end) addCommandHandler("asell", function ( thePlayer, command) if getElementData(thePlayer,"incarsell") and getElementData(thePlayer,"incarsell") == true then givePlayerMoney ( thePlayer, tonumber(getElementData(thePlayer,"SellPrice")) ) outputChatBox("#00ff00Shoma Ba Movafaghiat Mashin Khod Ra Ba Gheymate: "..tonumber(getElementData(thePlayer,"SellPrice")).."$ Be Server Forokhtid!", thePlayer, 255, 255, 255, true) local Query = dbQuery(exports.mysql:getMySQLC(), "DELETE FROM vehicles WHERE vID = '"..getElementData(thePlayer,"SellID").."';") dbFree(Query) for index, Mashin in ipairs( getElementsByType("vehicle") ) do if getElementData(Mashin,"vehicleID") and getElementData(Mashin,"vehicleID") == getElementData(thePlayer,"SellID") then destroyElement(Mashin) end end setElementData(thePlayer,"incarsell",nil) setElementData(thePlayer,"Slot",nil) setElementData(thePlayer,"SellID",nil) setElementData(thePlayer,"SellPrice", nil) else outputChatBox("#ff0000[Error]: #ffffffShoma Ke Dar Hale Forosh Mashin Nistid!", thePlayer, 255, 255, 255, true) end end) addCommandHandler("rsell", function ( thePlayer, command) if getElementData(thePlayer,"incarsell") and getElementData(thePlayer,"incarsell") == true then outputChatBox("#00ff00[Done]: #ffffffShoma Ba Movafaghiat Foroshe Mashin Ra Rad Kardid!", thePlayer, 255, 255, 255, true) for index, Mashin in ipairs( getElementsByType("vehicle") ) do if getElementData(Mashin,"vehicleID") and getElementData(Mashin,"vehicleID") == getElementData(thePlayer,"SellID") then setElementFrozen(Mashin, false) end end setElementData(thePlayer,"incarsell",nil) setElementData(thePlayer,"Slot",nil) setElementData(thePlayer,"SellID",nil) setElementData(thePlayer,"SellPrice", nil) else outputChatBox("#ff0000[Error]: #ffffffShoma Ke Dar Hale Forosh Mashin Nistid!", thePlayer, 255, 255, 255, true) end end) addCommandHandler("park", function ( thePlayer, command) if isPedInVehicle (thePlayer) then local theVehicle = getPedOccupiedVehicle ( thePlayer ) if getElementData(theVehicle,"owner") == getPlayerName(thePlayer) then local posX, posY, posZ = getElementPosition( theVehicle ) local rotx,roty,rotz = getElementRotation ( theVehicle ) local vID = getElementData(theVehicle,"vehicleID") vehSys:setVehicleData(vID, "vLocationX", posX) vehSys:setVehicleData(vID, "vLocationY", posY) vehSys:setVehicleData(vID, "vLocationZ", posZ) vehSys:setVehicleData(vID, "vRotationZ", rotz) setVehicleRespawnPosition ( theVehicle, posX, posY, posZ, rotx, roty, rotz ) outputChatBox("#00ff00[Done]: #ffffffMashin Shoma Ba Movafaqiat Dar Inja Park Shod!", thePlayer, 255, 255, 255, true) else outputChatBox("#ff0000[Error]: #ffffffInke In Mashine Shoma Nist", thePlayer, 255, 255, 255, true) end else outputChatBox("#ff0000[Error]: #ffffffBaraye Inkar Bayad Dakhele Mashin Bashid", thePlayer, 255, 255, 255, true) end end) function isVehicleEmpty( vehicle ) if not isElement( vehicle ) or getElementType( vehicle ) ~= "vehicle" then return true end local passengers = getVehicleMaxPassengers( vehicle ) if type( passengers ) == 'number' then for seat = 0, passengers do if getVehicleOccupant( vehicle, seat ) then return false end end end return true end addCommandHandler("towcar", function ( thePlayer, command, car) if car then for index, Mashin in ipairs( getElementsByType("vehicle") ) do if getElementData(Mashin,"owner") and getElementData(Mashin,"owner") == getPlayerName(thePlayer) then if tonumber(getElementData(Mashin,"vehicleSlot")) == tonumber(car) then if isVehicleEmpty(Mashin) then if getPlayerMoney(thePlayer) < 1000 then outputChatBox ( "#ff0000Baraye Inkar Bayad 1000$ Pool Dashte Bashid!", thePlayer, 230,0,0 ,true) return false else respawnVehicle(Mashin) outputChatBox ( "#00ff00Mashine "..car.." Shoma Tow Shod! Hazine : 1000$", thePlayer, 230,0,0 ,true) takePlayerMoney(thePlayer,1000) return true end else outputChatBox ( "#ff0000Mashine "..car.." Shoma Dar Hale Estefade Ast!", thePlayer, 230,0,0 ,true) return false end end end end outputChatBox ( "#ff0000Shoma Mashine "..car.." Nadarid!!", thePlayer, 230,0,0 ,true) return false else outputChatBox("#ffff00SYNTAX: /towcar [CarID]", thePlayer, 255, 22, 22, true) end end) function savaremashineghoflmishe ( thePlayer, seat, jacked ) if isVehicleLocked(source) then cancelEvent() outputChatBox ( "#ff0000Ghofle!", thePlayer, 230,0,0 ,true) end end addEventHandler ( "onVehicleStartEnter", getRootElement(), savaremashineghoflmishe ) addCommandHandler("givekey", function ( thePlayer, command, player, car) if player then local find = miscSys:findPlayer(player) if find then if car then for index, Mashin in ipairs( getElementsByType("vehicle") ) do if getElementData(Mashin,"owner") and getElementData(Mashin,"owner") == getPlayerName(thePlayer) then if tonumber(getElementData(Mashin,"vehicleSlot")) == tonumber(car) then setElementData(Mashin,"secondkeyowner",getPlayerName(find)) outputChatBox("#00ff00[Done]: #ffffffShoma Kelid Mashine "..car.." Khod Ra Be Player #ffff00"..getPlayerName(find).."#ffffff Dadid!", thePlayer, 255, 255, 255, true) outputChatBox("#ffffff[Info]: #ffffffPlayer #ffff00"..getPlayerName(thePlayer).."#ffffff Kelid Mashine "..car.." Khod Ra Be Shoma Dad!", find, 255, 255, 255, true) return true end end end outputChatBox ( "#ff0000Shoma Mashine "..car.." Nadarid!!", thePlayer, 230,0,0 ,true) return false else outputChatBox("#ffff00SYNTAX: /givekey [ID Or PartOfName] [CarID]", thePlayer, 255, 22, 22, true) end else outputChatBox("#ffff00Player Peyda Nashod!", thePlayer, 255, 22, 22, true) end else outputChatBox("#ffff00SYNTAX: /givekey [ID Or PartOfName] [CarID]", thePlayer, 255, 22, 22, true) end end) addCommandHandler("carinfo", function(thePlayer, cmd) local query = dbQuery(exports.mysql:getMySQLC(), "SELECT * FROM vehicles;" ) local result, numrows = dbPoll(query, dbpTime) if (result and numrows > 0) then setElementData(thePlayer,"carsnumber",0) for index, row in pairs(result) do local owner = row['vOwner'] if owner == getPlayerName(thePlayer) then local chanta = getElementData(thePlayer,"carsnumber") local chantabadi = tonumber(chanta) + 1 setElementData(thePlayer,"carsnumber",chantabadi) end end dbFree(query) local query = dbQuery(exports.mysql:getMySQLC(), "SELECT * FROM vehicles;" ) local Salam, khodafez = dbPoll(query, dbpTime) if (Salam and khodafez > 0) then setElementData(thePlayer,"carsnumber",0) for index, row in pairs(Salam) do local owner = row['vOwner'] if owner == getPlayerName(thePlayer) then local chanta2 = getElementData(thePlayer,"carsnumber") local chantabadi2 = tonumber(chanta2) + 1 setElementData(thePlayer,"carsnumber",chantabadi2) local model = row['vModel'] local vehname = getVehicleNameFromModel(model) local plate = row['vPlate'] local price = row['vPrice'] local benzin = row['vFuel'] if model == 411 then vehname = "Progen T20" elseif model == 522 then vehname = "Pegassi Bati 801" elseif model == 461 then vehname = "Honda CG-125" elseif model == 507 then vehname = "Benz CLS" elseif model == 587 then vehname = "Genesis Coup" elseif model == 503 then vehname = "Lamborghini Aventador" elseif model == 526 then vehname = "Renault Trezor" elseif model == 559 then vehname = "BMW i8" elseif model == 506 then vehname = "Ford Mustang GT" elseif model == 527 then vehname = "Pegassi Zentorno" elseif model == 429 then vehname = "Dodge Viper" elseif model == 402 then vehname = "Nissan GT-R R35" elseif model == 579 then vehname = "Enus" elseif model == 494 then vehname = "Chevrolet Corvette" elseif model == 412 then vehname = "BMW GTR M3" elseif model == 480 then vehname = "Honda S2000" elseif model == 415 then vehname = "Aston Martin Vantage" elseif model == 602 then vehname = "Bugatti Veyron" end outputChatBox("#00ff00Khodro Shomare #ff0000"..chantabadi2, thePlayer, 255, 255, 255, true) outputChatBox("#ffffffModel: #00ff00"..vehname.." #ffffff| Pelak: #00ff00"..plate.." #ffffff| Benzin: #00ff00"..benzin.."% #ffffff| Gheymat: #00ff00$"..convertNumber(price), thePlayer, 255, 255, 255, true) outputChatBox("--------------------------------------------", thePlayer, 255, 255, 255, true) end end end dbFree(query) setElementData(thePlayer,"carsnumber",nil) end end ) addCommandHandler("myvehs", function(thePlayer, cmd) local query = dbQuery(exports.mysql:getMySQLC(), "SELECT * FROM vehicles;" ) local result, numrows = dbPoll(query, dbpTime) if (result and numrows > 0) then setElementData(thePlayer,"carsnumber",0) for index, row in pairs(result) do local owner = row['vOwner'] if owner == getPlayerName(thePlayer) then local chanta = getElementData(thePlayer,"carsnumber") local chantabadi = tonumber(chanta) + 1 setElementData(thePlayer,"carsnumber",chantabadi) end end dbFree(query) outputChatBox("#ff0000[My-Vehs]:#ffffff Slot Veh Shoma: #ff0000"..getElementData(accSys:getPlayerAcc(thePlayer), "pSlot").." #ffffffTedad Mashin Haye Shoma : #ff0000"..getElementData(thePlayer,"carsnumber").."", thePlayer, 255, 255, 255, true) local query = dbQuery(exports.mysql:getMySQLC(), "SELECT * FROM vehicles;" ) local Salam, khodafez = dbPoll(query, dbpTime) if (Salam and khodafez > 0) then setElementData(thePlayer,"carsnumber",0) for index, row in pairs(Salam) do local owner = row['vOwner'] if owner == getPlayerName(thePlayer) then local chanta2 = getElementData(thePlayer,"carsnumber") local chantabadi2 = tonumber(chanta2) + 1 setElementData(thePlayer,"carsnumber",chantabadi2) local model = row['vModel'] local plate = row['vPlate'] local slot = row['vSlot'] outputChatBox("#ff0000["..chantabadi2.."]:#ffffff Vehicle Model : #ff0000"..model.." #ffffffVehicle Slot : #ff0000"..slot.." #ffffffVehicle Plate : #ff0000"..plate.."", thePlayer, 255, 255, 255, true) end end end dbFree(query) setElementData(thePlayer,"carsnumber",nil) end end ) local miscSys = exports["misc"] addCommandHandler("giveslot", function ( thePlayer, command, player, tedad ) if tonumber(getElementData(accSys:getPlayerAcc(thePlayer), "pAdmin")) < 8 then outputChatBox("#33AA33Error: Motasefane dastresi be in dastoor baraye shoma maghdoor nist.", thePlayer, 255, 255, 255, true) return false end local find = miscSys:findPlayer ( player ) if find then local targetPlayer = getPlayerName ( find ) local tedad = tonumber(tedad) local pSlot = getElementData(accSys:getPlayerAcc(find), "pSlot") setElementData(accSys:getPlayerAcc(find), "pSlot", tonumber(pSlot) + tonumber(tedad)) outputChatBox("#ff0000[ADM-Enix]:#ffffff Admin #ff0000"..getPlayerName(thePlayer).." #ffffffBe Shoma Tedad "..tedad.." Slot Mashin Dad!", find, 255, 255, 255, true) outputChatBox("#00ff00[Done]:#ffffff Shoma Be #ff0000"..getPlayerName(find).." #ffffff Tedad "..tedad.." Slot Mashin Dadid!", thePlayer, 255, 255, 255, true) outputDebugString("Admin "..getPlayerName(thePlayer).." Be Player "..targetPlayer.." Meghdar "..tedad.." Slot Mashin Dad!") else outputChatBox("#ff0000[Error]:#ffffffChenin Playeri Peyda Nashod!", thePlayer, 0, 255, 0,true) end end) function deleteveh () saveBenzin(source) end addEventHandler ( "onPlayerQuit", root, deleteveh ) function saveBenzin(root) local selfname = getPlayerName(root) for index, Mashin in ipairs( getElementsByType("vehicle") ) do if Mashin then if getElementData(Mashin, "owner") == selfname then destroyElement(Mashin) end end end end addEventHandler("OnGlobalTimer", root, function () for index, Mashin in ipairs( getElementsByType("vehicle") ) do if Mashin then if getElementData(Mashin,"vehicleID") then local vID = getElementData(Mashin,"vehicleID") local vFuel = getElementData(Mashin,"fuel") local myQH = dbQuery(exports.mysql:getMySQLC(), "UPDATE `vehicles` SET `vFuel` = '"..vFuel.."' WHERE `vID` = '"..vID.."'") dbFree(myQH) end end end end) function carHelpCMD (thePlayer, command) outputChatBox("#00ff00[Car-Help]: #ff0000/sellcar #00ff00Baraye Forokhtan Mashin Be Server", thePlayer, 255, 255, 255, true) outputChatBox("#00ff00[Car-Help]: #ff0000/asell #00ff00Baraye Ghabol Kardan Darkhast Forosh Mashin Be Sever", thePlayer, 255, 255, 255, true) outputChatBox("#00ff00[Car-Help]: #ff0000/rsell #00ff00Baraye Rad Kardan Darkhast Forosh Mashin Be Sever", thePlayer, 255, 255, 255, true) outputChatBox("#00ff00[Car-Help]: #ff0000/park #00ff00Baraye Park Kardan Mashin", thePlayer, 255, 255, 255, true) outputChatBox("#00ff00[Car-Help]: #ff0000/towcar #00ff00Baraye Tow Kardan Mashin", thePlayer, 255, 255, 255, true) outputChatBox("#00ff00[Car-Help]: #ff0000/givekey #00ff00Baraye Dadan Kelid Mashin Be Digaran", thePlayer, 255, 255, 255, true) outputChatBox("#00ff00[Car-Help]: #ff0000/carinfo #00ff00Baraye Didan Moshakhasat Va Mashin Ha", thePlayer, 255, 255, 255, true) outputChatBox("#00ff00[Car-Help]: #ff0000/myvehs #00ff00Baraye Didan Tedad Slot Haye Khodro", thePlayer, 255, 255, 255, true) end addCommandHandler("carhelp", carHelpCMD) 29 minutes ago, Avival said: setTimer( function() SortPlayerVehiclesID(thePlayer) end, 7000, 1) else outputChatBox("#ff0000Shoma Dar Hale Hazer "..tostring(getElementData(root,"carsnumber")).." Mashin Darid!", root, 255, 255, 255, true) setElementData(root,"carsnumber",nil) end else outputChatBox("#ff0000Shoma Poole Kafi Nadarid!", root, 255, 255, 255, true) end end please help me
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