Wysłany: 2017-02-04, 17:17
AssasiPlayGames
Wiek: 22 Na forum: 3757 dni Posty: 176
Nick w MP: NiFeKpL
Piwa : 909
Witam mam problem z stacjami robie je do square rpg paliwo dzia?a ale jak chce zatankowa? wgl gui sie nie pokazuje kod
Kod:
local cost=2
local price = 2
local key="x"
local show=false
local points={
-- x,y,z,wielkosc cuboida
{2015.9665527344, 57.702537536621, 30.853542327881, 5},
{1383.4501953125, 462.2412109375, 20.14066696167, 4.5},
{70.638671875, 1218.48046875, 18.518779754639, 7},
{2114.19921875, 921.9140625, 10.555886268616, 7},
{1596.7490234375, 2199.2353515625, 10.526239395142, 8},
{2201.7939453125, 2478.6044921875, 10.525874137878, 8},
{1595.52, 2198.59, 10.82, 15},
{1381.51, 459.72, 20.35, 5},
{1940.93, -1772.70, 13.64, 10},
{1004.85, -936.96, 42.33, 10},
{655.36, -565.28, 16.34, 10},
}
local wm={}
sx,sy=guiGetScreenSize()
wm.window = guiCreateWindow((971/1280*sx), (263/728*sy), (276/1280*sx), (376/728*sy), "Stacja samoobs?ugowa", false)
wm.memo=guiCreateMemo((15/1280*sx), (27/728*sy), (244/1280*sx), (190/728*sy), "", false, wm.window)
wm.button=guiCreateButton((19/1280*sx), (230/728*sy), (240/1280*sx), (75/728*sy), "", false, wm.window)
guiMemoSetReadOnly(wm.memo, true)
guiWindowSetMovable(wm.window, false)
guiSetVisible(wm.window, false)
for i,v in pairs(points) do
local cuboid=createColSphere(v[1], v[2], v[3]-1.20, v[4])
setElementData(cuboid,"stacjabenzynowa",true)
createBlipAttachedTo(cuboid, 56)
end
addEventHandler("onClientGUIClick", resourceRoot, function()
if source == wm.button then
local money=getElementData(plr, "user:money")
local veh=getPedOccupiedVehicle(localPlayer)
if not veh then return end
if getVehicleController(veh) ~= localPlayer then return end
local spawn=getElementData(veh,"vehicle:spawn")
if not spawn then return end
local fuel=getElementData(veh,"veh:fuel")
if not fuel then return end
local money = getElementData(plr, "user:money")
if price > money then
exports.rpg_noti:createNotification(plr, "error", "Nie sta? Ci? na zakup tego pojazdu")
return
end
setElementData(plr, "user:money", money-price)
if fuel <= 100 then
local nFuel=fuel+2
setElementData(veh,"veh:fuel", nFuel)
local newFuel=getElementData(veh, "veh:fuel")
guiSetText(wm.memo, "Stacja samoobs?ugowa wita\n\nTw?j bak: "..string.format("%.02f", newFuel).."\nCena za 1l: "..cost.."\n\nAby zatankowa? kliknij Zatankuj")
--triggerServerEvent("takePlayerMoney", localPlayer, cost)
--setElementData(plr, "user:money", money-cost)
else
if guiGetVisible(wm.window) then
showCursor(false)
guiSetVisible(wm.window,false)
end
end
end
end)
addEventHandler("onClientColShapeLeave", resourceRoot, function(el,md)
if el~=localPlayer then return end
if not getElementData(source,"stacjabenzynowa") then return end
local veh=getPedOccupiedVehicle(el)
if not veh then return end
if getVehicleController(veh) ~= localPlayer then return end
local spawn=getElementData(veh,"vehicle:spawn")
if not spawn then return end
local fuel=getElementData(veh,"veh:fuel")
if not fuel then return end
if guiGetVisible(wm.window) then
showCursor(false)
guiSetVisible(wm.window,false)
end
end)
addEventHandler("onClientColShapeHit", resourceRoot, function(el,md)
if el~=localPlayer then return end
if not getElementData(source,"stacjabenzynowa") then return end
local veh=getPedOccupiedVehicle(el)
if not veh then return end
if getVehicleController(veh) ~= localPlayer then return end
local spawn=getElementData(veh,"vehicle:spawn")
if not spawn then return end
local fuel=getElementData(veh,"veh:fuel")
if not fuel then return end
if not guiGetVisible(wm.window) then
showCursor(true,false)
guiSetVisible(wm.window,true)
guiSetText(wm.button, "Zatankuj")
guiSetText(wm.memo, "Stacja samoobs?ugowa wita\n\nTw?j bak: "..string.format("%.02f", fuel).."\nCena za 1l: "..cost.."\n\nAby zatankowa? kliknij Zatankuj")
end
end)
addEventHandler("onClientVehicleExit", root, function(plr,seat)
if seat ~= 0 then return end
if guiGetVisible(wm.window) then
showCursor(false)
guiSetVisible(wm.window, false)
end
cancelEvent()
end)
[/code]
Wysłany: 2017-02-04, 17:19
Dexnes_
Tiger
Wiek: 26 Na forum: 4401 dni Posty: 620
Nick w MP: Dexnes
Piwa : 1394
AssasiPlayGames , sprawdz czy nie ma b??d?w db3.
Wysłany: 2017-02-04, 17:22
AssasiPlayGames
Wiek: 22 Na forum: 3757 dni Posty: 176
Nick w MP: NiFeKpL
Piwa : 909
BlackGamePL , w?asnie nie ma
Wysłany: 2017-02-04, 17:50
Dexnes_
Tiger
Wiek: 26 Na forum: 4401 dni Posty: 620
Nick w MP: Dexnes
Piwa : 1394
Sprawdz czy tw?j pojazd napewno ma element date :
getElementData ( veh , "veh:fuel" )
Wysłany: 2017-02-04, 17:54
AssasiPlayGames
Wiek: 22 Na forum: 3757 dni Posty: 176
Nick w MP: NiFeKpL
Piwa : 909
Kod: local time=getTickCount()
local isBike={[509]=true,[481]=true,[510]=true}
local function naliczaj(veh)
if getTickCount()-time>2000 then
time = getTickCount()
local fuel = getElementData(veh, "veh:fuel") or 0
local mileage = getElementData(veh,"veh:distance") or 0
local vx,vy,vz = getElementVelocity(veh)
local spd=((vx^2 + vy^2 + vz^2)^(0.5)/10)
if spd>0 then
fuel = fuel-(spd*2)/3
setElementData(veh, "veh:fuel", fuel)
mileage = mileage+(spd)
setElementData(veh, "veh:distance", mileage)
end
end
end
addEventHandler("onClientRender", root, function()
local vehicle = getPedOccupiedVehicle(localPlayer)
if not vehicle then return end
if isBike[getElementModel(vehicle)] then return end
if not getVehicleEngineState(vehicle) then return end
if getElementData(vehicle,"veh:fuel") and getElementData(vehicle,"veh:fuel") or getElementData(vehicle,"veh:distance") and getElementData(vehicle,"veh:distance") then
naliczaj(vehicle)
if getElementHealth(vehicle)<300 then
setVehicleEngineState(vehicle, false)
end
if getElementData(vehicle,"veh:fuel")<1 then
setVehicleEngineState(vehicle, false)
end
end
end)
kawa?ek kodu z rpg_vehiles clienta
Tagi: stacje
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: