--[[
Autor: Malentas
]]
local screenW, screenH = guiGetScreenSize()
local sx, sy = guiGetScreenSize()
local px, py = screenW/1440, screenH/900
local font = dxCreateFont("cz.ttf", 10)
local font2 = dxCreateFont("cz.ttf", 13)
local okno = false
local rzeczy = {
--- nazwa, tekst, cena, %najedzenia, grafika
{"Hamburger", "Kupuj?c hamburgera dostajesz +20% najedzenia", 20, 20, 1},
{"Hotdog", "Kupuj?c hotdoga dostajesz +15% najedzenia", 10, 15, 2},
{"Kebab", "Kupuj?c kebaba dostajesz +20% najedzenia", 25, 20, 3},
{"Woda", "Kupuj?c wode dostajesz +5% najedzenia", 5, 5, 7},
{"P?czek", "Kupuj?c p?czka dostajesz +10% najedzenia", 10, 10, 5},
}
function gui()
dxDrawImage(510*px, 233*py, 420*px, 435*py, ":np-gui/grafiki/tlo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText("Zakup fastfood?w", 509*px, 233*py, 930*px, 272*py, tocolor(255, 255, 255, 255), 1.00, font2, "center", "center", false, false, false, false, false)
dxDrawImage(904*px, 243*py, 16*px, 16*py, ":guieditor/images/cross.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
for i, v in ipairs(rzeczy) do
local dodatekY = (73*py)*(i-1)
local dodatekY2 = (146*py)*(i-1)
dxDrawRectangle(520*px, 281*py+dodatekY, 400*px, 70*py, tocolor(0, 0, 0, 120), false)
dxDrawImage(530*px, 291*py+dodatekY, 50*px, 50*py, ":np-fastfoody/grafy/"..v[5]..".png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText(v[1], 598*px, 281*py+dodatekY2, 826*px, 309*py, tocolor(255, 255, 255, 255), 1.00, font, "left", "center", false, false, false, false, false)
dxDrawText(v[2], 598*px, 309*py+dodatekY, 826*px, 348*py, tocolor(255, 255, 255, 255), 1.00, font, "left", "top", false, true, false, false, false)
dxDrawImage(834*px, 316*py+dodatekY, 76*px, 25*py, ":np-gui/grafiki/button_off.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText("Kup", 833*px, 315*py+dodatekY2, 910*px, 341*py, tocolor(255, 255, 255, 255), 1.00, font, "center", "center", false, false, false, false, false)
dxDrawText(""..v[3].." PLN", 826*px, 281*py+dodatekY2, 920*px, 311*py, tocolor(255, 255, 255, 255), 1.00, font, "center", "center", false, false, false, false, false)
end
end
addEventHandler("onClientClick", root, function(btn, state)
if btn == "left" and state == "down" then
for i,v in ipairs(rzeczy) do
local dodatekY = (73*py)*(i-1)
if mysz(826*px, 301*py+dodatekY, 100*px, 50*py) and okno == true then
--local najedzenie = getElementData(localPlayer, "najedzenie") or 0
--if najedzenie >= 100 then exports["np-notyfikacje"]:noti("Jeste? najedzony", "error") return end
--setElementData(localPlayer, "najedzenie", najedzenie+tonumber(v[4]))
if getElementData( localPlayer, "pieniadze" ) < tonumber(v[3]) then
exports['np-notyfikacje']:noti( "Brakuje Ci pieni?dzy, na zakupienie tego.", "error" );
return;
end
setElementData(localPlayer, "pieniadze", getElementData(localPlayer, "pieniadze")-tonumber(v[3]))
exports["np-notyfikacje"]:noti("Zakupujesz "..v[1]..", posiadasz go w swoim ekwipunku (M).")
triggerServerEvent("daj:fastfoody", localPlayer, v[1])
end
end
if mysz(904*px, 243*py, 16*px, 16*py) and okno == true then
removeEventHandler("onClientRender", root, gui)
okno = false
showCursor(false)
end
end
end)
addEventHandler("onClientMarkerHit", resourceRoot, function(gracz)
if gracz ~= localPlayer then return end
if getPedOccupiedVehicle(localPlayer) then return end
if getElementData(localPlayer, "bw") then return end
if getElementDimension(localPlayer) ~= 0 or getElementInterior(localPlayer) ~= 0 then return end
addEventHandler("onClientRender", root, gui)
okno = true
showCursor(true)
end)
addEventHandler("onClientMarkerLeave", resourceRoot, function(gracz)
if gracz ~= localPlayer then return end
removeEventHandler("onClientRender", root, gui)
okno = false
showCursor(false)
end)
function mysz(psx,psy,pssx,pssy,abx,aby)
if not isCursorShowing() then return end
cx,cy=getCursorPosition()
cx,cy=cx*sx,cy*sy
if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
return true,cx,cy
else
return false
end
end