Sider Posted August 27, 2017 Share Posted August 27, 2017 Üdv. Elkezdtem irni egy vehicle-systemet es amikor ujra inditom a resourcet akkor ugye lekene menteni ujbol az adatokat hogy a kocsihozz kosse. Bovebben, sql -bol kene a kocsihoz kotni egy id-t de nincs ra otletem igy oldottam meg amikor elkeszitem az autot. if isElement(cars) then local vehicleQuery = dbQuery(connect,"INSERT INTO vehicle SET owner= ? , type = ? , r=?, g=? , b=?, x= ? ,y = ? ,z = ? ", owner, vehicleModel, r,g,b,px,py,pz) local vehicleQueryResult, _, beszurtID = dbPoll(vehicleQuery, -1) if vehicleQueryResult then setElementData(cars, "kocsi:id", beszurtID) local kocsiID = getElementData(cars, "kocsi:id") for k,v in ipairs(result) do if v["id"] == tonumber(owner) then owner_name = v["charname"]:gsub("_", " ") owner_id = v["id"] setElementData(cars, "kocsi:owner", owner_name) setElementData(cars, "kocsi:owner:id",owner_id) end end end end Ilyesmivel probalkoztam.(nem jott be) function res_resource(resource) local qh_v = dbQuery(connect, "SELECT * FROM vehicle") local result_v = dbPoll(qh_v,-1) for k,v in pairs(result_v) do local car = createVehicle(v["type"],v["sx"],v["sy"],v["sz"]) local color = setVehicleColor(car,v["r"],v["g"],v["b"]) if isElement(car) then local vehicleQueryResult, _, beszurtID = dbPoll(result_v[k], -1) if vehicleQueryResult then setElementData(cars, "kocsi:id", beszurtID) local kocsiID = getElementData(cars, "kocsi:id") outputChatBox(tostring(kocsiID),source) end end end end addEventHandler("onResourceStart", root , res_resource) Link to comment
Sider Posted August 27, 2017 Author Share Posted August 27, 2017 function res_resource(resource) if resource ~= getThisResource() then return end local qh_v = dbQuery(connect, "SELECT * FROM vehicle") local result_v = dbPoll(qh_v,-1) local qh = dbQuery(connect, "SELECT * FROM characters") local result = dbPoll(qh,-1) for k,v in ipairs(result_v) do local model,x,y,z,r,g,b = v["type"], v["sx"],v["sy"],v["sz"], v["r"], v["g"], v["b"] local car = createVehicle(model,x,y,z) local color = setVehicleColor(car, r,g,b) local vehicle_id,owner = v["ID"], v["owner"] if isElement(car) then setElementData(car, "kocsi:id",vehicle_id) setElementData(car, "kocsi:owner:id",owner) for i,j in ipairs(result) do if tonumber(getElementData(car, "kocsi:owner:id")) == tonumber(j["id"]) then setElementData(car, "owner:name", j["charname"]) end end outputChatBox(tostring(getElementData(car,"kocsi:id"))) end end end addEventHandler("onResourceStart", root , res_resource) MEGOLDVA! Link to comment
WorthlessCynomys Posted September 2, 2017 Share Posted September 2, 2017 Hello. Láttam megoldottad. De legközlebbre, ha használod a KÓD funkciót akkor sokkal hatékonyabb. A "<>" jel az. Sokkal másabb ez: function Lol() outputChatBox("Józsi") end mint ez: function Lol() outputChatBox("Józsi") end 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