Szerző Téma: Finemta item-system  (Megtekintve 2195 alkalommal)

Nem elérhető regun

Finemta item-system
« Dátum: 2016. május 19. - 22:34:02 »
0 Show voters
Valaki ehez az inventory systemhez az itemek táblát nem tudná elküldeni vagy a felépitését leírni próbáltam kibogozni de nekem nem sikerült eddig még létrehozni a táblát.




mysql = exports.mysql
nyitva = {}
sqlUsername = exports.mysql:getMySQLUsername()
sqlPassword = exports.mysql:getMySQLPassword()
sqlDB = exports.mysql:getMySQLDBName()
sqlHost = exports.mysql:getMySQLHost()
sqlPort = exports.mysql:getMySQLPort()
handler = mysql_connect(sqlHost, sqlUsername, sqlPassword, sqlDB, sqlPort)
itemDB = dbConnect( \"sqlite\", \"itemek.db\" )
function checkMySQL()
if not (mysql_ping(handler)) then
handler = mysql_connect(sqlHost, sqlUsername, sqlPassword, sqlDB, sqlPort)
end
end
setTimer(checkMySQL, 300000, 0)
function closeMySQL()
if (handler) then
mysql_close(handler)
handler = nil
end
local players = getElementsByType(\"player\")
for k,v in ipairs(players) do
--   saveItems(v)
takeAllWeapons ( v )
setPedWeaponSlot ( v, 0 )
setElementData(v, \"taplalkozas\", nil)
end
local veh = getElementsByType ( \"vehicle\" )
for k,v in ipairs(veh) do
setElementData(v, \"nyitva\", false)
if getElementData(v, \"fve\") then
setElementData(v, \"fve\", false)
end
end
local objs = getElementsByType(\"object\")
for k,v in ipairs(objs) do
if (getElementData(v, \"itemID\")==60) then
   setElementData(v, \"nyitva\", false)
   if getElementData(v, \"fve\") then
   setElementData(v, \"fve\", false)
   end
end
end
end
addEventHandler(\"onResourceStop\", getResourceRootElement(getThisResource()), closeMySQL)
function saveIiitem(player, cmd)
if (exports.global:isPlayerFoFoAdmin(player)) then
local players = getElementsByType(\"player\")
for k,v in ipairs(players) do
saveItems(v)
takeAllWeapons ( v )
setPedWeaponSlot ( v, 0 )
end
outputChatBox(\"Játékos inventoryk elmentve.\", player)
--   saveObjsk(player)
end
end
addCommandHandler(\"itemsave\", saveIiitem)
--[[function saveVehsk(player)
local vehs = getElementsByType(\"vehicle\")
for k,v in ipairs(vehs) do
if (getVehicleType(getElementModel(v))==\"Automobile\") or (getVehicleType(getElementModel(v))==\"Helicopter\") then
   if (getElementData(v, \"dbid\")>0) then
      saveItems(v)
   end
end
end
outputChatBox(\"Jármű inventoryk elmentve.\", player)
--saveObjsk()
end
function saveObjsk(player)
local objs = getElementsByType(\"object\")
for k,v in ipairs(objs) do
if (getElementData(v, \"itemID\")==60) then
   saveItems(v)
end
end
outputChatBox(\"Széf inventoryk elmentve.\", player)
end
--]]
function getID(element)
if getElementType(element) == \"player\" then
return getElementData(element, \"dbid\")
elseif getElementType(element) == \"vehicle\" then
return getElementData(element, \"dbid\")
elseif getElementParent(getElementParent(element)) == getResourceRootElement() and getElementData(element, \"itemID\")~=60 then
return getElementData(element, \"id\")
elseif getElementType(element) == \"object\" then
return getElementDimension(element)
else
return 0
end
end
function getType(element)
if getElementType(element) == \"player\" then
return \"jatekos\"
elseif getElementType(element) == \"vehicle\" then
return \"auto\"
elseif getElementParent(getElementParent(element)) == getResourceRootElement() and getElementData(element, \"itemID\")~=60 then
return \"fold\"
elseif getElementType(element) == \"object\" then
return \"szef\"
else
return \"jatekos\"
end
end
function loadItemForElement( element )
if not isElement( element ) then
return false, \"Hiba\"
else
for i=1, 36 do
   local theItem = tonumber(getElementData(element, \"itemslot\"..i)) or 0
   if theItem > 0 then
      setElementData(element, \"itemslot\"..i, 0)
      setElementData(element, \"itemvalue\"..i..theItem, 0)
      setElementData(element, \"itemdarab\"..i..theItem, 0)
      setElementData(element, \"dbid\"..i, 0)
   end
end
local elementID = tonumber(getID( element )) or 0
if elementID == 0 then return end
local dbMuv = dbQuery( itemDB, \"SELECT * FROM itemek WHERE elementID = \" .. elementID  .. \" AND elementtype = \'\".. getType(element) ..\"\' ORDER BY `id` ASC\" )
local result = dbPoll(dbMuv, -1)
if (#result>0) then
for _, row in ipairs ( result ) do
   id = tonumber(row[\"id\"])
   slot = tonumber(row[\"slot\"])
   item = tonumber(row[\"itemID\"])
   db = tonumber(row[\"db\"])
   itemValue = tonumber(row[\"itemValue\"])
   setElementData(element, \"mysqlid\"..slot, id)
   if item == 48 and getType(element) == \"jatekos\" then
      setElementData(element, \"taska\", true)
   end
   setElementData(element, \"itemslot\"..slot, item)
   setElementData(element, \"itemdarab\"..slot..item, db)
   setElementData(element, \"dbid\"..slot..item, id)
   setElementData(element, \"itemvalue\"..slot..item, itemValue)
    end
end
end
end
addEvent(\"lifele\", true)
addEventHandler(\"lifele\", getRootElement(), loadItemForElement)
--[[function saveItems(player)
local owner = tonumber(getElementData(player, \"dbid\")) or 0
local etype = getType(player)
if (etype==\"szef\") then
owner = getID(player)
end
for i=1,36 do
local item = tonumber(getElementData(player, \"itemslot\"..i)) or 0
if item > 0 then
   local time = getRealTime()
   local itemvalue = tonumber(getElementData(player, \"itemvalue\"..i..item)) or 0
   local darabszam = tonumber(getElementData(player, \"itemdarab\"..i..item)) or 0
   local QUERY = dbQuery(itemDB, \"SELECT * FROM itemek WHERE elementID = \'\".. owner ..\"\' AND elementtype = \'\".. etype ..\"\' AND slot = \'\".. i ..\"\'\")
   local result = dbPoll(QUERY, -1)
   if (#result>0) then
   for _, row in ipairs ( result ) do
--   if QUERY then
      local itemID = row[\"itemID\"]
      local itemValue2 = row[\"itemValue\"]
      local db = row[\"db\"]
      if (not item == itemID) or (not darabszam == db) or (not itemvalue == itemValue2) then
         dbExec(itemDB, \"DELETE FROM itemek WHERE elementID = \'\".. owner ..\"\' AND elementtype = \'\".. etype ..\"\' AND slot = \'\".. i ..\"\'\")
         dbExec(itemDB, \"INSERT INTO itemek (itemID, slot, elementID, itemValue, createDate, db, elementtype) VALUES (\"..item..\", \"..i..\", \"..owner..\", \"..itemvalue..\", \'\"..time.year+1900 ..\"-\"..time.month+1 ..\"-\"..time.monthday..\" \"..time.hour..\":\"..time.minute..\":\"..time.second..\"\', \"..darabszam..\", \'\"..etype..\"\')\")
      else
         dbExec(itemDB, \"UPDATE itemek SET itemID = \'\".. item ..\"\', itemValue = \'\".. itemvalue ..\"\', db = \'\".. darabszam ..\"\' WHERE elementID = \'\".. owner ..\"\' AND elementtype = \'\".. etype ..\"\' AND slot = \'\".. i ..\"\'\")
      end
   end
   else
      --dbExec(itemDB, \"DELETE FROM itemek WHERE elementID = \".. owner ..\" AND elementtype = \'\".. etype ..\"\' AND slot = \".. i ..\"\")
      dbExec(itemDB, \"INSERT INTO itemek (itemID, slot, elementID, itemValue, createDate, db, elementtype) VALUES (\"..item..\", \"..i..\", \"..owner..\", \"..itemvalue..\", \'\"..time.year+1900 ..\"-\"..time.month+1 ..\"-\"..time.monthday..\" \"..time.hour..\":\"..time.minute..\":\"..time.second..\"\', \"..darabszam..\", \'\"..etype..\"\')\")
   end
else
   dbExec(itemDB, \"DELETE FROM itemek WHERE elementID = \'\".. owner ..\"\' AND elementtype = \'\".. etype ..\"\' AND slot = \'\".. i ..\"\'\")
end
end
end
addEvent(\"saveItems\",true)
addEventHandler(\"saveItems\", getRootElement(), saveItems)]]
function saveItems(player)
local owner = tonumber(getElementData(player, \"dbid\")) or 0
local etype = getType(player)
if (etype==\"szef\") then
owner = getID(player)
end
dbExec(itemDB, \"DELETE FROM itemek WHERE elementID = \'\".. owner ..\"\' AND elementtype = \'\".. etype ..\"\'\")
for i=1,36 do
local item = tonumber(getElementData(player, \"itemslot\"..i)) or 0
if item > 0 then
   local time = getRealTime()
   local itemvalue = tonumber(getElementData(player, \"itemvalue\"..i..item)) or 0
   local darabszam = tonumber(getElementData(player, \"itemdarab\"..i..item)) or 0
   dbExec(itemDB, \"INSERT INTO itemek (itemID, slot, elementID, itemValue, createDate, db, elementtype) VALUES (\"..item..\", \"..i..\", \"..owner..\", \"..itemvalue..\", \'\"..time.year+1900 ..\"-\"..time.month+1 ..\"-\"..time.monthday..\" \"..time.hour..\":\"..time.minute..\":\"..time.second..\"\', \"..darabszam..\", \'\"..etype..\"\')\")
end
end
end
addEvent(\"saveItems\",true)
addEventHandler(\"saveItems\", getRootElement(), saveItems)
function mozogs(element, regi, uj, id, ertek, darab, olusz)
if (olusz==1) then
dbExec(itemDB, \"UPDATE itemek SET `db`=`db`+1 WHERE slot=\'\".. tonumber(uj) ..\"\' AND elementID=\'\".. tonumber(getID(element)) ..\"\' AND elementtype=\'\".. getType(element) ..\"\'\")
dbExec(itemDB, \"UPDATE itemek SET `db`=`db`-1 WHERE slot=\'\".. tonumber(regi) ..\"\' AND elementID=\'\".. tonumber(getID(element)) ..\"\' AND elementtype=\'\".. getType(element) ..\"\'\")
elseif (olusz==2) then
dbExec(itemDB, \"INSERT INTO itemek (itemID, slot, itemValue, db, elementID, elementtype) VALUES (\"..tonumber(id)..\", \"..tonumber(uj)..\", \"..tonumber(ertek)..\", \"..tonumber(darab)..\", \"..tonumber(getID(element))..\", \'\"..getType(element)..\"\')\")
dbExec(itemDB, \"UPDATE itemek SET `db`=`db`-1 WHERE slot=\'\".. tonumber(regi) ..\"\' AND elementID=\'\".. tonumber(getID(element)) ..\"\' AND elementtype=\'\".. getType(element) ..\"\'\")
else
dbExec(itemDB, \"UPDATE itemek SET itemID=\'\".. tonumber(id) ..\"\', slot=\'\".. tonumber(uj) ..\"\', itemValue=\'\".. tonumber(ertek) ..\"\', db=\'\".. tonumber(darab) ..\"\' WHERE slot=\'\".. tonumber(regi) ..\"\' AND elementID=\'\".. tonumber(getID(element)) ..\"\' AND elementtype=\'\".. getType(element) ..\"\'\")
end
end
addEvent(\"mozogs\",true)
addEventHandler(\"mozogs\", getRootElement(), mozogs)
function fixnulVS(element, slot)
dbExec( itemDB,\"DELETE FROM itemek WHERE slot=\'\".. slot ..\"\' AND elementID=\'\".. tonumber(getID(element)) ..\"\' AND elementtype=\'\".. getType(element) ..\"\'\")
end
addEvent(\"fixnulVS\",true)
addEventHandler(\"fixnulVS\", getRootElement(), fixnulVS)
function giveItem(thePlayer, itemID, itemValue, darab)
if itemID and itemValue then
   local elementID = tonumber(getElementData(thePlayer, \"dbid\")) or 0
   local eTipus = getType(thePlayer)
   local newItem = tonumber(itemID)
   local darab = tonumber(darab)
   local time = getRealTime()
   if not darab then
      darab = 1
   end
   --[[if (eTipus==\"szef\") then
      elementID = getElementDimension(thePlayer)
   end--]]
   local newSlot, state = elsoSzabadSlot(thePlayer)
   if state == true then
      if elementID > 0 then
      --[[   local dbMuv = dbQuery(itemDB, \"INSERT INTO itemek (itemID, slot, elementID, itemValue, createDate, db, elementtype) VALUES (\"..itemID..\", \"..newSlot..\", \"..elementID..\", \"..itemValue..\", \'\"..time.year+1900 ..\"-\"..time.month+1 ..\"-\"..time.monthday..\" \"..time.hour..\":\"..time.minute..\":\"..time.second..\"\', \"..darab..\", \'\"..eTipus..\"\')\")
         local vmi, vmi2, insertid = dbPoll(dbMuv, -1)--]]
         setElementData(thePlayer, \"itemslot\"..newSlot, newItem)
         setElementData(thePlayer, \"itemdarab\"..newSlot..newItem, darab)
         setElementData(thePlayer, \"itemvalue\"..newSlot..newItem, itemValue)
         setElementData(thePlayer, \"dbid\"..newSlot, 0)
      end
   else
      return false, \"Sikertelen.\"
   end
   return true, \"Sikeres.\"
end
end
--addEvent(\"giveItem\",true)
--addEventHandler(\"giveItem\", getRootElement(), giveItem)
function giveItem2(thePlayer, itemID, itemValue, darab, egyeb, egyeb2, gomb)
if itemID and itemValue then
   local elementID = tonumber(getElementData(thePlayer, \"dbid\")) or 0
   local eTipus = getType(thePlayer)
   local newItem = tonumber(itemID)
   local darab = tonumber(darab)
   local time = getRealTime()
   if not darab then
      darab = 1
   end
   if (eTipus==\"szef\") then
      elementID = getElementDimension(thePlayer)
   end
   local newSlot, state = elsoSzabadSlot(thePlayer)
   if state == true then
      if elementID > 0 then
         if (eTipus~=\"jatekos\") then
         dbExec(itemDB, \"INSERT INTO itemek (itemID, slot, elementID, itemValue, createDate, db, elementtype) VALUES (\"..itemID..\", \"..newSlot..\", \"..elementID..\", \"..itemValue..\", \'\"..time.year+1900 ..\"-\"..time.month+1 ..\"-\"..time.monthday..\" \"..time.hour..\":\"..time.minute..\":\"..time.second..\"\', \"..darab..\", \'\"..eTipus..\"\')\")
         end
         if (getType(egyeb)~=\"jatekos\") then
            if (gomb==\"mouse1\") then
               dbExec( itemDB,\"DELETE FROM itemek WHERE slot = \'\".. egyeb2 ..\"\' AND elementID = \'\".. tonumber(getID(egyeb)) ..\"\' AND elementtype = \'\" .. getType(egyeb) .. \"\'\")
            elseif (gomb==\"mouse2\") then
               dbExec( itemDB,\"UPDATE itemek SET `db`=`db`-1 WHERE slot = \'\".. egyeb2 ..\"\' AND elementID = \'\".. tonumber(getID(egyeb)) ..\"\' AND elementtype = \'\" .. getType(egyeb) .. \"\'\")
         --      dbExec( itemDB,\"UPDATE itemek SET `db`=`db`+1 WHERE slot = \'\".. newSlot ..\"\' AND elementID = \'\".. tonumber(getID(egyeb)) ..\"\' AND elementtype = \'\" .. getType(egyeb) .. \"\'\")
            end
         end
         setElementData(thePlayer, \"itemslot\"..newSlot, newItem)
         setElementData(thePlayer, \"itemdarab\"..newSlot..newItem, darab)
         setElementData(thePlayer, \"itemvalue\"..newSlot..newItem, itemValue)
         setElementData(thePlayer, \"dbid\"..newSlot, 0)
      end
   else
      return false, \"Sikertelen.\"
   end
   return true, \"Sikeres.\"
end
end
addEvent(\"giveItem2\",true)
addEventHandler(\"giveItem2\", getRootElement(), giveItem2)
function vilagItemek()
local dbMuv = dbQuery( itemDB, \"SELECT * FROM itemek WHERE elementtype = \'fold\'\" )
local result = dbPoll(dbMuv, -1)
if (#result>0) then
for _, row in ipairs ( result ) do
      elementtype = tostring(row[\"elementtype\"])
      id = tonumber(row[\"id\"])
      itemID = tonumber(row[\"itemID\"])
      itemValue = tonumber(row[\"itemValue\"])
      x,y,z,r = tonumber(row[\"wX\"]), tonumber(row[\"wY\"]), tonumber(row[\"wZ\"]), tonumber(row[\"wRot\"])
      int = tonumber(row[\"wInterior\"]) or 0
      dim = tonumber(row[\"wDimension\"]) or 0
      db = tonumber(row[\"db\"])
      if elementtype == \"fold\" then
         local object = createObject(getItemModel(itemID), x,y,z,r,0,0)
         if object then
            setElementInterior(object, int)
            setElementDimension(object, dim)
            setElementData(object, \"dbid\", id)
            setElementData(object, \"db\", db)
            setElementData(object, \"itemID\", itemID)
            setElementData(object, \"itemValue\", itemValue)
         end
      end
end
end
end
function dropItem(item, x,y,z,int,dim,slot,owner,plus,gmb)
if item and item > 0 then
if item == 60 then
   triggerClientEvent(owner, \"bugOff\", owner)
   if (hasItem(owner, 4, dim) or hasItem(owner, 5, dim)) then
      if isSafeInDimension(dim) then
         outputChatBox(\"Egy interioron belül csak 1 db széfet lehet lerakni!\", owner, 255,0,0)
         return
      end
      z = z + 0.5
   else
      outputChatBox(\"Nincs kulcsod ehhez a lakáshoz (vagy nem vagy lakásban).\", owner, 255,0,0)
      return
   end
elseif item == 208 then   
   triggerClientEvent(owner, \"bugOff\", owner)
   if (hasItem(owner, 4, dim) or hasItem(owner, 5, dim)) then
      if (exports[\"fine-drog\"]:leheteCserep(dim)) then
         outputChatBox(\"Egy interioron belül maximum 30 db cserepet lehet lerakni!\", owner, 255,0,0)
         return
      end
      z = z + 0.15
   else
      outputChatBox(\"Nincs kulcsod ehhez a lakáshoz (vagy nem vagy lakásban).\", owner, 255,0,0)
      return
   end
elseif item == 112 then
   triggerClientEvent(owner, \"bugOff\", owner)
   if (exports.global:isPlayerFoAdmin(owner)) then
      z = z + 0.4
   else
      return
   end
elseif tonumber(getElementData(owner, \"itemvalue\"..slot..item)) == 53 then
   triggerClientEvent(source, \"bugOff\", source)
   takeItem(owner, item, 53)
   dbExec( itemDB, \"DELETE FROM itemek WHERE elementID = \'\".. tonumber(getID(owner)) ..\"\' AND elementtype = \'\".. getType(owner) ..\"\' AND slot = \'\".. slot ..\"\'\" )
   return
end
local tulaj = owner
local owner = tonumber(getID(owner)) or 0
local itemDarab = tonumber(getElementData(tulaj, \"itemdarab\"..slot..item)) or 0
--   local dbid = tonumber(getElementData(tulaj, \"dbid\"..slot..item)) or 0
local itemValue = tonumber(getElementData(tulaj, \"itemvalue\"..slot..item)) or 0
if (tonumber(plus)) and (tonumber(plus)==1) then
setElementData(tulaj, \"itemdarab\"..slot..item, itemDarab-1)
itemDarab = 1
else
setElementData(tulaj, \"itemslot\"..slot, 0)
setElementData(tulaj, \"itemdarab\"..slot..item, 0)
setElementData(tulaj, \"dbid\"..slot..item, 0)
setElementData(tulaj, \"itemvalue\"..slot..item, 0)
end
local rx, ry, rz = getItemRotInfo(item)
--mysql_query( handler, \"INSERT INTO itemek SET elementtype = \'fold\', itemID = \'\".. item ..\"\', itemValue = \'\".. itemValue ..\"\', wX = \'\".. x ..\"\', wY = \'\".. y ..\"\', wZ = \'\".. z ..\"\', wRot = \'0\', db = \'\".. itemDarab ..\"\', wCreateDate = NOW(), wInterior = \'\".. int ..\"\', wDimension = \'\".. dim ..\"\', elementID = \'0\'\" )
if (getType(tulaj)~=\"jatekos\") then
if (gmb==\"mouse2\") then
dbExec( itemDB, \"UPDATE itemek SET `db`=`db`-1 WHERE elementID = \'\".. owner ..\"\' AND elementtype = \'\".. getType(tulaj) ..\"\' AND slot = \'\".. slot ..\"\'\" )
else
dbExec( itemDB, \"DELETE FROM itemek WHERE elementID = \'\".. owner ..\"\' AND elementtype = \'\".. getType(tulaj) ..\"\' AND slot = \'\".. slot ..\"\'\" )
end
end
if (item==208) then
mysql_query(handler, \"INSERT INTO cserepek SET x=\'\" .. x .. \"\', y=\'\" .. y .. \"\', z=\'\" .. z .. \"\', intr=\'\" .. int .. \"\', dim=\'\" .. dim .. \"\', fajta=\'\" .. itemValue .. \"\', allapot=0\")
dbid = mysql_insert_id(handler)
triggerEvent(\"setCsTomb\", tulaj, dbid, itemValue, x, y, z, int, dim)
else
local time = getRealTime()
local dbMuv = dbQuery( itemDB, \"INSERT INTO itemek (elementtype, itemID, itemValue, wX, wY, wZ, wRot, db, wCreateDate, wInterior, wDimension, elementID) VALUES (\'fold\', \"..item..\", \"..itemValue..\", \"..x..\", \"..y..\", \"..z..\", 0, \"..itemDarab..\", \'\"..time.year+1900 ..\"-\"..time.month+1 ..\"-\"..time.monthday..\" \"..time.hour..\":\"..time.minute..\":\"..time.second..\"\', \"..int..\", \"..dim..\", 0)\")
--   mysql:query_insert_free(\"INSERT INTO itemek SET elementtype = \'fold\', itemID = \'\".. item ..\"\', itemValue = \'\".. itemValue ..\"\', wX = \'\".. x ..\"\', wY = \'\".. y ..\"\', wZ = \'\".. z ..\"\', wRot = \'0\', db = \'\".. itemDarab ..\"\', wCreateDate = NOW(), wInterior = \'\".. int ..\"\', wDimension = \'\".. dim ..\"\', elementID = \'0\'\")
local vmi, vmi2, dbid = dbPoll(dbMuv, -1)
--[[đ      else
setElementData(tulaj, \"itemslot\"..slot, 0)
setElementData(tulaj, \"itemdarab\"..slot..item, 0)
setElementData(tulaj, \"dbid\"..slot..item, 0)
setElementData(tulaj, \"itemvalue\"..slot..item, 0)
local rx, ry, rz = getItemRotInfo(item)
local idke = mysql:query_fetch_assoc(\"SELECT id FROM itemek WHERE elementID = \'\".. owner ..\"\' AND slot = \'\".. slot ..\"\'\" )
dbid = tonumber(idke.id)
mysql_query( handler, \"UPDATE itemek SET elementtype = \'fold\', itemID = \'\".. item ..\"\', wX = \'\".. x ..\"\', wY = \'\".. y ..\"\', wZ = \'\".. z ..\"\', wRot = \'0\', db = \'\".. itemDarab ..\"\', wCreateDate = NOW(), wInterior = \'\".. int ..\"\', wDimension = \'\".. dim ..\"\', elementID = \'0\' WHERE elementID = \'\".. owner ..\"\' AND slot = \'\".. slot ..\"\'\" )
--   mysql:query_free(\"UPDATE itemek SET elementtype = \'fold\', wX = \'\".. x ..\"\', wY = \'\".. y ..\"\', wZ = \'\".. z ..\"\', wRot = \'0\', db = \'\".. itemDarab ..\"\', wCreateDate = NOW(), wInterior = \'\".. int ..\"\', wDimension = \'\".. dim ..\"\', elementID = \'0\' WHERE elementID = \'\".. owner ..\"\' AND slot = \'\".. slot ..\"\'\")
end--]]
local object = createObject(getItemModel(item), x,y,z,rx,ry,rz)
if object then
   setElementInterior(object, int)
   setElementDimension(object, dim)
   setElementData(object, \"dbid\", dbid)
   setElementData(object, \"db\", itemDarab)
   setElementData(object, \"itemID\", item)
   setElementData(object, \"itemValue\", itemValue)
end
if (item==44) then
   borondle(source)
end
end
exports.global:sendLocalMeAction(source, \"eldobott valamit.\")
exports.global:applyAnimation(source, \"CARRY\", \"putdwn\", 500, false, false, true)
triggerClientEvent(source, \"bugOff\", source)
end
end
addEvent(\"dropItemS\",true)
addEventHandler(\"dropItemS\", getRootElement(), dropItem)
function felveszItem(player, element)
if isElement(element) then
local itemID = getElementData(element, \"itemID\")
local dbid = getElementData(element, \"dbid\")
local dbid2 = getElementData(player, \"dbid\")
local DB = getElementData(element, \"db\")
local itemValue = getElementData(element, \"itemValue\")
local newSlot, state = elsoSzabadSlot(player)
if state == true then
   destroyElement(element)
   setElementData(player, \"itemslot\"..newSlot, itemID)
   setElementData(player, \"itemdarab\"..newSlot..itemID, DB)
   setElementData(player, \"itemvalue\"..newSlot..itemID, itemValue)
   setElementData(player, \"dbid\"..newSlot..itemID, dbid)
   --mysql_query( handler, \"UPDATE itemek SET elementtype = \'jatekos\', elementID = \'\".. dbid2 ..\"\', slot = \'\".. newSlot ..\"\' WHERE id = \'\".. dbid ..\"\'\" )
   dbExec( itemDB,\"UPDATE itemek SET elementtype = \'jatekos\', elementID = \'\".. dbid2 ..\"\', slot = \'\".. newSlot ..\"\' WHERE id = \'\".. dbid ..\"\'\")
   exports.global:applyAnimation(source, \"CARRY\", \"liftup\", 600, false, true, true)
   exports.global:sendLocalMeAction(source, \"lehajol és felvesz valamit.\")
else
--   outputChatBox(\"Hiba.\", player, 255, 0, 0)
end
end
end
addEvent(\"felveszItem\",true)
addEventHandler(\"felveszItem\", getRootElement(), felveszItem)
function belepesNull(player)
local veh = getPedOccupiedVehicle(player)
for i=1, 36 do
setElementData(player, \"itemslot\"..i, 0)
if (veh) then
setElementData(veh, \"itemslot\"..i, 0)
end
end
end
--addCommandHandler(\"null\", belepesNull)
function shinvS(player, cmd, target)
if (exports.global:isPlayerAdmin(player)) then
local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick(player, target)
if (targetPlayer) then
if (getElementData(targetPlayer, \"loggedin\")==1) then
   triggerClientEvent(player, \"shinv\", targetPlayer, targetPlayer)
end
end
end
end
addCommandHandler(\"showinv\", shinvS)
function kilepes(quitType)
if (pia[source]) then
destroyElement(pia[source])
pia[source] = nil
end
if (kaja[source]) then
destroyElement(kaja[source])
kaja[source] = nil
end
saveItems(source)
end
addEventHandler(\"onPlayerQuit\", getRootElement(), kilepes)
function getAllPlayers(res)
--[[đ   local veh = getElementsByType ( \"vehicle\" )
for k,v in ipairs(veh) do
loadItemForElement(v)
end
local objs = getElementsByType(\"object\")
for k,v in ipairs(objs) do
if (getElementData(v, \"itemID\")==60) then
   loadItemForElement(v)
end
end--]]
if (getResourceName(res)==\"item-system\") then
vilagItemek()
end
end
addEventHandler(\"onResourceStart\", getRootElement(getThisResource()), getAllPlayers)
function itemBetoltes(player)
setTimer(function()
loadItemForElement(player)
end, 5000, 1)
end
addEvent(\"itemBetoltes\", true)
addEventHandler(\"itemBetoltes\", getRootElement(), itemBetoltes)
function meFunkok(source, szoveg, bug)
exports.global:sendLocalMeAction(source, szoveg)
if not (bug) then
triggerClientEvent(source, \"bugOff\", source)
end
end
addEvent(\"meFunkok\", true)
addEventHandler(\"meFunkok\", getRootElement(), meFunkok)
function csomifix(source, jarmu, tipus)
if not (nyitva[jarmu]) then
nyitva[jarmu] = source
triggerClientEvent(source, \"nyitCsomi\", source, source, jarmu, tipus)
else
outputChatBox(\"#5e5e5e[#abababFineMTA#5e5e5e] #c3c3c3Egyszerre csak 1 ember nézhet bele ebbe.\", source, 0, 0, 0, true)
end
end
addEvent(\"csomifix\", true)
addEventHandler(\"csomifix\", getRootElement(), csomifix)
function csomiBezar(jarmu)
if (nyitva[jarmu]) then
nyitva[jarmu] = nil
end
end
addEvent(\"csomiBezar\", true)
addEventHandler(\"csomiBezar\", getRootElement(), csomiBezar)
function deleteAll( itemID, itemValue )
if itemID then
if itemValue then
   dbExec( itemDB, \"DELETE FROM itemek WHERE itemID = \" .. itemID .. \" AND itemValue = \'\" .. mysql_escape_string( handler, tostring( itemValue ) ) .. \"\'\" )
--         mysql_free_result( mysql_query( handler, \"DELETE FROM worlditems WHERE itemid = \" .. itemID .. \" AND itemvalue = \'\" .. mysql_escape_string( handler, tostring( itemValue ) ) .. \"\'\" ) )
   for key, value in pairs( getElementsByType( \"object\", getResourceRootElement( ) ) ) do
      if isElement( value ) then
         if getElementData( value, \"itemID\" ) == itemID and getElementData( value, \"itemValue\" ) == itemValue then
            destroyElement( value )
         end
      end
   end
local players = getElementsByType(\"player\")
for k,v in ipairs(players) do
for i=1, 36 do
   local item = tonumber(getElementData(v, \"itemslot\"..i)) or 0
   local itemVal = tonumber(getElementData(v, \"itemvalue\"..i..item)) or 0
   if item == itemID and itemVal == itemValue then
      setElementData(v, \"itemslot\"..i, 0)
      setElementData(v, \"itemdarab\"..i..item, 0)
      setElementData(v, \"itemvalue\"..i..item, 0)
      setElementData(v, \"dbid\"..i..item, 0)
   end
end
end
local veh = getElementsByType ( \"vehicle\" )
for k,v in ipairs(veh) do
if ((getVehicleType(v)==\"Automobile\") or (getVehicleType(v)==\"Helicopter\")) and (getElementData(v, \"dbid\")>0) then
for i=1, 36 do
   local item = tonumber(getElementData(v, \"itemslot\"..i)) or 0
   local itemVal = tonumber(getElementData(v, \"itemvalue\"..i..item)) or 0
   if item == itemID and itemVal == itemValue then
      setElementData(v, \"itemslot\"..i, 0)
      setElementData(v, \"itemdarab\"..i..item, 0)
      setElementData(v, \"itemvalue\"..i..item, 0)
      setElementData(v, \"dbid\"..i..item, 0)
   end
end
end
end
local objs = getElementsByType(\"object\")
for k,v in ipairs(objs) do
if (getElementData(v, \"itemID\")==60) then
for i=1, 36 do
   local item = tonumber(getElementData(v, \"itemslot\"..i)) or 0
   local itemVal = tonumber(getElementData(v, \"itemvalue\"..i..item)) or 0
   if item == itemID and itemVal == itemValue then
      setElementData(v, \"itemslot\"..i, 0)
      setElementData(v, \"itemdarab\"..i..item, 0)
      setElementData(v, \"itemvalue\"..i..item, 0)
      setElementData(v, \"dbid\"..i..item, 0)
   end
end
end
end
else
   dbExec( itemDB, \"DELETE FROM itemek WHERE itemID = \" .. itemID )
   --mysql_free_result( mysql_query( handler, \"DELETE FROM worlditems WHERE itemid = \" .. itemID ) )
   for key, value in pairs( getElementsByType( \"object\", getResourceRootElement( ) ) ) do
      if isElement( value ) then
         if getElementData( value, \"itemID\" ) == itemID then
            destroyElement( value )
         end
      end
   end
end
return true
else
return false
end
end
function delallszar(player, cmd)
if (exports.global:isPlayerTulaj(player)) then
dbExec( itemDB, \"DELETE FROM itemek WHERE itemID!=112 AND elementtype=\'fold\' AND wDimension=0 AND wInterior=0\")
for key, value in pairs( getElementsByType( \"object\", getResourceRootElement( ) ) ) do
if isElement( value ) then
   if getElementDimension(value) == 0 and getElementInterior(value) == 0 and getElementModel(value) ~= 1300 then
      destroyElement( value )
   end
end
end
outputChatBox(\"Az összes szar törölve!\", player, 255, 0, 0)
end
end
addCommandHandler(\"delallszar\", delallszar)
function updateItemValue(element, itemID, ujErtek)
for i=1, 36 do
local item = tonumber(getElementData(element, \"itemslot\"..i)) or 0
if item == itemID then
   local itemValue = tonumber(getElementData(element, \"itemvalue\"..i..item)) or 0
   if itemValue ~= ujErtek then
      setElementData(element, \"itemvalue\"..i..item, tonumber(ujErtek))
      dbExec( itemDB, \"UPDATE itemek SET itemValue = \'\".. tonumber(ujErtek) ..\"\' WHERE elementID = \'\".. getID(element) ..\"\' AND slot = \'\".. i ..\"\'\" )
      return true
   end
end
end
end
function getNearbyItems(thePlayer, commandName)
if (exports.global:isPlayerSuperAdmin(thePlayer)) then
local posX, posY, posZ = getElementPosition(thePlayer)
outputChatBox(\"Közeli itemek:\", thePlayer, 255, 126, 0)
local count = 0
for k, theObject in ipairs(getElementsByType(\"object\", getResourceRootElement())) do
   local dbid = getElementData(theObject, \"dbid\")
   if dbid then
      local x, y, z = getElementPosition(theObject)
      local distance = getDistanceBetweenPoints3D(posX, posY, posZ, x, y, z)
      if distance <= 10 and getElementDimension(theObject) == getElementDimension(thePlayer) and getElementInterior(theObject) == getElementInterior(thePlayer) then
         outputChatBox(\"   #\" .. dbid .. \": \" .. ( getItemName( getElementData(theObject, \"itemID\") ) or \"?\" ) .. \"(\" .. getElementData(theObject, \"itemID\") .. \"), ezzel az értékkel: \" .. tostring( getElementData(theObject, \"itemValue\") ), thePlayer, 255, 126, 0)
         count = count + 1
      end
   end
end
if (count==0) then
   outputChatBox(\"   Nincs találat.\", thePlayer, 255, 126, 0)
end
end
end
addCommandHandler(\"nearbyitems\", getNearbyItems, false, false)
function delItem(thePlayer, commandName, targetID)
if (exports.global:isPlayerSuperAdmin(thePlayer)) then
if not (targetID) then
   outputChatBox(\"SYNTAX: \" .. commandName .. \" [iD]\", thePlayer, 255, 194, 14)
else
   local object = nil
   targetID = tonumber( targetID )
   for key, value in ipairs(getElementsByType(\"object\", getResourceRootElement())) do
      local dbid = getElementData(value, \"dbid\")
      if dbid and dbid == targetID then
         object = value
         break
      end
   end
   if object then
      local id = getElementData(object, \"dbid\")
      if (id<0) then
         outputChatBox(\"Hiba. Kérdezd Peter-t ;)\")
         return
      end
      dbExec(itemDB, \"DELETE FROM itemek WHERE id=\'\" .. id .. \"\'\")
      outputChatBox(\"Item #\" .. id .. \" törölve.\", thePlayer)
      destroyElement(object)
   else
      outputChatBox(\"Hibás item ID.\", thePlayer, 255, 0, 0)
   end
end
end
end
addCommandHandler(\"delitem\", delItem, false, false)
function detNearbyItems(thePlayer, commandName)
if (exports.global:isPlayerFoAdmin(thePlayer)) then
local posX, posY, posZ = getElementPosition(thePlayer)
outputChatBox(\"Közeli itemek:\", thePlayer, 255, 126, 0)
local count = 0
for k, theObject in ipairs(getElementsByType(\"object\", getResourceRootElement())) do
   local dbid = getElementData(theObject, \"itemID\")
   if dbid~=60 and dbid~=112 then
      local x, y, z = getElementPosition(theObject)
      local distance = getDistanceBetweenPoints3D(posX, posY, posZ, x, y, z)
      if distance <= 10 and getElementDimension(theObject) == getElementDimension(thePlayer) and getElementInterior(theObject) == getElementInterior(thePlayer) then
         local id = getElementData(theObject, \"dbid\")
         dbExec(itemDB, \"DELETE FROM itemek WHERE id=\'\" .. id .. \"\'\")
         destroyElement(theObject)
         count = count + 1
      end
   end
end
outputChatBox( count .. \" item törölve.\", thePlayer, 255, 126, 0)
end
end
addCommandHandler(\"delnearbyitems\", detNearbyItems, false, false)
function kocsiTorlesCsomiFix()
if (getElementType(source) == \"vehicle\") then
local dbid = tonumber(getElementData(source, \"dbid\"))
dbExec(itemDB, \"DELETE FROM itemek WHERE elementID = \'\".. dbid ..\"\' AND elementtype = \'auto\'\")
end
end
addEventHandler(\"onElementDestroy\", root, kocsiTorlesCsomiFix)
« Utoljára szerkesztve: 2016. május 19. - 22:36:50 írta regun »

Finemta item-system
« Válasz #1 Dátum: 2016. május 19. - 23:33:57 »
0 Show voters
AceMTA mysql-ben benne van az ehez megfelelő táblázat.

Nem elérhető nyomo

  • 159
    • Profil megtekintése
Finemta item-system
« Válasz #2 Dátum: 2016. május 20. - 01:19:13 »
0 Show voters
CREATE TABLE IF NOT EXISTS `itemek` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `elementID` int(11) NOT NULL DEFAULT \'0\',
  `elementtype` enum(\'szef\',\'auto\',\'jatekos\',\'fold\',\'hatizsak\') NOT NULL,
  `itemID` int(11) NOT NULL,
  `itemValue` int(11) NOT NULL DEFAULT \'0\',
  `wX` varchar(500) NOT NULL DEFAULT \'0\',
  `wY` varchar(500) NOT NULL DEFAULT \'0\',
  `wZ` varchar(500) NOT NULL DEFAULT \'0\',
  `wRot` varchar(500) NOT NULL DEFAULT \'0\',
  `wCreateDate` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
  `createDate` datetime NOT NULL DEFAULT \'0000-00-00 00:00:00\',
  `wInterior` int(11) NOT NULL DEFAULT \'0\',
  `wDimension` int(11) NOT NULL DEFAULT \'0\',
  `slot` int(11) NOT NULL DEFAULT \'1\',
  `db` int(11) NOT NULL DEFAULT \'1\',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=87 ;

Finemta item-system
« Válasz #3 Dátum: 2016. május 29. - 17:17:45 »
0 Show voters
Minek keresel? Ha már felhasználsz, legalább írd át a lekéréseket sajátra, hidd el, nem is lesz annyi problémád, ha megérted egy kicsit a rendszert :D

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal