Hab mal eine Frage. Wenn ich im Shop was kaufe oder verkaufe wird mein Geld Betrag zwar angepasst jedoch wird er beim Quiten des Servers nicht gespeichert. Hier der Shop:
local screenW, screenH = guiGetScreenSize()
local tables = {gridlist = {},window = {},button = {},label = {},column = {}}
local category = {
{"Primary Weapons"},
{"Secondary Weapons"},
{"Special Weapons"},
{"Rare Items"},
{"Ammo"},
{"Food and Drink"},
{"Backpacks"},
{"Clothings"},
{"Medic"},
{"Armor"},
{"Items and Tools"},
{"Vehicles"},
}
local items = {
["Vehicles"] = {
{vehicleName = "Mustang Frank",vehicleID = 411,engine = 1,tires = 4,parts = 1,slots=60,price=50000},
},
["Primary Weapons"] = {
{itemName = "RPK", slots = 3,price_buy = 4700,price_sell = 2350,number = 1},
{itemName = "Winchester Model 70", slots = 3,price_buy = 5250,price_sell = 2625,number = 1},
{itemName = "AKM", slots = 3,price_buy = 3250,price_sell = 1725,number = 1},
{itemName = "AK-107", slots = 3,price_buy = 3250,price_sell = 1625,number = 1},
{itemName = "M4A1", slots = 3,price_buy = 3250,price_sell = 1625,number = 1},
{itemName = "AKS-74 Kobra", slots = 3,price_buy = 3250,price_sell = 1625,number = 1},
{itemName = "SVD", slots = 3,price_buy = 5100,price_sell = 2550,number = 1},
},
["Secondary Weapons"] = {
{itemName = "M1911",slots = 2,price_buy = 600,price_sell = 300,number = 1},
{itemName = "Makarov SD",slots = 2,price_buy = 600,price_sell = 300,number = 1},
{itemName = "Glock 18",slots = 2,price_buy = 600,price_sell = 300,number = 1},
{itemName = "Makarov",slots = 2,price_buy = 600,price_sell = 300,number = 1},
{itemName = "Revolver",slots = 2,price_buy = 600,price_sell = 300,number = 1},
{itemName = "MP5A5",slots = 3,price_buy = 600,price_sell = 300,number = 1},
{itemName = "MP5 SD",slots = 3,price_buy = 600,price_sell = 300,number = 1},
},
["Special Weapons"] = {
{itemName = "Molotov",slots = 1,price_buy = 300,price_sell = 150,number = 1},
{itemName = "M67",slots = 1,price_buy = 300,price_sell = 150,number = 1},
{itemName = "Tear Gas",slots = 1,price_buy = 300,price_sell = 150,number = 1},
},
["Ammo"] = {
{itemName = "STANAG Mag",slots = 0.085,price_buy = 750,price_sell = 375,number = 30},
{itemName = "AK Mag",slots = 0.035,price_buy = 750,price_sell = 375,number = 30},
{itemName = ".308 Rounds",slots = 0.085,price_buy = 2250,price_sell = 1125,number = 5},
{itemName = "7.62×39",slots = 0.050,price_buy = 2250,price_sell = 1125,number = 100},
{itemName = "7.62x54",slots = 0.1,price_buy = 2200,price_sell = 1100,number = 5},
{itemName = "9 mm",slots = 0.085,price_buy = 400,price_sell = 200,number = 7},
{itemName = ".357",slots = 0.085,price_buy = 400,price_sell = 200,number = 7},
{itemName = "MP5A5 Mag",slots = 0.025,price_buy = 600,price_sell = 300,number = 20},
},
["Food and Drink"] = {
{itemName = "Pizza",slots = 1,price_buy = 250,price_sell = 125,number = 1},
{itemName = "Milk",slots = 1,price_buy = 250,price_sell = 125,number = 1},
{itemName = "Water Bottle",slots = 1,price_buy = 250,price_sell = 125,number = 1},
},
["Backpacks"] = {
{itemName = "Coyote Mossy Backpack",slots = 1,price_buy = 7500,price_sell = 3250,number = 1},
{itemName = "Camouflage Assault Backpack",slots = 1,price_buy = 4500,price_sell = 2250,number = 1},
{itemName = "LHT Ghillie Backpack",slots = 1,price_buy = 2500,price_sell = 1250,number = 1},
{itemName = "Hunting Backpack",slots = 1,price_buy = 6000,price_sell = 3000,number = 1},
{itemName = "Tortilla Backpack",slots = 1,price_buy = 8450,price_sell = 4225,number = 1},
},
["Rare Items"] = {
{itemName = "Dragon Lore (Special)",slots = 3,price_buy = 300000,price_sell = 150000,number = 1},
{itemName = "Karambit (Special)",slots = 2,price_buy = 350000,price_sell = 200000,number = 1},
{itemName = "USP-S Torque (Special)",slots = 2,price_buy = 150000,price_sell = 80000,number = 1},
},
["Clothings"] = {
{itemName = "Ghillie Suit",slots = 1,price_buy = 900,price_sell = 450,number = 1},
{itemName = "Ghillie Desert",slots = 1,price_buy = 900,price_sell = 450,number = 1},
{itemName = "Civilian[F] Clothing",slots = 1,price_buy = 900,price_sell = 450,number = 1},
{itemName = "Your Custom CJ Skin",slots = 1,price_buy = 900,price_sell = 450,number = 1},
{itemName = "Ghillie[F] Suit",slots = 1,price_buy = 900,price_sell = 450,number = 1},
},
["Medic"] = {
{itemName = "Medic Kit",slots = 2,price_buy = 500,price_sell = 250,number = 1},
{itemName = "Antidot",slots = 1,price_buy = 400,price_sell = 200,number = 1},
{itemName = "Painkiller",slots = 1,price_buy = 400,price_sell = 200,number = 1},
{itemName = "Bandage",slots = 1,price_buy = 400,price_sell = 200,number = 1},
{itemName = "Morphine",slots = 1,price_buy = 500,price_sell = 250,number = 1},
},
["Armor"] = {
{itemName = "Ballistic Bulletproof Vest",slots = 1,price_buy = 12000,price_sell = 6000,number = 1},
{itemName = "Press Vest Blue",slots = 1,price_buy = 12000,price_sell = 6000,number = 1},
{itemName = "Army Bulletproof Vest",slots = 1,price_buy = 12000,price_sell = 6000,number = 1},
{itemName = "Police Bulletproof Vest",slots = 1,price_buy = 12000,price_sell = 6000,number = 1},
{itemName = "Durable Bulletproof Vest",slots = 1,price_buy = 12000,price_sell = 6000,number = 1},
{itemName = "Balaclava",slots = 1,price_buy = 2500,price_sell = 800,number = 1},
{itemName = "Gas Mask",slots = 1,price_buy = 2500,price_sell = 800,number = 1},
{itemName = "Psycho Mask",slots = 1,price_buy = 2500,price_sell = 800,number = 1},
{itemName = "Dallas Mask",slots = 1,price_buy = 2500,price_sell = 800,number = 1},
{itemName = "Tactical Helmet",slots = 1,price_buy = 10000,price_sell = 5000,number = 1},
{itemName = "Camouflage Helmetk",slots = 1,price_buy = 10000,price_sell = 5000,number = 1},
{itemName = "Helmet",slots = 1,price_buy = 10000,price_sell = 5000,number = 1},
{itemName = "Ballistic Helmet",slots = 1,price_buy = 10000,price_sell = 5000,number = 1},
{itemName = "Police Helmet",slots = 1,price_buy = 10000,price_sell = 5000,number = 1},
},
["Items and Tools"] = {
{itemName = "Tire",slots = 2,price_buy = 2000,price_sell = 1000,number = 1},
{itemName = "Engine",slots = 5,price_buy = 4000,price_sell = 2000,number = 1},
{itemName = "GPS",slots = 0.5,price_buy = 300,price_sell = 150,number = 1},
{itemName = "Map",slots = 0.5,price_buy = 300,price_sell = 150,number = 1},
{itemName = "Tank Parts",slots = 3,price_buy = 2000,price_sell = 1000,number = 1},
{itemName = "Watch",slots = 0.5,price_buy = 300,price_sell = 150,number = 1},
{itemName = "Toolbox",slots = 0.5,price_buy = 300,price_sell = 150,number = 1},
{itemName = "Compass",slots = 0.5,price_buy = 300,price_sell = 150,number = 1},
{itemName = "Tent",slots = 2,price_buy = 1500,price_sell = 750,number = 1},
{itemName = "Full Gas Canister",slots = 2,price_buy = 1500,price_sell = 750,number = 1},
{itemName = "Ganja",slots = 1,price_buy = 200000,price_sell = 100000,number = 1},
},
}
addEventHandler("onClientResourceStart",resourceRoot,
function()
tables.window[1] = guiCreateWindow((screenW - 726) / 2, (screenH - 440) / 2, 726, 440, "Revolution DayZ Shop", false)
guiWindowSetSizable(tables.window[1], false)
tables.gridlist[1] = guiCreateGridList(9, 28, 177, 222, false, tables.window[1])
tables.column[1] = guiGridListAddColumn(tables.gridlist[1], "Categories", 0.9)
tables.gridlist[2] = guiCreateGridList(196, 28, 520, 402, false, tables.window[1])
guiGridListSetSortingEnabled(tables.gridlist[2],false)
tables.column[2] = guiGridListAddColumn(tables.gridlist[2], "Name", 0.5)
tables.column[3] = guiGridListAddColumn(tables.gridlist[2], "Purchase", 0.1)
tables.column[4] = guiGridListAddColumn(tables.gridlist[2], "Selling", 0.1)
tables.column[5] = guiGridListAddColumn(tables.gridlist[2], "number", 0.1)
tables.button[1] = guiCreateButton(10, 350, 176, 25, "Buy", false, tables.window[1])
tables.button[2] = guiCreateButton(10, 315, 176, 25, "Sell", false, tables.window[1])
tables.label[1] = guiCreateLabel(10, 260, 176, 45, "Your Money: $", false, tables.window[1])
tables.button[3] = guiCreateButton(10, 385, 176, 25, "Close", false, tables.window[1])
for i, data in ipairs(category) do
local row = guiGridListAddRow(tables.gridlist[1])
guiGridListSetItemText(tables.gridlist[1],row,tables.column[1],tostring(data[1]),false,false)
end
addEventHandler("onClientGUIClick",tables.gridlist[1],
function()
columnName = guiGridListGetItemText(tables.gridlist[1],guiGridListGetSelectedItem(tables.gridlist[1]),1)
if columnName then
guiGridListClear(tables.gridlist[2])
if columnName ~= "Vehicles" then
if items[columnName] then
for i, data in ipairs(items[columnName]) do
local row = guiGridListAddRow(tables.gridlist[2])
guiGridListSetItemText(tables.gridlist[2],row,tables.column[2],tostring(data.itemName),false,false)
guiGridListSetItemText(tables.gridlist[2],row,tables.column[3],tostring(data.price_buy),false,false)
guiGridListSetItemText(tables.gridlist[2],row,tables.column[4],tostring(data.price_sell),false,false)
guiGridListSetItemText(tables.gridlist[2],row,tables.column[5],tostring(data.number),false,false)
end
guiSetEnabled(tables.button[2],true)
else
outputDebugString("not column for shop")
end
else
for i, data in ipairs(items["Vehicles"]) do
local row = guiGridListAddRow(tables.gridlist[2])
guiGridListSetItemText(tables.gridlist[2],row,tables.column[2],tostring(data.vehicleName),false,false)
guiGridListSetItemText(tables.gridlist[2],row,tables.column[3],tostring(data.price),false,false)
guiGridListSetItemText(tables.gridlist[2],row,tables.column[4],"Can not Sell",false,false)
guiGridListSetItemText(tables.gridlist[2],row,tables.column[5],"-",false,false)
end
guiSetEnabled(tables.button[2],false)
end
end
end,false)
addEventHandler("onClientGUIClick",tables.button[3],function()
guiSetVisible(tables.window[1],false)
showCursor(false)
setElementData(localPlayer,"currentShop",nil)
end,false)
addEventHandler("onClientGUIClick",tables.button[1],
function()
local itemName = guiGridListGetItemText(tables.gridlist[2],guiGridListGetSelectedItem(tables.gridlist[2]),1)
local buyPrice = guiGridListGetItemText(tables.gridlist[2],guiGridListGetSelectedItem(tables.gridlist[2]),2)
if buyPrice then
if delayButtonsInventory then
outputChatBox("You can not do it very often!")
return
end
if (getPlayerMoney(localPlayer) or 0) - tonumber(buyPrice) >= 0 then
if (delayButtonBuy or 0) > getTickCount() then
return
end
if not delayButtonBuy then
delayButtonBuy = getTickCount() + 2500
end
guiSetEnabled(tables.button[1],false)
setTimer(guiSetEnabled,2500,1,tables.button[1],true)
for _, vehicle in ipairs(items["Vehicles"]) do
if itemName == vehicle.vehicleName then
if getElementData(resourceRoot,"serv:time") <= (getElementData(localPlayer,"tick.vehicle") or 0) then
outputChatBox("The machine can be bought every 10 minutes!",231,217,176,true)
return
end
triggerServerEvent("shop:spawnVehicle",localPlayer,vehicle.vehicleID,vehicle.engine,vehicle.tires,vehicle.parts,vehicle.slots)
--setPlayerMoney(localPlayer,(getPlayerMoney(localPlayer) or 0 ) - tonumber(buyPrice))
--setPlayerMoney(getPlayerMoney() - tonumber(buyPrice))
setPlayerMoney (source,getPlayerMoney(source) - tonumber(buyPrice))
setElementData(getElementData(localPlayer,"currentShop"),"shop:money",getElementData(getElementData(localPlayer,"currentShop"),"shop:money") + tonumber(buyPrice))
guiSetText(tables.label[1],"Your money: "..tostring(getPlayerMoney(localPlayer) or 0).."$\nmoney Shop: "..tostring(getElementData(getElementData(localPlayer,"currentShop"),"shop:money") or 0).."$")
return
end
end
if getItemSlotsPlus(itemName) then
outputChatBox("Your inventory is full!") return end
--setPlayerMoney(localPlayer,(getPlayerMoney(localPlayer) or 0 ) - tonumber(buyPrice))
setPlayerMoney(getPlayerMoney() - tonumber(buyPrice))
setElementData(getElementData(localPlayer,"currentShop"),"shop:money",getElementData(getElementData(localPlayer,"currentShop"),"shop:money") + tonumber(buyPrice))
guiSetText(tables.label[1],"Your money: "..tostring(getPlayerMoney(localPlayer) or 0).."$\nmoney Shop: "..tostring(getElementData(getElementData(localPlayer,"currentShop"),"shop:money") or 0).."$")
outputChatBox("You bought an item '"..itemName.."' by price "..tonumber(buyPrice).." For "..returnItemNumber().." Piece.")
setElementData(localPlayer,itemName,getElementData(localPlayer,itemName) + returnItemNumber())
refreshInventory()
---------------------------------------------------------
delayButtonsInventory = true
setTimer(function()
delayButtonsInventory = false
end,500,1)
else
outputChatBox("Sorry, but you do not have enough money!")
end
end
end,false)
addEventHandler("onClientGUIClick",tables.button[2],
function()
local itemName = guiGridListGetItemText(tables.gridlist[2],guiGridListGetSelectedItem(tables.gridlist[2]),1)
local sellPrice = guiGridListGetItemText(tables.gridlist[2],guiGridListGetSelectedItem(tables.gridlist[2]),3)
if items[columnName] then
for i, data in ipairs(items[columnName]) do
if itemName == tostring(data.itemName) then
sellPrice = tonumber(data.price_sell)
end
end
end
if sellPrice then
if delayButtonsInventory then
outputChatBox("You can not do it very often!")
return
end
if getElementData(getElementData(localPlayer,"currentShop"),"shop:money") - tonumber(sellPrice) >= 0 then
if getElementData(localPlayer,itemName) < returnItemNumber() then
outputChatBox("You do not have this item or it is not enough!")
return
end
setPlayerMoney (getPlayerMoney() + tonumber(sellPrice))
setElementData(getElementData(localPlayer,"currentShop"),"shop:money",getElementData(getElementData(localPlayer,"currentShop"),"shop:money") - tonumber(sellPrice))
guiSetText(tables.label[1],"Your money: "..tostring(getPlayerMoney(localPlayer) or 0).."$\nmoney Shop: "..tostring(getElementData(getElementData(localPlayer,"currentShop"),"shop:money") or 0).."$")
setElementData(localPlayer,itemName,getElementData(localPlayer,itemName) - returnItemNumber())
outputChatBox("You sell the item '"..itemName.."' by price "..tonumber(sellPrice).." for "..returnItemNumber().." Piece.")
refreshInventory()
---------------------------------------------------------
delayButtonsInventory = true
setTimer(function()
delayButtonsInventory = false
end,500,1)
else
outputChatBox("Sorry, but the store does not have enough money to buy!")
end
end
end,false)
guiSetVisible(tables.window[1],false)
end)
function onClientMarkerHit(elementHit,matchingDimension)
if getElementType(elementHit) == "player" and elementHit == localPlayer and getElementData(source,"shop:ID") then
setElementData(elementHit,"currentShop",source)
guiSetVisible(tables.window[1],not guiGetVisible(tables.window[1]))
guiSetText(tables.label[1],"Your money: "..tostring(getPlayerMoney(localPlayer) or 0).."$\nmoney Shop: "..tostring(getElementData(getElementData(localPlayer,"currentShop"),"shop:money") or 0).."$")
showCursor(guiGetVisible(tables.window[1]))
end
end
addEventHandler("onClientMarkerHit",getRootElement(),onClientMarkerHit)
function onClientMarkerLeave(elementHit,matchingDimension)
if getElementType(elementHit) == "player" and elementHit == localPlayer and getElementData(source,"shop:ID") then
guiSetVisible(tables.window[1],false)
showCursor(false)
setElementData(elementHit,"currentShop",nil)
end
end
addEventHandler("onClientMarkerLeave",getRootElement(),onClientMarkerLeave)
function getItemSlotsPlus(selectItem)
for i, column in ipairs(category) do
for i, data in ipairs(items[column[1]]) do
if selectItem == data.itemName then
local currentSlots = getPlayerCurrentSlots() + data.slots * returnItemNumber()
if currentSlots <= getElementData(localPlayer,"MAX_Slots") then
return false
end
end
end
end
return true
end
function returnItemNumber()
for i, column in ipairs(category) do
for i, data in ipairs(items[column[1]]) do
if guiGridListGetItemText(tables.gridlist[2],guiGridListGetSelectedItem(tables.gridlist[2]),1) == data.itemName then
return data.number
end
end
end
end
function safezone ()
if getElementData(getLocalPlayer(), "greenzone") == true then return end
if getElementData(attacker, "greenzone") == true then return end
end
addEvent("enableGodMode", true)
addEventHandler ("enableGodMode", getRootElement(),
function()
addEventHandler ("onClientPlayerDamage", getRootElement(), cancelEventEvent)
end)
addEvent("disableGodMode", true)
addEventHandler ("disableGodMode", getRootElement(),
function()
removeEventHandler ("onClientPlayerDamage", getRootElement(), cancelEventEvent)
end)
function cancelEventEvent () cancelEvent() end
Alles anzeigen
Ich bedanke mich im voraus für jegliche Antworten.