Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local func = {}
- func["dbConnect"] = exports["rise_mysql"]:getConnection()
- weapons = {}
- itemCache = {}
- addEventHandler("onResourceStart", resourceRoot,function()
- for k,v in ipairs(getElementsByType("vehicle")) do
- setElementData(v,"veh:use",false)
- setElementData(v,"veh:player",nil)
- end
- for k,v in ipairs(getElementsByType("player")) do
- weapons[v] = {}
- itemCache[v] = {
- ["bag"] = {},
- ["key"] = {},
- ["vehicle"] = {},
- ["object"] = {},
- }
- loadInventoryElement(v)
- end
- for k,v in ipairs(getElementsByType("vehicle")) do
- itemCache[v] = {
- ["bag"] = {},
- ["key"] = {},
- ["vehicle"] = {},
- ["object"] = {},
- }
- loadInventoryElement(v)
- end
- end)
- function loadInventoryElement(element)
- local elementTypes = getTypeOfElement(element)
- local elementOwnerID = tonumber(getElementData(element, elementTypes[2]))
- if not itemCache[element] then
- itemCache[element] = {
- ["bag"] = {},
- ["key"] = {},
- ["vehicle"] = {},
- ["object"] = {},
- }
- end
- dbQuery(function(qh, element)
- local res, rows, err = dbPoll(qh, 0)
- if rows > 0 then
- for k, row in pairs(res) do
- itemCache[element][tostring(row["type"])][tonumber(row["slot"])] = {
- ["dbid"] = tonumber(row["id"]),
- ["id"] = tonumber(row["itemid"]),
- ["value"] = tostring(row["value"]),
- ["count"] = tonumber(row["count"]),
- ["duty"] = tonumber(row["dutyitem"]),
- ["slot"] = tonumber(row["slot"]),
- ["health"] = tonumber(row["itemState"]),
- ["name"] = tostring(row["name"]),
- ["weaponserial"] = tostring(row["weaponserial"]),
- }
- end
- end
- end, {element}, func["dbConnect"], "SELECT * FROM `items` WHERE `owner` = ?",elementOwnerID)
- end
- func["onStop"] = function()
- for k,v in ipairs(getElementsByType("player")) do
- if getElementData(v,"loggedin") then
- if getElementData(v,"acc:id") > 0 then
- if itemCache[v] then
- saveOneElementInventory(v)
- end
- end
- end
- end
- for k,v in ipairs(getElementsByType("vehicle")) do
- if (getElementData(v,"veh:id") or 0) > 0 then
- if itemCache[v] then
- saveOneElementInventory(v)
- end
- end
- end
- for k,v in ipairs(getElementsByType("object", getResourceRootElement(getResourceFromName("rise_item")))) do
- if getElementData(v,"dbid") and getElementData(v,"dbid") > 0 then
- if itemCache[v] then
- saveOneElementInventory(v)
- end
- end
- end
- end
- addEventHandler("onResourceStop",resourceRoot,func["onStop"])
- function removeDuplicate(s, id)
- for k, v in pairs(itemCache) do
- if isElement(k) then
- if getElementType(k) == 'player' then
- for i = 1, row * column do
- if v['bag'][i] and v['bag'][i]['dbid'] == id then
- itemCache[k]['bag'][i] = nil
- if getElementType(k) == 'player' then
- triggerClientEvent(k,"updateItemClick",k)
- end
- end
- if v['key'] and v['key'][i] and v['key'][i]['dbid'] == id then
- itemCache[k]['key'][i] = nil
- if getElementType(k) == 'player' then
- triggerClientEvent(k,"updateItemClick",k)
- end
- end
- end
- else
- for i = 1, row * column do
- if v[getTypeOfElement(k)[1]][i] then
- local dbid = v[getTypeOfElement(k)[1]][i]['dbid']
- if dbid == 2484 then iprint('miafasz?') end
- if id == 2484 then iprint('miafasz? miafasz?') end
- if dbid == id then
- itemCache[k][getTypeOfElement(k)[1]][i] = nil
- end
- end
- end
- end
- end
- end
- if id == 2484 then iprint('AZTAKURVA') end
- end
- function saveOneElementInventory(element)
- if getElementType(element) == "player" then
- for i = 1, row * column do
- if (itemCache[element]["bag"][i]) then
- local dbid = tonumber(itemCache[element]["bag"][i]["dbid"])
- local item = tonumber(itemCache[element]["bag"][i]["id"])
- local value = tostring(itemCache[element]["bag"][i]["value"])
- local count = tonumber(itemCache[element]["bag"][i]["count"])
- local duty = tonumber(itemCache[element]["bag"][i]["duty"])
- local state = tonumber(itemCache[element]["bag"][i]["health"])
- local name = tostring(itemCache[element]["bag"][i]["name"])
- local weaponserial = tostring(itemCache[element]["bag"][i]["weaponserial"])
- dbExec(func["dbConnect"],"UPDATE items SET slot = ?, value = ?, count = ?, type = ?, owner = ?, dutyitem = ?, itemState = ?, name = ?, weaponserial = ? WHERE id = ?",i,value,count,"bag",getElementData(element,"acc:id"),duty,state,name,weaponserial,dbid)
- --setTimer(removeDuplicate, 1000, 1, element, dbid)
- end
- end
- for i = 1, row * column do
- if (itemCache[element]["key"][i]) then
- local dbid = tonumber(itemCache[element]["key"][i]["dbid"])
- local item = tonumber(itemCache[element]["key"][i]["id"])
- local value = tostring(itemCache[element]["key"][i]["value"])
- local count = tonumber(itemCache[element]["key"][i]["count"])
- local duty = tonumber(itemCache[element]["key"][i]["duty"])
- local state = tonumber(itemCache[element]["key"][i]["health"])
- local name = tostring(itemCache[element]["key"][i]["name"])
- local weaponserial = tostring(itemCache[element]["key"][i]["weaponserial"])
- dbExec(func["dbConnect"],"UPDATE items SET slot = ?, value = ?, count = ?, type = ?, owner = ?, dutyitem = ?, itemState = ?, name = ?, weaponserial = ? WHERE id = ?",i,value,count,"key",getElementData(element,"acc:id"),duty,state,name,weaponserial,dbid)
- --setTimer(removeDuplicate, 1000, 1, element, dbid)
- end
- end
- elseif getElementType(element) == "vehicle" then
- for i = 1, row * column do
- if (itemCache[element][getTypeOfElement(element)[1]][i]) then
- local dbid = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["dbid"])
- local item = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["id"])
- local value = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["value"])
- local count = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["count"])
- local duty = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["duty"])
- local state = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["health"])
- local name = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["name"])
- local weaponserial = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["weaponserial"])
- dbExec(func["dbConnect"],"UPDATE items SET slot = ?, value = ?, count = ?, type = ?, owner = ?, dutyitem = ?, itemState = ?, name = ?, weaponserial = ? WHERE id = ?",i,value,count,getTypeOfElement(element)[1],getElementData(element,"veh:id"),duty,state,name,weaponserial,dbid)
- --setTimer(removeDuplicate, 1000, 1, element, dbid)
- end
- end
- elseif getElementType(element) == "object" then
- for i = 1, row * column do
- if (itemCache[element][getTypeOfElement(element)[1]][i]) then
- local dbid = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["dbid"])
- local item = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["id"])
- local value = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["value"])
- local count = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["count"])
- local duty = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["duty"])
- local state = tonumber(itemCache[element][getTypeOfElement(element)[1]][i]["health"])
- local name = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["name"])
- local weaponserial = tostring(itemCache[element][getTypeOfElement(element)[1]][i]["weaponserial"])
- dbExec(func["dbConnect"],"UPDATE items SET slot = ?, value = ?, count = ?, type = ?, owner = ?, dutyitem = ?, itemState = ?, name = ?, weaponserial = ? WHERE id = ?",i,value,count,getTypeOfElement(element)[1],getElementData(element,"dbid"),duty,state,name,weaponserial,dbid)
- --setTimer(removeDuplicate, 1000, 1, element, dbid)
- end
- end
- end
- end
- function getElementItems(playerSource, element, playerValue)
- if (element) then
- if not itemCache[element] then
- itemCache[element] = {
- ["bag"] = {},
- ["key"] = {},
- ["licens"] = {},
- ["vehicle"] = {},
- ["object"] = {},
- }
- end
- if (tonumber(playerValue) == 1 or tonumber(playerValue) == 2) then
- triggerClientEvent(playerSource, "setElementItems", playerSource, itemCache, playerValue, element)
- else
- return itemCache
- end
- end
- end
- addEvent("getElementItems", true)
- addEventHandler("getElementItems", getRootElement(), getElementItems)
- function takeStatus(playerSource, elementSource, itemData, newStatus)
- if (newStatus) then
- itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemData["id"]))[1]][tonumber(itemData["slot"])]["health"] = newStatus
- end
- end
- addEvent("takeStatus", true)
- addEventHandler("takeStatus", getRootElement(), takeStatus)
- function updateItemSlot(playerSource, elementSource, newSlot, oldItem,oldSlot,click)
- if (newSlot and oldItem) then
- if click == 1 then
- itemCache[elementSource][getTypeOfElement(elementSource,tonumber(oldItem["id"]))[1]][tonumber(oldSlot)] = nil
- itemCache[elementSource][getTypeOfElement(elementSource,tonumber(oldItem["id"]))[1]][tonumber(newSlot)] = {
- ["dbid"] = tonumber(oldItem["dbid"]),
- ["id"] = tonumber(oldItem["id"]),
- ["value"] = tostring(oldItem["value"]),
- ["count"] = tonumber(oldItem["count"]),
- ["duty"] = tonumber(oldItem["duty"]),
- ["slot"] = tonumber(newSlot),
- ["health"] = tonumber(oldItem["health"]),
- ["name"] = tostring(oldItem["name"]),
- ["weaponserial"] = tostring(oldItem["weaponserial"]),
- }
- triggerClientEvent(playerSource,"updateItemClick",playerSource)
- end
- --itemCache[elementSource][getTypeOfElement(elementSource,tonumber(oldItem["id"]))[1]][tonumber(newSlot)] = oldItem
- --itemCache[elementSource][getTypeOfElement(elementSource,tonumber(oldItem["id"]))[1]][oldSlot] = nil
- -- outputChatBox("-------------------------------------")
- -- outputChatBox("dbid: "..itemCache[elementSource][getTypeOfElement(elementSource,tonumber(oldItem["id"]))[1]][tonumber(newSlot)]["dbid"].." - "..tonumber(oldItem["dbid"]))
- -- outputChatBox("new slot: "..newSlot.." old slot: "..oldItem["slot"])
- getElementItems(playerSource, elementSource, 2)
- else
- triggerClientEvent(playerSource,"updateItemClick",playerSource)
- end
- end
- addEvent("updateItemSlot", true)
- addEventHandler("updateItemSlot", getRootElement(), updateItemSlot)
- function updateItemCount(playerSource, elementSource, itemSlot, newCount,itemData)
- if (newCount) then
- itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemData["id"]))[1]][tonumber(itemSlot)]["count"] = newCount
- end
- end
- addEvent("updateItemCount", true)
- addEventHandler("updateItemCount", getRootElement(), updateItemCount)
- function updateItemName(playerSource, elementSource, itemSlot, newName, itemData)
- if (newName) then
- itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemData["id"]))[1]][tonumber(itemData["slot"])]["name"] = newName
- end
- end
- addEvent("updateItemName", true)
- addEventHandler("updateItemName", getRootElement(), updateItemName)
- function updateItemValue(playerSource, elementSource, itemSlot, newValue, itemData)
- if (newValue) then
- itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemData["id"]))[1]][tonumber(itemData["slot"])]["value"] = newValue
- end
- end
- addEvent("updateItemValue", true)
- addEventHandler("updateItemValue", getRootElement(), updateItemValue)
- function deleteItem(playerSource, elementSource,itemData,state)
- if not state then
- state = 0
- end
- if (elementSource) then
- if state == 0 then
- if getElementType(elementSource) == "player" then
- func["delActionbarItem"](elementSource,itemData["dbid"])
- end
- end
- dbExec(func["dbConnect"],"DELETE FROM `items` WHERE `id` = ?",itemData["dbid"])
- itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemData["id"]))[1]][tonumber(itemData["slot"])] = nil
- getElementItems(playerSource, elementSource, 2)
- end
- end
- addEvent("deleteItem", true)
- addEventHandler("deleteItem", getRootElement(), deleteItem)
- func["delActionbarItem"] = function(element,itemDBID)
- dbQuery(function(q, element)
- local rs, rws, errs = dbPoll(q, 0)
- if rws > 0 then
- for k,r in pairs(rs) do
- dbExec(func["dbConnect"], "DELETE FROM `actionbaritems` WHERE `id`=?",r["id"])
- triggerClientEvent(element,"delActionBarSlot",element,element,r["actionslot"])
- end
- end
- end, {element}, func["dbConnect"],"SELECT * FROM `actionbaritems` WHERE `itemdbid` = ?", itemDBID)
- end
- addEventHandler("onPlayerQuit", root, function()
- local showElement = getElementData(source,"show:inv")
- if isElement(showElement) then
- if getElementType(showElement) == "vehicle" then
- if (getElementData(showElement, "veh:use") or false) then
- if getElementData(showElement, "veh:player") == source then
- setElementData(showElement, "veh:player", nil)
- setElementData(showElement, "veh:use", false)
- setVehicleDoorOpenRatio(showElement,1,0,1200)
- end
- end
- end
- if getElementType(showElement) == "object" then
- if getElementModel(showElement) == 2332 then
- if (getElementData(showElement, "safe:use") or false) then
- if getElementData(showElement, "safe:player") == source then
- setElementData(showElement, "safe:player", nil)
- setElementData(showElement, "safe:use", false)
- end
- end
- end
- end
- end
- end)
- addCommandHandler("fixinv",function(playerSource,cmd)
- if getElementData(playerSource,"acc:admin") >= 4 then
- local playerX,playerY,playerZ = getElementPosition(playerSource)
- for k,v in ipairs(getElementsByType("object")) do
- if getElementData(v,"szef") then
- if getElementData(v,"safe:use") then
- local objectX,objectY,objectZ = getElementPosition(v)
- if getDistanceBetweenPoints3D(playerX,playerY,playerZ,objectX,objectY,objectZ) <= 2 then
- setElementData(v, "safe:player", nil)
- setElementData(v, "safe:use", false)
- outputChatBox("[RiseMTA]:#ffffff Sikeresen fix-eltél egy #ACD373'széf'#ffffff inventory-t.",playerSource,172, 211, 115,true)
- return
- end
- end
- end
- end
- for k,v in ipairs(getElementsByType("vehicle")) do
- if getElementData(v,"dbid") and getElementData(v,"dbid") > 0 then
- if getElementData(v, "veh:use") then
- local vehicleX,vehicleY,vehicleZ = getElementPosition(v)
- if getDistanceBetweenPoints3D(playerX,playerY,playerZ,vehicleX,vehicleY,vehicleZ) <= 2 then
- setElementData(v, "veh:player", nil)
- setElementData(v, "veh:use", false)
- setVehicleDoorOpenRatio(v,1,0,1200)
- outputChatBox("[RiseMTA]:#ffffff Sikeresen fix-eltél egy #ACD373'csomagtartó'#ffffff inventory-t.",playerSource,172, 211, 115,true)
- end
- end
- end
- end
- end
- end)
- function createNewItem(playerSource, elementSource, itemID, itemSlot, itemCount, itemDuty, itemValue,itemHealth,itemName,weaponserial,oldDBID)
- if (itemID and itemSlot) then
- local elementType = getTypeOfElement(elementSource)
- local elementOwnerID = tonumber(getElementData(elementSource, elementType[2]))
- dbQuery(function(qh,itemID,elementOwnerID,itemSlot)
- local query, query_lines,id = dbPoll(qh, 0)
- local id = tonumber(id)
- if id > 0 then
- itemCache[elementSource][getTypeOfElement(elementSource,tonumber(itemID))[1]][tonumber(itemSlot)] = {
- ["dbid"] = tonumber(id),
- ["id"] = tonumber(itemID),
- ["value"] = tostring(itemValue),
- ["count"] = tonumber(itemCount),
- ["duty"] = tonumber(itemDuty),
- ["slot"] = tonumber(itemSlot),
- ["health"] = tonumber(itemHealth),
- ["name"] = tostring(itemName),
- ["weaponserial"] = tostring(weaponserial),
- }
- if getElementType(elementSource) == "player" and weaponModels[itemID] then
- if isElement(weapons[elementSource][oldDBID]) then
- weapons[elementSource][id] = weapons[elementSource][oldDBID]
- end
- end
- getElementItems(playerSource, elementSource, 2)
- end
- end,{itemID,elementOwnerID,itemSlot},func["dbConnect"], "INSERT INTO `items` SET `itemid` = ?, `slot` = ?, `owner` = ?, `value` = ?, `count` = ?, `type` = ?, `dutyitem` = ?, `itemState` = ?, `name` = ?, `weaponserial` = ?",itemID, itemSlot, elementOwnerID, itemValue, itemCount, getTypeOfElement(elementSource,tonumber(itemID))[1], itemDuty,itemHealth,itemName,weaponserial)
- end
- end
- addEvent("createNewItem", true)
- addEventHandler("createNewItem", getRootElement(), createNewItem)
- function tradeItem(playerSource, elementSource, activeElementSource, activeItem,click)
- if (playerSource and elementSource and activeItem) then
- if click == 1 then
- local elementType = getTypeOfElement(elementSource)
- local itemDBID = activeItem["dbid"]
- local elementOwnerID = tonumber(getElementData(elementSource, elementType[2]))
- --local elementOwnerType = elementType[1]
- if not itemCache[elementSource] then
- itemCache[elementSource] = {
- ["bag"] = {},
- ["key"] = {},
- ["vehicle"] = {},
- ["object"] = {},
- }
- end
- local weight = getElementItemsWeight(elementSource)
- if weight + (getItemWeight(activeItem["id"]) * activeItem["count"]) > getTypeOfElement(elementSource)[3] then
- outputChatBox("[RiseMTA]:#ffffff A kiválaszott elem inventoryja nem bír el több tárgyat.", playerSource,172, 211, 115, true)
- triggerClientEvent(playerSource,"updateItemClick",playerSource)
- return
- end
- local pSlotState, pSlotID = getFreeSlot(elementSource, activeItem["id"])
- if (pSlotState and pSlotID) then
- local itemName = ""
- if #activeItem["name"] <= 0 then
- itemName = getItemName(activeItem["id"],tonumber(activeItem["value"]))
- else
- itemName = activeItem["name"]
- end
- if getElementType(elementSource) == "vehicle" and elementSource ~= playerSource and (activeItem["id"] == 176 and hasItem(elementSource,176,1)) then
- outputChatBox("[RiseMTA]:#ffffff A kiválaszott elem már rendelkezik egy ilyen tárggyal. #ACD373("..itemName..")", playerSource,172, 211, 115, true)
- elseif getElementType(elementSource) == "vehicle" and elementSource ~= playerSource and (activeItem["id"] == 177 and hasItem(elementSource,177,1)) then
- outputChatBox("[RiseMTA]:#ffffff A kiválaszott elem már rendelkezik egy ilyen tárggyal. #ACD373("..itemName..")", playerSource,172, 211, 115, true)
- else
- itemCache[activeElementSource][getTypeOfElement(activeElementSource,tonumber(activeItem["id"]))[1]][tonumber(activeItem["slot"])] = nil
- itemCache[elementSource][getTypeOfElement(elementSource,tonumber(activeItem["id"]))[1]][tonumber(pSlotID)] = {
- ["dbid"] = tonumber(activeItem["dbid"]),
- ["id"] = tonumber(activeItem["id"]),
- ["value"] = tostring(activeItem["value"]),
- ["count"] = tonumber(activeItem["count"]),
- ["duty"] = tonumber(activeItem["duty"]),
- ["slot"] = tonumber(pSlotID),
- ["health"] = tonumber(activeItem["health"]),
- ["name"] = tostring(activeItem["name"]),
- ["weaponserial"] = tostring(activeItem["weaponserial"]),
- }
- if getElementType(elementSource) == "player" and elementSource ~= playerSource then
- if isElement(getElementData(elementSource,"show:inv")) and getElementType(getElementData(elementSource,"show:inv")) == "player" then
- getElementItems(elementSource, elementSource, 2)
- end
- func["delActionbarItem"](activeElementSource,activeItem["dbid"])
- end
- getElementItems(playerSource, activeElementSource, 2)
- if getElementType(elementSource) == "player" and elementSource ~= playerSource then
- exports["rise_chat"]:sendLocalMeAction(playerSource,"átadott egy tárgyat "..string.gsub(getPlayerName(elementSource), "_", " ").." -nak/nek. ("..itemName..")")
- dbExec(func['dbConnect'], 'UPDATE items SET owner=?, type=?, slot=? WHERE id=?', getElementData(elementSource, 'char:id'), getTypeOfElement(elementSource, activeItem['id'])[1], pSlotID, activeItem['dbid'])
- itemAnim(playerSource,elementSource)
- if weaponModels[activeItem["id"]] then
- delAttachWeapon(playerSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
- addAttachWeapon(elementSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
- end
- elseif getElementType(elementSource) == "vehicle" and elementSource ~= playerSource then
- --local lampTable = exports["dm_vehiclelights"]:getLamp()
- --if lampTable[getElementModel(elementSource)] then
- --if activeItem["id"] == 176 then
- --exports["dm_vehiclelights"]:loadTaxilamp(elementSource)
- --end
- --end
- --local sirenTable = exports["dm_vehiclelights"]:getSiren()
- --if sirenTable[getElementModel(elementSource)] then
- --if activeItem["id"] == 177 then
- --exports["dm_vehiclelights"]:loadSiren(elementSource)
- --end
- --end
- exports["rise_chat"]:sendLocalMeAction(playerSource,"berakott egy tárgyat a jármű csomagtartójába. ("..itemName..")")
- dbExec(func['dbConnect'], 'UPDATE items SET owner=?, type=?, slot=? WHERE id=?', getElementData(elementSource, 'veh:id'), getTypeOfElement(elementSource, activeItem['id'])[1], pSlotID, activeItem['dbid'])
- if weaponModels[activeItem["id"]] then
- delAttachWeapon(playerSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
- end
- elseif getElementType(activeElementSource) == "vehicle" and elementSource == playerSource then
- --local lampTable = exports["dm_vehiclelights"]:getLamp()
- --if lampTable[getElementModel(activeElementSource)] then
- -- if activeItem["id"] == 176 then
- -- exports["dm_vehiclelights"]:destroyLamp(activeElementSource)
- -- end
- -- end
- -- local sirenTable = exports["dm_vehiclelights"]:getSiren()
- -- if sirenTable[getElementModel(activeElementSource)] then
- -- if activeItem["id"] == 177 then
- -- exports["dm_vehiclelights"]:destroySiren(activeElementSource)
- --end
- --end
- exports["rise_chat"]:sendLocalMeAction(playerSource,"kivett egy tárgyat a jármű csomagtartójából. ("..itemName..")")
- dbExec(func['dbConnect'], 'UPDATE items SET owner=?, type=?, slot=? WHERE id=?', getElementData(playerSource, 'char:id'), getTypeOfElement(playerSource, activeItem['id'])[1], pSlotID, activeItem['dbid'])
- if weaponModels[activeItem["id"]] then
- addAttachWeapon(playerSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
- end
- elseif getElementType(elementSource) == "object" and elementSource ~= playerSource then
- exports["rise_chat"]:sendLocalMeAction(playerSource,"berakott egy tárgyat a széfbe. ("..itemName..")")
- dbExec(func['dbConnect'], 'UPDATE items SET owner=?, type=?, slot=? WHERE id=?', getElementData(elementSource, 'dbid'), getTypeOfElement(elementSource, activeItem['id'])[1], pSlotID, activeItem['dbid'])
- if weaponModels[activeItem["id"]] then
- delAttachWeapon(playerSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
- end
- elseif getElementType(activeElementSource) == "object" and elementSource == playerSource then
- exports["rise_chat"]:sendLocalMeAction(playerSource,"kivett egy tárgyat a széfből. ("..itemName..")")
- dbExec(func['dbConnect'], 'UPDATE items SET owner=?, type=?, slot=? WHERE id=?', getElementData(playerSource, 'char:id'), getTypeOfElement(playerSource, activeItem['id'])[1], pSlotID, activeItem['dbid'])
- if weaponModels[activeItem["id"]] then
- addAttachWeapon(playerSource,activeItem["id"],activeItem["value"],activeItem["dbid"])
- end
- end
- end
- else
- outputChatBox("[RiseMTA]:#ffffff A kiválaszott elem inventoryja nem bír el több tárgyat.", playerSource,172, 211, 115, true)
- end
- triggerClientEvent(playerSource,"updateItemClick",playerSource)
- end
- end
- end
- addEvent("tradeItem", true)
- addEventHandler("tradeItem", getRootElement(), tradeItem)
- function getElementItemsWeight(element)
- local bagWeight = 0
- local keyWeight = 0
- local vehWeight = 0
- local objectWeight = 0
- if getElementType(element) == "player" then
- for i = 1, row * column do
- if (itemCache[element]["bag"][i]) then
- bagWeight = bagWeight + (getItemWeight(itemCache[element]["bag"][i]["id"]) * itemCache[element]["bag"][i]["count"])
- end
- end
- for i = 1, row * column do
- if (itemCache[element]["key"][i]) then
- keyWeight = keyWeight + (getItemWeight(itemCache[element]["key"][i]["id"]) * itemCache[element]["key"][i]["count"])
- end
- end
- end
- if getElementType(element) == "vehicle" then
- for i = 1, row * column do
- if (itemCache[element]["vehicle"][i]) then
- vehWeight = vehWeight + (getItemWeight(itemCache[element]["vehicle"][i]["id"]) * itemCache[element]["vehicle"][i]["count"])
- end
- end
- end
- if getElementType(element) == "object" then
- for i = 1, row * column do
- if (itemCache[element]["object"][i]) then
- objectWeight = objectWeight + (getItemWeight(itemCache[element]["object"][i]["id"]) * itemCache[element]["object"][i]["count"])
- end
- end
- end
- return math.ceil(bagWeight + keyWeight + vehWeight + objectWeight)
- end
- function hasItem(element,item,value)
- if not value then
- value = 1
- end
- for i = 1, row * column do
- if (itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]) then
- if tonumber(itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["id"]) == tonumber(item) then
- if value == -1 then
- if tonumber(itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["value"]) < 4 then
- return true,itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["id"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["value"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["dbid"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["count"]
- end
- elseif tonumber(itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["value"]) == tonumber(value) then
- return true,itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["id"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["value"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["dbid"],itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["count"]
- end
- end
- end
- end
- return false,-1,-1,-1,-1
- end
- function getItemCount(element,item,value)
- local r = 0
- for i = 1, row*column do
- if (itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]) then
- if tonumber(itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["id"]) == tonumber(item) then
- if not value then
- r = r + itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["count"]
- elseif value and value == itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["value"] then
- r = r + itemCache[element][getTypeOfElement(element,tonumber(item))[1]][i]["count"]
- end
- end
- end
- end
- return r
- end
- function hasItemCount(element,item,count,itemData)
- if not itemData then
- itemData = itemCache
- end
- for i = 1, row * column do
- if (itemData[element][getTypeOfElement(element,tonumber(item))[1]][i]) then
- if tonumber(itemData[element][getTypeOfElement(element,tonumber(item))[1]][i]["id"]) == tonumber(item) and tonumber(itemData[element][getTypeOfElement(element,tonumber(item))[1]][i]["count"]) >= tonumber(count) then
- return true
- end
- end
- end
- if count == -1 then
- return true
- end
- return false
- end
- function giveItem(playerSource, itemID, itemValue, itemCount, itemDuty, itemState,itemName,serial)
- local r = false
- if (playerSource and itemID and itemValue and itemCount and itemDuty) then
- if not itemState then
- itemState = 100
- else
- itemState = itemState
- end
- if not itemName then
- itemName = ""
- else
- itemName = itemName
- end
- if weaponModels[itemID] then
- weaponSerial = generateSerial()
- else
- --if itemID == 65 then
- -- weaponSerial = serial
- --else
- weaponSerial = ""
- --end
- end
- local elementType = getTypeOfElement(playerSource)
- local elementOwnerID = tonumber(getElementData(playerSource, elementType[2]))
- --local elementOwnerType = elementType[1]
- local pSlotState, pSlotID = getFreeSlot(playerSource, itemID)
- dbQuery(function(qh,itemID,elementOwnerID,pSlotID)
- local query, query_lines,id = dbPoll(qh, 0)
- local id = tonumber(id)
- if id > 0 then
- itemCache[playerSource][getTypeOfElement(playerSource,tonumber(itemID))[1]][tonumber(pSlotID)] = {
- ["dbid"] = tonumber(id),
- ["id"] = tonumber(itemID),
- ["value"] = tostring(itemValue),
- ["count"] = tonumber(itemCount),
- ["duty"] = tonumber(itemDuty),
- ["slot"] = tonumber(pSlotID),
- ["health"] = tonumber(itemState),
- ["name"] = tostring(itemName),
- ["weaponserial"] = tostring(weaponSerial),
- }
- if weaponModels[itemID] then
- addAttachWeapon(playerSource,itemID,itemValue,id)
- end
- if isElement(getElementData(playerSource,"show:inv")) and getElementType(getElementData(playerSource,"show:inv")) == "player" then
- getElementItems(playerSource, playerSource, 2)
- end
- r = true
- end
- end,{itemID,elementOwnerID,pSlotID},func["dbConnect"], "INSERT INTO `items` SET `itemid` = ?, `slot` = ?, `owner` = ?, `value` = ?, `count` = ?, `type` = ?, `dutyitem` = ?, `itemState` = ?, `name` = ?, `weaponserial` = ?",itemID, pSlotID, elementOwnerID, itemValue, itemCount, getTypeOfElement(playerSource,tonumber(itemID))[1], itemDuty, itemState,itemName,weaponSerial)
- end
- return r
- end
- addEvent("giveItem", true)
- addEventHandler("giveItem", root, giveItem)
- addCommandHandler("giveitem",function(playerSource, cmd, id, item, value, count,dutyitem, itemState)
- if getElementData(playerSource, "acc:admin") >= 6 then
- if id and item and value and count and dutyitem then
- local targetPlayer, targetPlayerName = exports['rise_core']:findPlayer(playerSource, id)
- if targetPlayer then
- if getElementData(targetPlayer,"loggedin") then
- local weight = getElementItemsWeight(targetPlayer)
- if weight + (getItemWeight(tonumber(item)) * tonumber(count)) > getTypeOfElement(targetPlayer)[3] then
- outputChatBox("[RiseMTA]:#ffffff A kiválasztott játékos nem bír el több tárgyat. #ACD373(Súly)", playerSource,172, 211, 115,true)
- return
- end
- local pSlotState, pSlotID = getFreeSlot(targetPlayer, tonumber(item))
- if pSlotState then
- if tonumber(item) == 47 or tonumber(item) == 48 or tonumber(item) == 71 or tonumber(item) == 72 then
- triggerEvent("givePlayerIdentity",targetPlayer,targetPlayer,tonumber(item))
- elseif tonumber(item) == 8 then
- exports.rise_phone:addPhone(targetPlayer)
- else
- giveItem(targetPlayer,tonumber(item),tostring(value),tonumber(count),tonumber(dutyitem))
- outputChatBox("[RiseMTA]:#ffffff Sikeresen adtál #ACD373"..string.gsub(getPlayerName(targetPlayer), "_", " ").."#ffffff -nak/nek #ACD373"..tonumber(count).."#ffffff darab #ACD373"..getItemName(tonumber(item),tostring(value)).."#ffffff -t.",playerSource,172, 211, 115,true)
- outputChatBox("[RiseMTA]:#ffffff Sikeresen kaptál #ACD373"..getElementData(playerSource,"char:anick").."#ffffff -tól/től #ACD373"..tonumber(count).."#ffffff darab #ACD373"..getItemName(tonumber(item),tostring(value)).."#ffffff -t.",targetPlayer,172, 211, 115,true)
- end
- else
- outputChatBox("[RiseMTA]:#ffffff A kiválasztott játékos nem bír el több tárgyat. #ACD373(Slot)", playerSource,172, 211, 115,true)
- end
- else
- outputChatBox("[RiseMTA]:#ffffff A kiválasztott játékos nincs bejelentkezve.", playerSource,172, 211, 115,true)
- end
- end
- else
- outputChatBox("Használat:#ffffff /"..cmd.." [NÉVRÉSZLET/ID] [ItemID] [érték] [db] [dutyItem: 0=Nem , 1=Igen]", playerSource,172, 211, 115,true)
- end
- end
- end)
- addCommandHandler("changelock",function(playerSource,cmd,typ)
- if getElementData(playerSource,"acc:admin") >= 7 then
- if typ then
- typ = tostring(typ)
- if typ == "vehicle" then
- local veh = getPedOccupiedVehicle(playerSource)
- if isElement(veh) then
- local dbid = getElementData(veh,"veh:id")
- takeAllItem(0,dbid)
- giveItem(playerSource,0,dbid,1,0)
- outputChatBox("[RiseMTA]:#ffffff Sikeresen changelock-oltál egy járművet. #ACD373("..dbid..")", playerSource,172, 211, 115, true)
- else
- outputChatBox("[RiseMTA]:#ffffff Nem ülsz járműben.", playerSource,172, 211, 115, true)
- end
- elseif typ == "interior" then
- if getElementData(playerSource, "isInIntMarker") then
- local theMarkElement = getElementData(playerSource,"int:Marker")
- if getElementData(theMarkElement,"isIntMarker") then
- local dbid = getElementData(theMarkElement,"int:id")
- takeAllItem(1,dbid)
- giveItem(playerSource,1,dbid,1,0)
- outputChatBox("[RiseMTA]:#ffffff Sikeresen changelock-oltál egy interiort. #ACD373("..dbid..")", playerSource,172, 211, 115, true)
- end
- else
- outputChatBox("[DoubleMTA - Interior]:#ffffff Nem állsz interior marker-ben.",playerSource,172, 211, 115,true)
- end
- end
- else
- outputChatBox("Használat:#ffffff /"..cmd.." [tipus: vehicle, interior]", playerSource,172, 211, 115, true)
- end
- end
- end)
- addCommandHandler("delplayeritem",function(playerSource,cmd,who,category,slot)
- if getElementData(playerSource,"acc:admin") >= 7 then
- if who and category and slot then
- if category == "bag" or category == "key" then
- slot = tonumber(slot)
- if type(slot) == "number" then
- local targetPlayer, targetPlayerName = exports['rise_core']:findPlayer(playerSource,who)
- if targetPlayer then
- if(itemCache[targetPlayer][category])then
- if(itemCache[targetPlayer][category][slot])then
- outputChatBox("[RiseMTA]:#ffffff Sikeresen töröltél #ACD373"..getPlayerName(targetPlayer):gsub("_", " ").."#ffffff -tól/től egy #D23131"..getItemName(itemCache[targetPlayer][category][slot]["id"],itemCache[targetPlayer][category][slot]["value"]).."#ffffff -t.",playerSource,172, 211, 115, true)
- outputChatBox("[RiseMTA]:#ffffff Sikeresen törölt tőled #ACD373"..getElementData(targetPlayer,"anev").."#ffffff egy #D23131"..getItemName(itemCache[targetPlayer][category][slot]["id"],itemCache[targetPlayer][category][slot]["value"]).."#ffffff -t.",targetPlayer,172, 211, 115, true)
- if(weaponModels[itemCache[targetPlayer][category][slot]["id"]])then
- delAttachWeapon(targetPlayer,itemCache[targetPlayer][category][slot]["id"],itemCache[targetPlayer][category][slot]["value"],itemCache[targetPlayer][category][slot]["dbid"])
- end
- deleteItem(targetPlayer,targetPlayer,itemCache[targetPlayer][category][slot])
- else
- outputChatBox("[RiseMTA]:#ffffff A kiválaszott játékosnak a #7cc576'"..category.."'#ffffff inventoryjában nincs ezen a sloton item. #ACD373("..slot..")", playerSource,172, 211, 115, true)
- end
- end
- end
- else
- outputChatBox("[RiseMTA]:#ffffff A slot csak szám lehet.", playerSource,172, 211, 115, true)
- end
- else
- outputChatBox("[RiseMTA]:#ffffff A kategória csak bag, key lehet.", playerSource,172, 211, 115, true)
- end
- else
- outputChatBox("Használat:#ffffff /"..cmd.." [ID/Név] [category: bag,key] [slot]", playerSource,172, 211, 115, true)
- end
- end
- end)
- function addPhone(playerSource,typ)
- local thePhoneNumber = math.random(7868771+getElementData(playerSource,"dbid"),7968771+getElementData(playerSource,"playerid"))
- dbQuery(function(qh, playerSource)
- local res, rows, err = dbPoll(qh, 0)
- if rows > 0 then
- giveItem(playerSource,174,thePhoneNumber,1,0)
- end
- end, {playerSource}, func["dbConnect"],"INSERT INTO phones SET phoneNumber = ?, type = ?, date = NOW()",tonumber(thePhoneNumber),tostring(typ))
- end
- addEvent("addPhone",true)
- addEventHandler("addPhone",getRootElement(),addPhone)
- function getFreeSlot(elementSource, forItemID)
- local nextSlot = 1
- for i = 1, (row * column) do
- if not (itemCache[elementSource][getTypeOfElement(elementSource,tonumber(forItemID))[1]][i]) then
- return true, nextSlot
- else
- nextSlot = nextSlot + 1
- end
- end
- return false, -1
- end
- function doorState(vehicle,typ)
- if typ == 1 then
- setVehicleDoorOpenRatio(vehicle,1,1,1200)
- --setElementData(vehicle,"veh:use",true)
- --setElementData(vehicle,"veh:player",source)
- else
- setVehicleDoorOpenRatio(vehicle,1,0,1200)
- --setElementData(vehicle,"veh:use",false)
- --setElementData(vehicle,"veh:player",nil)
- end
- end
- addEvent("doorState", true)
- addEventHandler("doorState", root, doorState)
- function itemAnim(element, targetElement)
- if isElement(element) and isElement(targetElement) then
- setPedAnimation(element,"DEALER","DEALER_DEAL",3000,false,false,false,false)
- setPedAnimation(targetElement,"DEALER","DEALER_DEAL",3000,false,false,false,false)
- end
- end
- addEvent("itemAnim", true)
- addEventHandler("itemAnim", root, itemAnim)
- function takeItem(playerSource,item)
- local elem = 0
- if itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]] then
- for i = 1, row * column do
- if (itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]) then
- if itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["id"] == item then
- elem = elem+1
- if elem == 1 then
- if itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["count"] > 1 then
- itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["count"] = itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["count"]-1
- getElementItems(playerSource, playerSource, 2)
- else
- if weaponModels[itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["id"]] then
- delAttachWeapon(playerSource,itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["id"],itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["value"],itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i]["dbid"])
- end
- deleteItem(playerSource,playerSource,itemCache[playerSource][getTypeOfElement(playerSource,tonumber(item))[1]][i])
- end
- end
- end
- end
- end
- end
- end
- function takeAllItem(item,value)
- for k,v in ipairs(getElementsByType("vehicle")) do
- if getElementData(v,"dbid") > 0 then
- if itemCache[v] then
- if itemCache[v][getTypeOfElement(v,tonumber(item))[1]] then
- for i = 1, row * column do
- if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i] then
- if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"] == tonumber(item) and tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["value"]) == tonumber(value) then
- itemCache[v][getTypeOfElement(v,tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"]))[1]][tonumber(i)] = nil
- if isElement(getElementData(v, "veh:player")) then
- getElementItems(getElementData(v, "veh:player"),v,1)
- end
- end
- end
- end
- end
- end
- end
- end
- for k,v in ipairs(getElementsByType("object")) do
- if getElementData(v,"szef") and getElementData(v,"dbid") > 0 then
- if itemCache[v][getTypeOfElement(v,tonumber(item))[1]] then
- for i = 1, row * column do
- if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i] then
- if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"] == tonumber(item) and tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["value"]) == tonumber(value) then
- itemCache[v][getTypeOfElement(v,tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"]))[1]][tonumber(i)] = nil
- if isElement(getElementData(v, "safe:player")) then
- getElementItems(getElementData(v, "safe:player"),v,1)
- end
- end
- end
- end
- end
- end
- end
- for k,v in ipairs(getElementsByType("player")) do
- if getElementData(v,"loggedin") then
- if itemCache[v] then
- if itemCache[v][getTypeOfElement(v,tonumber(item))[1]] then
- for i = 1, row * column do
- if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i] then
- if itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"] == tonumber(item) and tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["value"]) == tonumber(value) then
- itemCache[v][getTypeOfElement(v,tonumber(itemCache[v][getTypeOfElement(v,tonumber(item))[1]][i]["id"]))[1]][tonumber(i)] = nil
- if isElement(getElementData(v,"show:inv")) and getElementType(getElementData(v,"show:inv")) == "player" then
- getElementItems(v,v,2)
- end
- end
- end
- end
- end
- end
- end
- end
- dbQuery(function(query)
- local query, query_lines = dbPoll(query, 0)
- for k, row in pairs (query) do
- dbExec(func["dbConnect"],"DELETE FROM `items` WHERE `id` = ?",row["id"])
- end
- end, func["dbConnect"], "SELECT * FROM `items` WHERE `value` = ? AND `itemid` = ?",tonumber(value),tonumber(item))
- end
- function RemovePlayerDutyItems(element) -- duty cuccok
- if element and itemCache[element] and itemCache[element]["bag"] then
- for i = 1, row * column do
- if (itemCache[element]["bag"][i]) then
- if itemCache[element]["bag"][i]["duty"] == 1 then
- if weaponModels[itemCache[element]["bag"][i]["id"]] then
- delAttachWeapon(element,itemCache[element]["bag"][i]["id"],itemCache[element]["bag"][i]["value"],itemCache[element]["bag"][i]["dbid"])
- end
- deleteItem(element,element,itemCache[element]["bag"][i])
- end
- end
- end
- end
- end
- addEvent("RemovePlayerDutyItems", true)
- addEventHandler("RemovePlayerDutyItems",getRootElement(),RemovePlayerDutyItems)
- function deleteItemByID(element, itemID, itemPrice)
- for k,v in ipairs(getElementsByType("player")) do
- if getElementData(v,"loggedin") then
- if itemCache[v] then
- if itemCache[v][getTypeOfElement(v,tonumber(itemID))[1]] then
- for i = 1, row * column do
- if itemCache[v][getTypeOfElement(v,tonumber(itemID))[1]][i] then
- if itemCache[v][getTypeOfElement(v,tonumber(itemID))[1]][i]["id"] == tonumber(itemID) then
- itemCache[v][getTypeOfElement(v,tonumber(itemCache[v][getTypeOfElement(v,tonumber(itemID))[1]][i]["id"]))[1]][tonumber(i)] = nil
- if isElement(getElementData(v,"show:inv")) and getElementType(getElementData(v,"show:inv")) == "player" then
- getElementItems(v,v,2)
- end
- end
- end
- end
- end
- end
- end
- end
- dbQuery(function(query)
- local query, query_lines = dbPoll(query, 0)
- for k, row in pairs (query) do
- dbExec(func["dbConnect"],"DELETE FROM `items` WHERE `id` = ?",row["id"])
- end
- end, func["dbConnect"], "SELECT * FROM `items` WHERE `itemid` = ?",tonumber(itemID))
- end
- function addAttachWeapon(playerSource,item,value,dbid)
- --[[
- if not weapons[playerSource] then
- weapons[playerSource] = {}
- end
- if not isElement(weapons[playerSource][dbid]) or not weapons[playerSource][dbid] then
- local x,y,z = getElementPosition(playerSource)
- if weaponModels[item] then
- weapons[playerSource][dbid] = createObject(weaponModels[item][1],x,y,z)
- setElementInterior(weapons[playerSource][dbid],getElementInterior(playerSource))
- setElementDimension(weapons[playerSource][dbid],getElementDimension(playerSource))
- setElementData(weapons[playerSource][dbid],"attachedObject",true)
- if tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 264 then
- exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/camo")
- elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 265 then
- exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/camo2")
- elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 266 then
- exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/camo3")
- elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 267 then
- exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/gold")
- elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 268 then
- exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/gold2")
- elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 269 then
- exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/silver")
- elseif tonumber(weaponIndexByID[item]) == 30 and tonumber(item) == 270 then
- exports["rise_weapontuning"]:setObjectPaintjob(weapons[playerSource][dbid],"ak", "ak/kitty")
- end
- exports.bone_attach:attachElementToBone(weapons[playerSource][dbid], playerSource,weaponPositions[tonumber(weaponIndexByID[item])][1],weaponPositions[tonumber(weaponIndexByID[item])][2],weaponPositions[tonumber(weaponIndexByID[item])][3],weaponPositions[tonumber(weaponIndexByID[item])][4],weaponPositions[tonumber(weaponIndexByID[item])][5],weaponPositions[tonumber(weaponIndexByID[item])][6],weaponPositions[tonumber(weaponIndexByID[item])][7])
- end
- end
- ]]
- end
- addEvent("addAttachWeapon",true)
- addEventHandler("addAttachWeapon",getRootElement(),addAttachWeapon)
- function delAttachWeapon(playerSource,item,value,dbid)
- --[[
- if weapons[playerSource] then
- if isElement(weapons[playerSource][dbid]) then
- if tonumber(item) == 84 and tonumber(value) == 20 then
- exports["rise_weapontuning"]:removeStickerFromObject(object)
- end
- exports.bone_attach:detachElementFromBone(weapons[playerSource][dbid])
- destroyElement(weapons[playerSource][dbid])
- weapons[playerSource][dbid] = {}
- end
- end
- ]]
- end
- addEvent("delAttachWeapon",true)
- addEventHandler("delAttachWeapon",getRootElement(),delAttachWeapon)
- addEventHandler("onPlayerQuit",getRootElement(),function()
- if getElementData(source,"loggedin") then
- saveOneElementInventory(source)
- for i = 1, row * column do
- if (itemCache[source]["bag"][i]) then
- if weapons[source] then
- if isElement(weapons[source][itemCache[source]["bag"][i]["dbid"]]) then
- exports.bone_attach:detachElementFromBone(weapons[source][itemCache[source]["bag"][i]["dbid"]])
- destroyElement(weapons[source][itemCache[source]["bag"][i]["dbid"]])
- end
- end
- end
- end
- weapons[source] = {}
- end
- end)
- --Actionbar server--
- addEvent("moveItemToActionBar",true)
- addEventHandler("moveItemToActionBar", getRootElement(),function(playerSource,itemdbid,item,category,actionslot)
- local dbid = tonumber(getElementData(playerSource, "acc:id"))
- dbExec(func["dbConnect"],"INSERT INTO actionbaritems SET itemdbid = ?, item = ?, owner = ?, category = ?, actionslot = ?",itemdbid,item,dbid,category,actionslot)
- end)
- function deleteActionBarItem(player,actionslot)
- local dbid = tonumber(getElementData(player, "acc:id"))
- dbExec(func["dbConnect"], "DELETE FROM `actionbaritems` WHERE owner=? and actionslot=?", dbid, actionslot)
- end
- addEvent("deleteActionBarItem",true)
- addEventHandler("deleteActionBarItem", getRootElement(), deleteActionBarItem)
- function loadActionBarItems(playerSource)
- local dbid = getElementData(playerSource,"acc:id")
- local loadedTables = {}
- dbQuery(function(qh)
- local res, rows, err = dbPoll(qh, 0)
- if rows > 0 then
- for k, row in pairs(res) do
- loadedTables[#loadedTables+1] = {["id"] = tonumber(row["id"]),["owner"] = tonumber(row["owner"]),["itemdbid"] = tonumber(row["itemdbid"]),["item"] = tonumber(row["item"]),["category"] = tostring(row["category"]),["actionslot"] = tonumber(row["actionslot"])}
- end
- end
- triggerClientEvent(playerSource,"actionBarEvent",playerSource,playerSource,loadedTables)
- end,func["dbConnect"],"SELECT * FROM actionbaritems WHERE owner=?",dbid)
- end
- addEvent("loadActionBarItems",true)
- addEventHandler("loadActionBarItems",getRootElement(),loadActionBarItems)
- addEvent("takeTicket",true)
- addEventHandler("takeTicket",getRootElement(),function(playerSource,id)
- dbQuery(function(query)
- local query, query_lines = dbPoll(query, 0)
- for k, row in pairs (query) do
- outputChatBox("[RiseMTA]:#ffffff Mivel nem fizetted be a csekket, ezért a bírság összegének a dupláját vonta le a rendszer, ami #ACD373"..(row["amount"]*2).."#ffffff dollár.",playerSource,172, 211, 115,true)
- setElementData(playerSource,"money",getElementData(playerSource,"money") -(row["amount"]*2))
- dbExec(func["dbConnect"], "DELETE FROM `tickets` WHERE id=?",id)
- end
- end, func["dbConnect"], "SELECT * FROM `tickets` WHERE `id` = ?", tonumber(id))
- end)
Add Comment
Please, Sign In to add comment