Szerző Téma: Bútor rendszer  (Megtekintve 1447 alkalommal)

Bútor rendszer
« Dátum: 2015. november 01. - 15:34:58 »
0 Show voters
Olyan problémám lenne,hogy folyton ezt írja ki INFO:MYSQL_ERROR 1054: Unknown column \'id\' in \'field list\'
persze /debugscript 3 után írja ezt főleg ha újra indítom a resource-t. Fogalmam sincs mi lehet a baja.
 
local mysql = exports.mysql
local null = mysql_null()
local toLoad = { }
local threads = { }
function loadAllButor(res)
local players = exports.pool:getPoolElementsByType(\"player\")
for key, value in ipairs(players) do
exports[\'anticheat-system\']:changeProtectedElementDataEx(value, \"realinvehicle\", 0, false)
end
local result = mysql:query(\"SELECT id FROM butor\")
if result then
while true do
   local row = mysql:fetch_assoc(result)
   if not row then break end
   toLoad[tonumber(row[\"id\"])] = true
end
mysql:free_result(result)
for id in pairs( toLoad ) do
   local co = coroutine.create(loadOneButor)
   coroutine.resume(co, id, true)
   table.insert(threads, co)
end
setTimer(resume, 1000, 4)
else
outputDebugString( \"loadAllButor hiba\" )
end
end
addEventHandler(\"onResourceStart\", getResourceRootElement(), loadAllButor)
function resume()
for key, value in ipairs(threads) do
coroutine.resume(value)
end
end
function loadOneButor(id, hasCoroutine)
if (hasCoroutine==nil) then
hasCoroutine = false
end
local row = mysql:query_fetch_assoc(\"SELECT * FROM butor WHERE id = \" .. mysql:escape_string(id) )
if row then
if (hasCoroutine) then
   coroutine.yield()
end
for k, v in pairs( row ) do
   if v == null then
      row[k] = nil
   else
      row[k] = tonumber(row[k]) or row[k]
   end
end
local objectid = tonumber(row.object)
local id = tonumber(row.id)
local x,y,z = row.x, row.y, row.z
local rx,ry,rz = row.rotx, row.roty, row.rotz
local int, dim = tonumber(row.interior), tonumber(row.dimension)
local object = createObject ( objectid, x,y,z, rx,ry,rz )
if object then
   setElementInterior(object, int)
   setElementDimension(object, dim)
   exports[\'anticheat-system\']:changeProtectedElementDataEx(object, \"butor\", true)
   exports[\'anticheat-system\']:changeProtectedElementDataEx(object, \"object\", true)
   exports[\'anticheat-system\']:changeProtectedElementDataEx(object, \"id\", id)
end
else
outputDebugString(\"found\", 1)
end
end
function saveObject(object, x,y,z,rx,ry,rz, int,dim, ar, player)
local object = tonumber(object)
local ar = tonumber(ar)
local x = x
local y = y
local z = z
local interior = tonumber(int)
local dimension = tonumber(dim)
if ar > 0 then
if exports.global:takeMoney(player, ar) then
   outputChatBox(\"Ennek a bútornak ára: \".. ar .. \" Ft! Jó használatot!\", player,0,255,0)
else
   outputChatBox(\"Ennek a bútornak ára: \".. ar .. \" Ft! Nincs elég pénzed!\", player,255,0,0)
   return
end
end
local insertid = mysql:query_insert_free(\"INSERT INTO butor SET object = \'\".. object ..\"\', interior = \'\".. int ..\"\', dimension = \'\".. dim ..\"\', rotx = \'\".. rx ..\"\', roty = \'\".. ry ..\"\', rotz = \'\".. rz ..\"\', x = \'\".. x ..\"\', y = \'\".. y ..\"\', z = \'\".. z ..\"\'\")
local object = createObject ( object, x,y,z, rx,ry,rz )
if insertid then
if object then
   exports.global:allocateElement(veh, insertid)
   setElementInterior(object, interior)
   setElementDimension(object, dimension)
   exports[\'anticheat-system\']:changeProtectedElementDataEx(object, \"butor\", true)
   exports[\'anticheat-system\']:changeProtectedElementDataEx(object, \"object\", true)
   exports[\'anticheat-system\']:changeProtectedElementDataEx(object, \"id\", tonumber(insertid))
end
else
outputChatBox(\"Bútor írási hiba #001 hiba. (query_insert_free)\")
end
end
addEvent(\"onButorCreate\", true)
addEventHandler(\"onButorCreate\", getRootElement(), saveObject)
function butorSzerkesztServer(id, object, jatekos)
if id and isElement(object) then
destroyElement(object)
mysql:query_insert_free(\"DELETE FROM butor WHERE id = \'\".. id ..\"\'\")
end
end
addEvent(\"onButorSzerkesztStart\", true)
addEventHandler(\"onButorSzerkesztStart\", getRootElement(), butorSzerkesztServer)
function onButorDeleteStart(id, object, jatekos)
if id and isElement(object) then
destroyElement(object)
mysql:query_insert_free(\"DELETE FROM butor WHERE id = \'\".. id ..\"\'\")
end
end
addEvent(\"onButorDeleteStart\", true)
addEventHandler(\"onButorDeleteStart\", getRootElement(), onButorDeleteStart)
« Utoljára szerkesztve: 2015. november 01. - 15:42:16 írta Lorain »

Bútor rendszer
« Válasz #1 Dátum: 2015. november 01. - 15:38:37 »
0 Show voters
A kódot bemásolnád?

Nem elérhető Xenius

  • 668
    • Profil megtekintése
Bútor rendszer
« Válasz #2 Dátum: 2015. november 01. - 19:27:32 »
0 Show voters
Oka: 2013-as HL Mod.
Amúgy pedig nem találja sql-ben az \'id\'-t

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal