GiorgioUlani
JesteśNoobem
Wiek: 26 Na forum: 2037 dni Posty: 26
Nick w MP: ANONIM
Piwa : 6
Witam mam problem poniewa? po zamontowaniu neon?w one nie zapisuj? sie one w pojezdzie
kod
c.lua
Kod: local marker = createMarker(-2115.63, -23.55, 35.32, "cylinder", 2)
local pileczka=createElement("text")
setElementData(pileczka,"name", "Testowe Neony")
setElementPosition(pileczka,-2115.63, -23.55, 35.32)
screen = Vector2(guiGetScreenSize())
function scale_x(value)
if not value then return nil end
return (value / 1920) * screen['x']
end
function scale_y(value)
if not value then return nil end
return (value / 1080) * screen['y']
end
local font = dxCreateFont("font.ttf", scale_x(15))
local k = 1
local n = 5
local m = 5
local okno = false
local neon = {
{5000000, 255, 0, 0}, -- czerwone
{5000000, 0, 255, 0}, -- zielone
{5000000, 0, 0, 255}, -- niebieskie
{5000000, 0, 255, 255}, -- b??kitne
{5000000, 255, 255, 255}, -- bia?e
{5000000, 255, 0, 255}, -- niebieskie
{5000000, 255, 255, 0}, -- niebieskie
}
function gui()
dxDrawImage(scale_x(757), scale_y(328), scale_x(407), scale_y(424), ":pystories-sklepkas/shop_casino.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
shadowText("Monta? neon?w", scale_x(757), scale_y(328), scale_x(1164), scale_y(385), tocolor(255, 255, 255, 255), 1.00, font, "center", "center", false, false, false, false, false)
local x = 0
for i, v in ipairs(neon) do
if i >= k and i <= n then
x = x+1
local addY = (scale_y(58))*(x-1)
dxDrawImage(scale_x(767), scale_y(395)+addY, scale_x(387), scale_y(56), ":pystories-montaz-liczniki/images/button.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
shadowText(v[1].."$", scale_x(900), scale_y(395)+(addY*2), scale_x(1092), scale_y(451), tocolor(255, 255, 255, 255), 1.00, font, "left", "center", false, false, false, false, false)
dxDrawRectangle(scale_x(777), scale_y(401)+addY, scale_x(94), scale_y(44), tocolor(v[2], v[3], v[4], 255), false)
end
end
shadowText("Kliknij na pasek aby zamontowa? neon", 757, 708, 1164, 746, tocolor(255, 0, 0, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
end
addEventHandler("onClientClick", root, function(btn, state)
if btn == "left" and state == "down" and okno == true then
local x = 0
for i, v in ipairs(neon) do
if i >= k and i <= n then
x = x+1
local addY = (scale_y(58))*(x-1)
if isMouseIn(scale_x(767), scale_y(395)+addY, scale_x(387), scale_y(56)) then
if getPlayerMoney(localPlayer) > v[1] then
triggerServerEvent("zamontujNeon", localPlayer, v[1], getElementData(getPedOccupiedVehicle(localPlayer), "vehicle:id"), v[2]..","..v[3]..","..v[4])
setElementData(getPedOccupiedVehicle(localPlayer), "neon", v[2]..","..v[3]..","..v[4])
else
outputChatBox("Nie masz tyle pieni?dzy", 255, 0, 0)
end
end
end
end
end
end)
bindKey("mouse_wheel_down", "both", function()
if okno ~= true then return end
scrollUp()
end)
bindKey("mouse_wheel_up", "both", function()
if okno ~= true then return end
scrollDown()
end)
function scrollDown()
if n == m then return end
k = k-1
n = n-1
end
function scrollUp()
if n >= #neon then return end
k = k+1
n = n+1
end
addEventHandler("onClientMarkerHit", marker, function(gracz)
if localPlayer ~= gracz then return end
if not getPedOccupiedVehicle(localPlayer) then return end
--if not getPlayerOccupiedVehicle(localPlayer) ~= 0 then return end
if not getElementData(getPedOccupiedVehicle(localPlayer), "vehicle:id") then return end
showCursor(true, false)
okno = true
addEventHandler("onClientRender", root, gui)
end)
addEventHandler("onClientMarkerLeave", marker, function(gracz)
if gracz ~= localPlayer then return end
if okno == false then return end
showCursor(false)
okno = false
removeEventHandler("onClientRender", root, gui)
end)
function shadowText(text,x,y,w,h,color,size,font,xx,yy,x1,x2,x3,x4,x5)
dxDrawText(text,x+1,y+1,w+1,h+1,tocolor(0,0,0),size,font,xx,yy,x1,x2,x3,x4,x5)
dxDrawText(text,x,y,w,h,color,size,font,xx,yy,x1,x2,x3,x4,x5)
end
function isMouseIn(psx,psy,pssx,pssy,abx,aby)
if not isCursorShowing() then return end
cx,cy=getCursorPosition()
cx,cy=cx*screen["x"],cy*screen["y"]
if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
return true,cx,cy
else
return false
end
end
function przecinkiAdd(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
s.lua
Kod: addEvent("zamontujNeon", true)
addEventHandler("zamontujNeon", root, function(ilosc, id, rgb)
takePlayerMoney(client, ilosc)
exports["pystories-db"]:dbSet("UPDATE pystories_vehicles SET neon=? WHERE id=?", rgb, id)
triggerClientEvent(client, "onClientAddNotification", client, "Pomy?lnie zamontowano Neon", "success")
takePlayerMoney(source, cena)
else
triggerClientEvent(client, "onClientAddNotification", client, "To nie jest tw?j pojazd!", "warning")
end
end)
end)