GTA San Posted April 2, 2018 Share Posted April 2, 2018 السلام عليكم كيفكم هذا كوود استخدمة ولكن الفلوس وهمية ابيها داتا لاهنتم حاولت شوية ماضبطت function getFreeID() local result = dbPoll(dbQuery(db, "SELECT ID FROM VehicleList ORDER BY ID ASC"), -1) newID = false for i, id in pairs (result) do if id["ID"] ~= i then newID = i break end end if newID then return newID else return #result + 1 end end function getVehicleByID(id) v = false for i, veh in ipairs (getElementsByType("vehicle")) do if getElementData(veh, "ID") == id then v = veh break end end return v end function updateVehicleInfo(player) if isElement(player) then local result = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(player))), -1) if type(result) == "table" then setElementData(player, "VehicleInfo", result) end end end addEventHandler("onResourceStart", resourceRoot, function() db = dbConnect("sqlite", "database.db") dbExec(db, "CREATE TABLE IF NOT EXISTS VehicleList (ID, Account, Model, X, Y, Z, RotZ, Colors, Upgrades, Paintjob, Cost, HP)") for i, player in ipairs(getElementsByType("player")) do updateVehicleInfo(player) end end) addEvent("onOpenGui", true) addEventHandler("onOpenGui", root, function() updateVehicleInfo(source) end) function destroyVehicle(theVehicle) if isElement(theVehicle) then local Owner = getElementData(theVehicle, "Owner") if Owner then local x, y, z = getElementPosition(theVehicle) local _, _, rz = getElementRotation(theVehicle) local r1, g1, b1, r2, g2, b2 = getVehicleColor(theVehicle, true) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 upgrade = "" for _, upgradee in ipairs (getVehicleUpgrades(theVehicle)) do if upgrade == "" then upgrade = upgradee else upgrade = upgrade..","..upgradee end end local Paintjob = getVehiclePaintjob(theVehicle) or 3 local id = getElementData(theVehicle, "ID") dbExec(db, "UPDATE VehicleList SET X = ?, Y = ?, Z = ?, RotZ = ?, HP = ?, Colors = ?, Upgrades = ?, Paintjob = ? WHERE Account = ? AND ID = ?", x, y, z, rz, getElementHealth(theVehicle), color, upgrade, Paintjob, getAccountName(getPlayerAccount(Owner)), id) updateVehicleInfo(Owner) local attached = getAttachedElements(theVehicle) if (attached) then for k,element in ipairs(attached) do if getElementType(element) == "blip" then destroyElement(element) end end end end destroyElement(theVehicle) end end addEvent("onBuyNewVehicle", true) addEventHandler("onBuyNewVehicle", root, function(Model, cost, r1, g1, b1, r2, g2, b2) abc = false local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(source))), -1) for i, data in ipairs (data) do if data["Model"] == Model then abc = true break end end if #data >= 5 then outputChatBox("[G4A] نائسف احد الاقصا للسيارات هو [5] ", source, 38, 122, 216, true) return end if abc then outputChatBox("[G4A] هذه المركبه موجوده من قبل", source, 38, 122, 216, true) return end if getPlayerMoney(source) >= tonumber(cost) then takePlayerMoney ( source, cost ) local x, y, z = getElementPosition(source) local _, _, rz = getElementRotation(source) local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 vehicle = createVehicle(Model, x-5, y+5, z, 0, 0, rz) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) setElementData(vehicle, "Owner", source) local NewID = getFreeID() setElementData(vehicle, "ID", NewID) dbExec(db, "INSERT INTO VehicleList VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", NewID, getAccountName(getPlayerAccount(source)), Model, x-5, y+5, z, rz, color, "", 3, cost, 1000) outputChatBox("[Vehicle System] #FFFF00انت اشتريت: #00FFFF"..getVehicleNameFromModel(Model), source, 38, 122, 216, true) outputChatBox("[Vehicle System] #FFFF00مبلغ: #00FF00$"..cost, source, 38, 122, 216, true) updateVehicleInfo(source) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 50, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) else outputChatBox("[G4A] ليس لديك فلوس ", source, 38, 122, 216, true) end end) vv = {} addEvent("SpawnMyVehicle", true) addEventHandler("SpawnMyVehicle", root, function(id) local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then if getVehicleByID(id) then outputChatBox(" [G4A] #58FAF4 مركبتك ظاهره بالفعل !!", source, 38, 122, 216, true) else local color = split(data[1]["Colors"], ',') r1 = color[1] or 255 g1 = color[2] or 255 b1 = color[3] or 255 r2 = color[4] or 255 g2 = color[5] or 255 b2 = color[6] or 255 vehicle = createVehicle(data[1]["Model"], data[1]["X"], data[1]["Y"], data[1]["Z"], 0, 0, data[1]["RotZ"]) setElementData(vehicle, "ID", id) local upd = split(tostring(data[1]["Upgrades"]), ',') for i, upgrade in ipairs(upd) do addVehicleUpgrade(vehicle, upgrade) end local Paintjob = data[1]["Paintjob"] or 3 setVehiclePaintjob(vehicle, Paintjob) setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) if data[1]["HP"] <= 255.5 then data[1]["HP"] = 255 end setElementHealth(vehicle, data[1]["HP"]) setElementData(vehicle, "Owner", source) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 50, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) outputChatBox("[G4A] #58FAF4 تم اظهار مركبتك ", source, 38, 122, 216, true) end else outputChatBox("[G4A] قد تكون هذه مشكله كلم الادمن ", source, 38, 122, 216, true) end end) addEvent("DestroyMyVehicle", true) addEventHandler("DestroyMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then destroyVehicle(vehicle) outputChatBox ("[G4A] #58FAF4 تم اخفاء مركبتك ", source, 38, 122, 216, true) else outputChatBox("[G4A] اختر المركبه التي تريد اخفائها !! ", source, 38, 122, 216, true) end else outputChatBox("[G4A] هذه المركبه ليست ظاهرة", source, 38, 122, 216, true) end end) addEvent("LightsMyVehicle", true) addEventHandler("LightsMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then local Vehicle = getPedOccupiedVehicle(source) if Vehicle == vehicle then if getVehicleOverrideLights(vehicle) ~= 2 then setVehicleOverrideLights(vehicle, 2) outputChatBox("[G4A] #58FAF4 تم تشغيل النوار المركبة ", source, 38, 122, 216, true) elseif getVehicleOverrideLights(vehicle) ~= 1 then setVehicleOverrideLights(vehicle, 1) outputChatBox("[G4A] #58FAF4 تم اقاف تشغيل انلوار المركبة ", source, 38, 122, 216, true) end else outputChatBox("[G4A] #FF0000 انت لست بداخل المركبه ", source, 38, 122, 216, true) end else outputChatBox("[[G4A] #58FAF4 مركبتك ليست ظاهره ", source, 38, 122, 216, true) end end) addEvent("LockMyVehicle", true) addEventHandler("LockMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then if not isVehicleLocked(vehicle) then setVehicleLocked(vehicle, true) setVehicleDoorsUndamageable(vehicle, true) setVehicleDoorState(vehicle, 0, 0) setVehicleDoorState(vehicle, 1, 0) setVehicleDoorState(vehicle, 2, 0) setVehicleDoorState(vehicle, 3, 0) outputChatBox("[G4A] #58FAF4 تم اقفال المركبة ", source, 38, 122, 216, true) elseif isVehicleLocked(vehicle) then setVehicleLocked(vehicle, false) setVehicleDoorsUndamageable(vehicle, false) outputChatBox("[G4A] #58FAF4 تم فتح قفل مركبتك ", source, 38, 122, 216, true) end else outputChatBox("[G4A] #58FAF4 مركبتك ليست ظاهرة ", source, 38, 122, 216, true) end end) addEvent("BlipMyVehicle", true) addEventHandler("BlipMyVehicle", root, function(id) local vehicle = getVehicleByID(id) if isElement(vehicle) then if not getElementData(vehicle, "ABlip") then setElementData(vehicle, "ABlip", true) createBlipAttachedTo(vehicle, 41, 2, 255, 0, 0, 255, 0, 65535, source) outputChatBox("[G4A] #58FAF4 تم تحديد مكان مركبتك", source, 38, 122, 216, true) else local attached = getAttachedElements(vehicle) if (attached) then for k,element in ipairs(attached) do if getElementType(element) == "blip" then destroyElement(element) end end end setElementData(vehicle, "ABlip", false) outputChatBox("[G4A] #58FAF4 تم الغاء تحديد مكان مركبتك ", source, 38, 122, 216, true) end else outputChatBox("[G4A]#58FAF4 سيارتك ليست ظاهره ", source, 38, 122, 216, true) end end) addEvent("FixMyVehicle", true) addEventHandler("FixMyVehicle", root, function(id) if getElementData(source, "Oil") >= tonumber(20) then setElementData(source, "Oil", (getElementData(source, "Oil") or 0) - 20) local vehicle = getVehicleByID(id) if isElement(vehicle) then fixVehicle(vehicle) setVehicleEngineState(vehicle, true) if isVehicleDamageProof(vehicle) then setVehicleDamageProof(vehicle, false) end end dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND ID = ?", 1000, getAccountName(getPlayerAccount(source)), id) updateVehicleInfo(source) outputChatBox ("[G4A] #58FAF4 تتم اصلاح المركبة بنجاح", source, 38, 122, 216, true) else outputChatBox("[G4A] #FF0000 ليس لديك النفط الكافي", source, 38, 122, 216, true) end end) addEvent("WarpMyVehicle", true) addEventHandler("WarpMyVehicle", root, function(id) if not isPedInVehicle (source) then if getElementInterior(source) == 0 then if getPlayerMoney(source) >= tonumber(5000) then local vehicle = getVehicleByID(id) if isElement(vehicle) then takePlayerMoney ( source, 5000 ) local x, y, z = getElementPosition(source) setElementPosition(vehicle, x+3, y+2, z+1.5) outputChatBox ("[G4A] #58FAF4 تم سحب المركبة ", source, 38, 122, 216, true) else outputChatBox("[G4A] #58FAF4 المركبة ليست ظاهرة ", source, 38, 122, 216, true) end else outputChatBox("[G4A] #FF0000 لا يوجد مال لسحبها ", source, 38, 122, 216, true) end else outputChatBox("[G4A]#FF0000 انت بداخل المركبة لا يمكن سحبها !!! ", source, 38, 122, 216, true) end else outputChatBox("[G4A] #FF0000 لا تسطتطيع سحب المركبة اخرج منها ", source, 38, 122, 216, true) end end) addEvent("SellMyVehicle", true) addEventHandler("SellMyVehicle", root, function(id) local vehicle = getVehicleByID(id) local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id), -1) if type(data) == "table" and #data ~= 0 then local Money = math.ceil((data[1]["Cost"]*.9)*math.floor(data[1]["HP"])/100/10) givePlayerMoney (source, Money) if isElement(vehicle) then destroyElement(vehicle) end dbExec(db, "DELETE FROM VehicleList WHERE Account = ? AND ID = ?", getAccountName(getPlayerAccount(source)), id) updateVehicleInfo(source) outputChatBox(" #00FF00 تم بيع السياره بسعر $"..Money, source, 38, 122, 216, true) end end) function getDataOnLogin(_, account) updateVehicleInfo(source) end addEventHandler("onPlayerLogin", root, getDataOnLogin) function SaveVehicleDataOnQuit() for i, veh in ipairs (getElementsByType("vehicle")) do if getElementData(veh, "Owner") == source then destroyVehicle(veh) end end end addEventHandler("onPlayerQuit", root,SaveVehicleDataOnQuit) Link to comment
Abdul KariM Posted April 2, 2018 Share Posted April 2, 2018 حط الوظيفتين بأعلى الملف وغير اسم الداتا لاسم الداتا الموجوود عندك function getPlayerMoney ( player ) if ( player and getElementType ( player ) == "player" ) then return getElementData ( player , "money" ) or 0 end end function takePlayerMoney ( player , amount ) if ( player and getElementType ( player ) == "player" and type ( amount ) == "number" ) then local playerMoney = getPlayerMoney ( player ) setElementData ( player , "money" , playerMoney - amount ) return true end end Link to comment
GTA San Posted April 2, 2018 Author Share Posted April 2, 2018 شكككرا جزيلأأ اخي ابا كريم يعمل اخي دابل كنت اريد الاموال شكرا لك Link to comment
GTA San Posted April 2, 2018 Author Share Posted April 2, 2018 في مشكلة اقدر سحب سيارة بفلوس داتا بس ماقدر اشتري سيارة يقولي فلوس وهمية Link to comment
GTA San Posted April 2, 2018 Author Share Posted April 2, 2018 ألمشكلة لا شريت مايسحب فلوس Link to comment
Me[Z]oO Posted April 3, 2018 Share Posted April 3, 2018 function getPlayerMoney ( player ) if ( player and getElementType ( player ) == "player" ) then return getElementData ( player , "Money" ) or 0 end end function takePlayerMoney ( player , amount ) if ( player and getElementType ( player ) == "player" and type ( amount ) == "number" ) then local playerMoney = getPlayerMoney ( player ) setElementData ( player , "Money" , playerMoney - amount ) return true end end لو سيرفرك حرب عصابات الداتا Money وليست money Link to comment
Abdul KariM Posted April 3, 2018 Share Posted April 3, 2018 @gta-gta العفو , قايل لك غير اسم الداتا انا حاط اسم من عندي 1 Link to comment
GTA San Posted April 3, 2018 Author Share Posted April 3, 2018 سويت اسم الداتا بس لاشريت السيارمايسحب فلوس 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