Wysłany: 2015-07-13, 14:04
Given
Wiek: 31 Na forum: 4158 dni Posty: 31
Nick w MP: Given
Piwa : 1
Witam moj problem polega na tym ze gdy wjade w marker i wpisze np ?eby tankowalo 1 l to zatankuje ale kasy nie odejmuje co powinno to robi?.
Moje pytanie brzmi jak to naprawic ?
B??d w debugscript : triggered serverside event givePlayerMoney, but event is not added serverside
Kod:
if not tonumber(guiGetText(zpwp_ilosc_e)) then return end
local ile = stan + guiGetText(zpwp_ilosc_e)
local koszt = guiGetText(zpwp_ilosc_e) * 5
if ile < stan then
setTimer(guiSetText, 2000, 1, zpwp_warning, "")
guiSetText(zpwp_warning, "Poda?e? z?? warto?? paliwa.")
return
end
if ile < 101 then
if getPlayerMoney(localPlayer) > koszt then
showCursor(false)
guiSetVisible(zpwp_okno, false)
outputChatBox("* Pojazd zosta? zatankowany...")
setElementData(pojazd, "pojazd_paliwo", tonumber(ile))
triggerServerEvent("takePlayerMoney", localPlayer, koszt)
else
setTimer(guiSetText, 2000, 1, zpwp_warning, "")
guiSetText(zpwp_warning, "Nie posiadasz wystarczaj?cej ilo?ci pieni?dzy.")
end
else
setTimer(guiSetText, 2000, 1, zpwp_warning, "")
guiSetText(zpwp_warning, "Maxymalnie pojazd mo?e mie? 100% litr?w paliwa")
end
end)
Za pomoc jak zawsze
Wysłany: 2015-07-13, 14:10
Jurandovsky
Kurdebele
Wiek: 17 Na forum: 4839 dni Posty: 915
Piwa : 2697
Zrob w s-side co? takiego :
addEvent("takePlayerMoney", true)
addEventHandler("takePlayerMoney", resourceRoot, function(ile)
takePlayerMoney(client, ile)
end
uzywaj w c-side tak :
triggerServerEvent("takePlayerMoney", resourceRoot, ile_kasy)
Podpis
Jedyny kontakt ze mną to PW forum
Kod:
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Wysłany: 2015-07-13, 14:22
Given
Wiek: 31 Na forum: 4158 dni Posty: 31
Nick w MP: Given
Piwa : 1
Niestety cos nie dzia?a musia?em cos nie tak zrobi? ale co to nwm
[ Dodano : 2015-07-13, 14:25 ]
Mo?e podam tak :
Kod: sx,sy = guiGetScreenSize()
local punktyTankowania = {
{-81.73, 1022.739, 19.795},
{-86.376, 1022.708, 19.795},
{70.339, 1218.664, 18.812},
{615.462, 1690.561, 6.588},
{2115.397, 927.681, 10.416},
{2115.294, 911.85, 10.416},
{2204.791, 2476.208, 10.416},
{612.50,1694.81,7.03},
{2115.18,919.53,10.85},
{2200.073, 2477.069, 10.414},
}
for i,v in ipairs(punktyTankowania) do
zpwp_marker = createMarker(v[1], v[2], v[3]-1.0, "cylinder",2, 100, 100, 100, 255 )
setElementData(zpwp_marker, "stacja_benzynowa", true)
end
zpwp_okno = guiCreateWindow(199/1280*sx, 191/720*sy, 872/1280*sx, 294/720*sy, "Stacja benzynowa", false)
guiWindowSetSizable(zpwp_okno, false)
guiSetVisible(zpwp_okno, false)
zpwp_warning = guiCreateLabel(17/1280*sx, 18/720*sy, 845/1280*sx, 16/720*sy, "", false, zpwp_okno)
guiLabelSetColor(zpwp_warning, 183, 0, 0)
guiLabelSetHorizontalAlign(zpwp_warning, "center", false)
zpwp_info = guiCreateLabel(211/1280*sx, 81/720*sy, 477/1280*sx, 15/720*sy, "Stacja wita, poni?ej jest przedstawiony cennik paliwa, cennik mo?e ulec zmianie.", false, zpwp_okno)
guiSetFont(zpwp_info, "default-bold-small")
zpwp_stan_l = guiCreateLabel(17/1280*sx, 48/720*sy, 111/1280*sx, 15/720*sy, "Obecny stan paliwa:", false, zpwp_okno)
guiSetFont(zpwp_stan_l, "default-bold-small")
zpwp_stan = guiCreateProgressBar(154/1280*sx, 38/720*sy, 708/1280*sx, 30/720*sy, false, zpwp_okno)
guiProgressBarSetProgress(zpwp_stan, 0)
zpwp_cena = guiCreateLabel(365/1280*sx, 106/720*sy, 143/1280*sx, 16/720*sy, "Cena za jeden litr: 3 Z?", false, zpwp_okno)
zpwp_ilosc = guiCreateLabel(318/1280*sx, 132/720*sy, 208/1280*sx, 15/720*sy, "Wpisz ile liter paliwa, chcesz zakupi?:", false, zpwp_okno)
zpwp_ilosc_e = guiCreateEdit(536/1280*sx, 127/720*sy, 40/1280*sx, 26/720*sy, "", false, zpwp_okno)
zpwp_zakup = guiCreateButton(27/1280*sx, 171/720*sy, 820/1280*sx, 113/720*sy, "TANKUJ", false, zpwp_okno)
addEventHandler("onClientMarkerHit", resourceRoot, function(el, md)
if not getElementData(source, "stacja_benzynowa") then return end
if el ~= localPlayer then return end
if guiGetVisible(zpwp_okno) == false then
local pojazd = getPedOccupiedVehicle(el)
if not pojazd then return end
local paliwo = getElementData(pojazd, "pojazd_paliwo" )
showCursor(true, false)
guiSetVisible(zpwp_okno, true)
guiProgressBarSetProgress(zpwp_stan, paliwo)
end
end)
addEventHandler("onClientMarkerLeave", resourceRoot, function(el, md)
if not getElementData(source, "stacja_benzynowa") then return end
if el ~= localPlayer then return end
if guiGetVisible(zpwp_okno) == true then
showCursor(false)
guiSetVisible(zpwp_okno, false)
end
end)
addEventHandler("onClientGUIClick", zpwp_zakup, function()
local pojazd = getPedOccupiedVehicle(localPlayer)
if not pojazd then return end -- nie powinno si? wydarzy?
local stan = getElementData(pojazd, "pojazd_paliwo")
if not stan then return end -- nie powinno si? wydarzy?
if not tonumber(guiGetText(zpwp_ilosc_e)) then return end
local ile = stan + guiGetText(zpwp_ilosc_e)
local koszt = guiGetText(zpwp_ilosc_e) * 3
if ile < stan then
setTimer(guiSetText, 2000, 1, zpwp_warning, "")
guiSetText(zpwp_warning, "Poda?e? z?? warto?? paliwa.")
return
end
if ile < 101 then
if getPlayerMoney(localPlayer) > koszt then
showCursor(false)
guiSetVisible(zpwp_okno, false)
outputChatBox("* Pojazd zosta? zatankowany...")
setElementData(pojazd, "pojazd_paliwo", tonumber(ile))
triggerServerEvent("takePlayerMoney", localPlayer, koszt)
else
setTimer(guiSetText, 2000, 1, zpwp_warning, "")
guiSetText(zpwp_warning, "Nie posiadasz wystarczaj?cej ilo?ci pieni?dzy.")
end
else
setTimer(guiSetText, 2000, 1, zpwp_warning, "")
guiSetText(zpwp_warning, "Maxymalnie pojazd mo?e mie? 100% litr?w paliwa")
end
end)
[ Dodano : 2015-07-13, 15:08 ]
lub mo?e co? tutaj ?
Kod: local czas = getTickCount()
isBike = {
[509]=true, --Bike
[481]=true, --BMX
[510]=true, --Mountain bike
[420]=true, --Mountain bike
}
function odejmijPaliwo(pojazd)
if getTickCount() - czas > 150 then
czas = getTickCount()
local paliwo = getElementData(pojazd, "pojazd_paliwo") or 0
local vx,vy,vz = getElementVelocity(pojazd)
local spd = ((vx^2+vy^2+vz^2)^(0.5)/150)
if spd > 0 then
paliwo = paliwo-spd*2
setElementData(pojazd, "pojazd_paliwo", paliwo)
end
end
end
addEventHandler("onClientRender", root, function()
local pojazd = getPedOccupiedVehicle(localPlayer)
if not pojazd then return end
if isBike[getElementModel(pojazd)] then return end
if not getVehicleEngineState(pojazd) then return end
if getVehicleController(pojazd) ~= localPlayer then return end
odejmijPaliwo(pojazd)
end)
function zgasSilnik()
for i,v in ipairs(getElementsByType("vehicle")) do
local data = getElementData(v, "pojazd_paliwo")
if data then
if tonumber(data) < 0 then
setVehicleEngineState(v, false)
end
end
end
end
setTimer(zgasSilnik, 1000, 999999999)
Tagi: kasa-paliwo
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: