Mam tu skrypt, który potrafi zapisać pozycje pojazdu (czyli gdzie został zostawiony), obrót, color i tunig. Jednak z nim jej taki problem że poprawnie zapisuje tylko pierwszy pojazd, a jak już się zeszpawnuje drugi o takim samy ID to po przemieszczeniu tego drugiego pojazdu już nie potrafi uaktualnić danych. Pamięta tylko gdzie został zeszpawnowany ten drugi pojazdu.
Ktoś może wie co jest nie tak?
[lua]
-- Plik: spawn_vehicle_server.lua
local spawnedVehicles = {}
local saveFileName = "spawned_vehicles.json"
function saveSpawnedVehicles()
local data = ""
for _, vehicleData in ipairs(spawnedVehicles) do
local line = toJSON(vehicleData)
data = data .. line .. "n"
end
local file = fileCreate(saveFileName)
if file then
fileWrite(file, data)
fileClose(file)
end
end
function loadSpawnedVehicles()
local file = fileOpen(saveFileName)
if file then
local data = fileRead(file, fileGetSize(file))
spawnedVehicles = {}
for line in string.gmatch(data, "[^rn]+") do
local vehicleData = fromJSON(line)
table.insert(spawnedVehicles, vehicleData)
end
fileClose(file)
end
end
function updateVehicleDataAndSave(vehicle, player)
local vehicleID = getElementModel(vehicle)
-- Pobierz informacje o tuningowaniu pojazdu
local upgrades = getVehicleUpgrades(vehicle)
Witam to jest skrypt na zapis pojazdow MySQL
Chcia?em doda? do tego opcj? drugiego w?a?ciciela ale nie wiem jak...
Tabele do pobrania moge przes?a? tutaj kod -
[code]--@author:piotr172
local SQL_LOGIN="" --login do bazy danych
local SQL_PASSWD="" --has?o do bazy danych
local SQL_DB="" --baza danych
local SQL_HOST="" --host bazy danych
local SQL_PORT=tonumber(get("port") or 3306) --port(standardowo 3306)
local root = getRootElement()
local SQL
local function connect() --??czy z baz? danych
SQL = mysql_connect(SQL_HOST, SQL_LOGIN, SQL_PASSWD, SQL_DB, SQL_PORT)
if (not SQL) then
outputServerLog("BRAK POLACZENIA Z BAZA DANYCH!")
else
mysql_query(SQL,"SET NAMES utf8")
end
end
addEventHandler("onResourceStart",getResourceRootElement(),function() --po w?aczeniu skryptu wysy?a do funkcji kt?ra ?aczy si? z baz? danych
connect()
end)
function esc(value)
return mysql_escape_string(SQL,value)
end
function pobierzTabeleWynikow(query)
local result=mysql_query(SQL,query)
if (not result) then
outputDebugString("mysql_query failed: (" .. mysql_errno(SQL) .. ") " .. mysql_error(SQL)) -- Show the reason
return nil
end
local tabela={}
for result,row in mysql_rows_assoc(result) do
table.insert(tabela,row)
end
mysql_free_result(result)
return tabela
end
function pobierzWyniki(query)
local result=mysql_query(S...
Mam skrypt na barierki tylko jest ma?y problem jak je postawie widz? je tylko ja mam to po stronie clinet i nie pokazuje innej osobie jak nawet dam 2 clinet i server barierka si? pokazuje ale jak w ni? wjade autem to 1 si? rozwala a druga ta nie widzalna dla 2 osoby zostaje
dam kod Clinet:
[lua]
function barier()
plr = getLocalPlayer()
if getElementModel(plr) ~= 280 then return end
if getPedOccupiedVehicle(plr) then return end
local x,y,z = getElementPosition(plr)
local rx,ry,rz = getElementRotation(plr)
setElementData(barierka, "isBarierka2", getPlayerName(plr))
end
addCommandHandler("ub",barier )
function barier ()
if getElementModel(plr) ~= 280 then return end
for i,v in ipairs(getElementsByType("object", resourceRoot)) do
if not getElementData(v, "isBarierka") then return end
if getElementData(v, "isBarierka2") == getPlayerName(plr) then
destroyElement(v)
end
end
end
addCommandHandler("usb", barier)
/////////////////////////////////////////
a tu po stronie server
Kod:
////////////////////////////////////
function barier(plr)
if getElementModel(plr) ~=...
Witajcie u?ytkownicy gtaonline!
Mianowicie, mam pytanko dla bardziej zaawansowanych skrypter?w.
Jak przenie??, z pliku x.lua zmienn? "x" do pliku y.lua?