MarvelSK Posted May 20, 2016 Share Posted May 20, 2016 Hello I need help, I download script "Gielda samochodowa" it is vehicle shop of player cars and it is not working local sw,sh = guiGetScreenSize() local gieldaMarker = createMarker( -1892.845703125,-857.79699707031,32.0234375, "cylinder" ,5, 0, 71,255,40 ) local strefa = createColSphere ( -1896.7279052734,-858.39862060547,31.440845489502 , 5, 4.5, 2) local cuboid=createMarker( -1896.7279052734,-858.39862060547,31.440845489502, "cylinder" ,11, 25, 111,25,0) local koniec = createMarker(-1896.7279052734,-858.39862060547,31.440845489502, "cylinder", 0.01, 255, 0, 255, 0) buttonWystaw = guiCreateButton(620/1440*sw, 479/900*sh, 264/1440*sw, 94/900*sh, "Set vehicle price!", false) editWystaw = guiCreateEdit(613/1440*sw, 383/900*sh, 278/1440*sw, 64/900*sh, "", false) guiSetVisible(buttonWystaw, false) guiSetVisible(editWystaw, false) function dxPokaz() dxDrawRectangle(600/1440*sw, 284/900*sh, 306/1440*sw, 310/900*sh, tocolor(0, 0, 0, 198), false) dxDrawRectangle(600/1440*sw, 284/900*sh, 306/1440*sw, 28/900*sh, tocolor(0, 76, 255, 207), false) dxDrawText("RealLife 4.7!", 62/1440*sw, 310/900*sh, 1440/1440*sw, 284/900*sh, tocolor(255, 255, 255, 255), 1.00, "pricedown", "center", "center", false, false, false, false, false) dxDrawText("Enter the price of the car you're interested in what \n(minimum €500)", 65/1440*sw, 284/900*sh, 1427/1440*sw, 377/900*sh, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Enter the price of the car you're interested in what \n(minimum €500)", 70/1440*sw, 282/900*sh, 1427/1440*sw, 375/900*sh, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Enter the price of the car you're interested in what \n(minimum €500)", 70/1440*sw, 284/900*sh, 1425/1440*sw, 377/900*sh, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Enter the price of the car you're interested in what \n(minimum €500)", 70/1440*sw, 282/900*sh, 1425/1440*sw, 375/900*sh, tocolor(0, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, true, false) dxDrawText("Enter the price of the car you're interested in what \n(minimum €500)", 70/1440*sw, 283/900*sh, 1426/1440*sw, 376/900*sh, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, true, false) end addEventHandler("onClientMarkerLeave", gieldaMarker, function(el, md) if el ~= localPlayer then return end if guiGetVisible(buttonWystaw) == true then guiSetVisible(buttonWystaw, false) guiSetVisible(editWystaw, false) showCursor(false) removeEventHandler('onClientRender', root, dxPokaz) end end) addEventHandler('onClientMarkerHit', gieldaMarker, function(hitElement, matchingDimension) if hitElement ~= getLocalPlayer() then return end if getPedOccupiedVehicle ( hitElement ) then local pojazdy = getElementsWithinColShape(strefa,"vehicle") if #pojazdy>40 then outputChatBox("The stock market is 40 cars. Wait until it is free place") return end guiSetVisible(buttonWystaw, true) guiSetVisible(editWystaw, true) showCursor(true, false) addEventHandler("onClientRender", root, dxPokaz) end end) function wystaw( ) local cenaPobierz = guiGetText ( editWystaw ) local cena = tonumber(cenaPobierz) local pojazd = getPedOccupiedVehicle(localPlayer) local car = getVehicleName(pojazd) local owner = getElementData(pojazd, "car_owner") local id = getElementData(pojazd, "car_id") if cena >499 then --triggerServerEvent ( "wystawEvent", resourceRoot, pojazd, cena, wlasciciel, id) setElementData(pojazd,"pojazd_opis","------------------\nVehicle: "..car.."\nPrice: "..cena.."$\nOwner: "..owner.."\nID Vehicle: "..id.."\n------------------" ) --"Cena: "..cena.."$\nSprzedający: "..owner.."\nID Pojazdu: "..id.."" ) else --jesli cena to nie 750 outputChatBox("* Minimum price is 500€!") end end addEventHandler ( "onClientGUIClick", buttonWystaw , wystaw ) --33 addEventHandler('onClientMarkerHit', cuboid, function(el,md) if not md or el ~= localPlayer then return end if wstep then return end wstep=true end) addEventHandler("onClientMarkerHit", cuboid, function(el,md) if not md or el ~= localPlayer then return end if not wstep then return end local veh=getPedOccupiedVehicle(el) if not veh then return end setElementData(veh,"pojazd_opis",false) end) And my vehiclesystem with ID "zapisz_aut" --[[ Ten plik zawiera: * tworzenie aut przy uruchomieniu skryptu * laczenie sie z baza SQL Lite * zapis danych aut co 15 min i przy wylaczeniu skryptu * komende dla administratora sluzaca zapisowi aut * funkcje blokujaca wejscie do auta jesli nie jestesmy jego wlascicieleme --]] handler = dbConnect("sqlite", "pojazdy.db") --pojazdy dbExec(handler, "CREATE TABLE IF NOT EXISTS pojazdy (id INTEGER PRIMARY KEY AUTOINCREMENT, wlasciciel TEXT, model INTEGER, x FLOAT, y FLOAT, z FLOAT, rot FLOAT, ca INTEGER, cb INTEGER, cc INTEGER, przebieg FLOAT, paliwo FLOAT)") dbExec(handler, "CREATE UNIQUE INDEX IF NOT EXISTS IDX_id on pojazdy(id)") --tuning dbExec(handler, "CREATE TABLE IF NOT EXISTS tuning (id INTEGER, t0 INTEGER, t1 INTEGER, t2 INTEGER, t3 INTEGER, t4 INTEGER, t5 INTEGER, t6 INTEGER, t7 INTEGER, t8 INTEGER, t9 INTEGER, t10 INTEGER, t11 INTEGER, t12 INTEGER, t13 INTEGER, t14 INTEGER, t15 INTEGER, t16 INTEGER, paintjob INTEGER, hr INTEGER, hg INTEGER, hb INTEGER)") dbExec(handler, "CREATE UNIQUE INDEX IF NOT EXISTS IDX_id on tuning(id)") function onStartLoadVehicles() local query = dbQuery(handler, "SELECT * FROM pojazdy") local result, num_rows, errormsg = dbPoll (query, -1) for i,v in pairs(result) do local veh = createVehicle(v["model"], v["x"], v["y"], v["z"]) setElementRotation(veh, 0, 0, v["rot"]) setVehicleColor(veh, v["ca"], v["cb"], v["cc"]) ustawDanePojazdu(veh, v["id"], v["wlasciciel"]) --ustawiam paliwo i przebieg setElementData(veh, "pojazd_paliwo", v["paliwo"] or 50) setElementData(veh, "pojazd_przebieg", v["przebieg"] or 0) --<< na koncu -->> local query = dbQuery(handler, "SELECT * FROM tuning WHERE id='"..v["id"].."'") local result, num_rows, errormsg = dbPoll (query, -1) setVehiclePaintjob(veh, result[1].paintjob) setVehicleHeadLightColor(veh, result[1].hr, result[1].hg, result[1].hb) for i,v in pairs(result) do for ii, vv in pairs(v) do if (ii ~= "id" and ii ~= "paintjob" and ii ~= "hr" and ii ~= "hg" and ii ~= "hb") then local vv = tonumber(vv) if vv ~= 0 then addVehicleUpgrade(veh, vv) end end end end end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), onStartLoadVehicles) function ustawDanePojazdu(veh, id, wlasciciel) --id = INT, wlasciciel = STRING setElementData(veh, "car_id", id) setElementData(veh, "car_owner", wlasciciel) end function onVehicleStartEnter(player, seat, jacked) if seat == 0 then local car_owner = getElementData(source, "car_owner") if car_owner then local account = getPlayerAccount(player) if account then local name = getAccountName(account) if car_owner == name then --mamy prawo wejscia do auta prawo_ = true end end if prawo_ then --wchodzim prawo_ = false else --sio outputChatBox("You haven´t got a keys from this vehicle.", player, 255, 255, 255, true) cancelEvent() end end end end addEventHandler ("onVehicleStartEnter", resourceRoot, onVehicleStartEnter) --<> function zapiszPojazdy() for i,v in pairs(getElementsByType("vehicle")) do local id = getElementData(v, "car_id") if id then local owner = getElementData(v, "car_owner") local x, y, z = getElementPosition(v) local _, _, rot = getElementRotation(v) local color1, color2, color3, color4 = getVehicleColor(v, true) local paliwo = getElementData(v, "pojazd_paliwo") local przebieg = getElementData(v, "pojazd_przebieg") dbExec(handler, "UPDATE pojazdy SET x='"..x.."', y='"..y.."', z='"..z.."', rot='"..rot.."', ca='"..color1.."', cb='"..color2.."', cc='"..color3.."', przebieg='"..przebieg.."', paliwo='"..paliwo.."' WHERE id='"..id.."'") local paintjob = getVehiclePaintjob(v) local r, g, b = getVehicleHeadLightColor(v) sav = {} for i=0, 16 do local upgrade = getVehicleUpgradeOnSlot(v, i) sav[i] = upgrade or 0 end dbExec(handler, "UPDATE tuning SET t0='"..sav[0].."', t1='"..sav[1].."', t2='"..sav[2].."', t3='"..sav[3].."', t4='"..sav[4].."', t5='"..sav[5].."', t6='"..sav[6].."', t7='"..sav[7].."', t8='"..sav[8].."', t9='"..sav[9].."', t10='"..sav[10].."', t11='"..sav[11].."', t12='"..sav[12].."', t13='"..sav[13].."', t14='"..sav[14].."', t15='"..sav[15].."', t16='"..sav[16].."', paintjob='"..paintjob.."', hr='"..r.."', hg='"..g.."', hb='"..b.."' WHERE id="..id.."") sav = nil end end end setTimer(zapiszPojazdy, 900000, 0) function zapiszKomenda(player) local acc = getAccountName (getPlayerAccount(player)) if isObjectInACLGroup ("user."..acc, aclGetGroup ("Admin")) then zapiszPojazdy() outputChatBox("** Vehicles were saved.", player, 255, 255, 255, true) end end addCommandHandler("savecars", zapiszKomenda) -- mapa, f11 addEvent("pobierzPojazdyGracza", true) addEventHandler("pobierzPojazdyGracza", getRootElement(), function() local account = getPlayerAccount(source) if account then local name = getAccountName(account) local vehs = getVehiclesByOwner(name) triggerClientEvent(source, "zwrocPojazdyGracza", root, vehs) end end) -- --zwraca pojazd o danym ID function getVehicleByID(poszukiwane_id) for i,v in pairs(getElementsByType("vehicle")) do local id = getElementData(v, "car_id") if id then local id = tonumber(id) local poszukiwane_id = tonumber(poszukiwane_id) if id == poszukiwane_id then return v end end end return false end --zwraca pojazdy ktore posiada dany login function getVehiclesByOwner(szukany) tab = {} for i,v in pairs(getElementsByType("vehicle")) do local owner = getElementData(v, "car_owner") if owner then if owner == szukany then table.insert(tab, v) end end end return tab end --zwraca liczbe pojazdow jaka ma dany login function getYourVehicleCount(login) local vehs = getVehiclesByOwner(login) return #vehs 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