Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-02-29, 14:49


NewStories







Wiek: 22
Na forum: 2639 dni
Posty: 65
Nick w MP: Dobrich

Piwa: 4

Respekt: 50

Ostrzeżeń: 60%
Witam, mam problem z bindowaniem.


addEventHandler("onClientMarkerHit",resourceRoot,bindKey("h""down", function(e)
if e==localPlayer then
veh getPedOccupiedVehicle(e)
if getElementData(veh,"vehicle:rodzaj") == "Elektryk" then return end
if veh and getElementData(veh,"vehicle:id"then
addEventHandler("onClientRender",root,dxrender)
tick getTickCount()
showCursor(true)
isdx true
end
end
end)
end)


Problem w DB3:
Kod:


dxgui.lua:69: ')' expeected (to close '(' at line 57) near 'end'
[/list]

Podpis
Dobrich/9971
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-02-29, 15:14


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4044 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

addEventHandler "onMarkerHit"markerzbinduj) 

function zbinduj(hitElement) 
    if (getElementType (hitElement) == "player"then 
            bindKey(hitElement"f""down", function() 
            funkcja(hitElement) 
            end)
    end 
end

function funkcja(hitElement) 
if hitElement==localPlayer then
veh getPedOccupiedVehicle(hitElement)
if getElementData(hitElement,"vehicle:rodzaj") == "Elektryk" then return end
if veh and getElementData(hitElement,"vehicle:id"then
addEventHandler("onClientRender",root,dxrender)
tick getTickCount()
showCursor(true)
isdx true
end
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-02-29, 15:36


NewStories







Wiek: 22
Na forum: 2639 dni
Posty: 65
Nick w MP: Dobrich

Piwa: 4

Respekt: 50

Ostrzeżeń: 60%
P.Wi?nia, skrypt jest w cliencie, wi?c nie dzia?a.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-02-29, 15:53


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4044 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

bindKey("e", "down", function()
if e==localPlayer then
veh = getPedOccupiedVehicle(e)
if getElementData(veh,"vehicle:rodzaj") == "Elektryk" then return end
if veh and getElementData(veh,"vehicle:id") then
addEventHandler("onClientRender",root,dxrender)
tick = getTickCount()
showCursor(true)
isdx = true
end
end
end)
end)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-02-29, 19:02


NewStories







Wiek: 22
Na forum: 2639 dni
Posty: 65
Nick w MP: Dobrich

Piwa: 4

Respekt: 50

Ostrzeżeń: 60%
P.Wi?nia,
Kod:


local screenW,screenH = guiGetScreenSize()

cena = math.random(450.00,520.00)
function cenas(x)
if not x then x = math.random(450.00,520.00) end
cena = x
end
sync_czas = 1000*60*180-- co 3 godziny zmiana ceny
setTimer(cenas,sync_czas,0)
function isMouseInPosition ( x, y, width, height )
if ( not isCursorShowing( ) ) then
return false
end
local sx, sy = guiGetScreenSize ( )
local cx, cy = getCursorPosition ( )
local cx, cy = ( cx * sx ), ( cy * sy )
if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then
return true
else
return false
end
end

local stacje={
{-2023.41, 156.94, 27.84}, -- doherty
{-2028.61, 156.94, 27.84}, -- doherty
{-1667.61, 410.31, 6.18}, -- obok kgp
{-1671.91, 414.61, 6.18}, -- obok kgp
{50.78, 1215.71, 17.92}, -- FC
{48.75, 1220.03, 17.95}, -- FC
{-2838.66, 449.86, 4.28}, -- SCENA
{-2838.66, 446.55, 4.27}, -- SCENA
{-2825.33, 447.27, 4.23},
{-2825.33, 450.57, 4.23},
{-2248.17, -2559.16, 31.55},
{-2243.07, -2561.24, 31.55},

}


for _,v in ipairs(stacje)do
marker=createMarker(v[1],v[2],v[3]-2,"cylinder",2,0,0,0,0)
local marker2=createMarker(v[1],v[2],v[3]-2,"cylinder",3,75, 0, 130, 35)
local text = createElement("text")
setElementData(text,"name", "Aby otworzy? menu tankowania, wci?nij klawisz 'H'")
setElementPosition(text,v[1], v[2], v[3])
end


local isdx = false
loadingfuel = false

tankujbenzyna = false
tankujlpg = false
tankujdiesel = false


addEventHandler("onClientMarkerHit",resourceRoot,function(e)
if e==localPlayer then
local veh = getPedOccupiedVehicle(e)
if getElementData(veh,"vehicle:rodzaj") == "Elektryk" then return end
if veh and getElementData(veh,"vehicle:id") then
addEventHandler("onClientRender",root,dxrender)
showCursor(true)
isdx = true
end
end
end)

addEventHandler("onClientMarkerLeave",resourceRoot,function(e)
if e==localPlayer then
removeEventHandler("onClientRender",root,on)
removeEventHandler("onClientRender",root,on2)
removeEventHandler("onClientRender",root,dxrender)
isdx = false
showCursor(false)
end
end)

function dxDrawLinedRectangle( x, y, width, height, color, _width, postGUI )
_width = _width or 1
dxDrawLine ( x, y, x+width, y, color, _width, postGUI ) -- Top
dxDrawLine ( x, y, x, y+height, color, _width, postGUI ) -- Left
dxDrawLine ( x, y+height, x+width, y+height, color, _width, postGUI ) -- Bottom
return dxDrawLine ( x+width, y, x+width, y+height, color, _width, postGUI ) -- Right
end

local czas_wysuwania2 = 300

function dxrender()
local a = interpolateBetween(20, 0, 0, 220, 0, 0, (getTickCount()-tick)/czas_wysuwania2, "Linear")
--exports["buttons"]:createCustomWindow("Stacja Benzynowa", screenW * 0.3651, screenH * 0.2389, screenW * 0.2938, screenH * 0.3343, tocolor(1, 0, 0, 135), false)
dxDrawRectangle(screenW * 0.3401, screenH * 0.2389, screenW * 0.3438, screenH * 0.3343, tocolor(30, 30, 30, a), false)
dxDrawImage(screenW * 0.3844, screenH * 0.3880, screenW * 0.0583, screenH * 0.1019, "images/ON.png", 0, 0, 0, tocolor(255, 255, 255,a), false)
dxDrawImage(screenW * 0.4812, screenH * 0.3889, screenW * 0.0583, screenH * 0.1019, "images/LPG.png", 0, 0, 0, tocolor(255, 255, 255, a), false)
dxDrawImage(screenW * 0.5781, screenH * 0.3889, screenW * 0.0583, screenH * 0.1019, "images/95.png", 0, 0, 0, tocolor(255, 255, 255, a), false)
dxDrawLinedRectangle(screenW * 0.5781, screenH * 0.3889, screenW * 0.0583, screenH * 0.1019, tocolor(38,255,178, 255), 1, true)
dxDrawLinedRectangle(screenW * 0.4812, screenH * 0.3889, screenW * 0.0583, screenH * 0.1019, tocolor(38,255,178, 255), 1, true)
dxDrawLinedRectangle(screenW * 0.3844, screenH * 0.3880, screenW * 0.0583, screenH * 0.1019, tocolor(38,255,178, 255), 1, true)
dxDrawText("Wci?nij backspace aby zamkn?? okno.", screenW * 0.4521, screenH * 0.7481, screenW * 0.5760, screenH * 0.3722, tocolor(255, 255, 255, 255), 1.00, "default-bold", "center", "center", false, false, false, false, false)
if getVehicleEngineState ( getPedOccupiedVehicle ( localPlayer )) == true then
dxDrawText("Aby zatankowa? pojazd, nale?y wy??czy? silnik oraz zaci?gn?? r?czny.", screenW * 0.4521, screenH * 0.2081, screenW * 0.5760, screenH * 0.3722, tocolor(255, 0, 0, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
end
end

function on()
local a = interpolateBetween(20, 0, 0, 220, 0, 0, (getTickCount()-tick)/czas_wysuwania2, "Linear")
--exports["buttons"]:createCustomWindow("Stacja Benzynowa", screenW * 0.3651, screenH * 0.2389, screenW * 0.2938, screenH * 0.3343, tocolor(1, 0, 0, 135), false)
dxDrawRectangle(screenW * 0.3401, screenH * 0.2389, screenW * 0.3438, screenH * 0.3343, tocolor(30, 30, 30, a), false)
local veh = getPedOccupiedVehicle(localPlayer)
local butla = getElementData(veh,"vehicle:bak")
local fuel = tonumber(getElementData(veh,"vehicle:fuel"))
for i = 1,fuel do
if getElementData (veh,"vehicle:bak") == 25 then
dxDrawRectangle(screenW * 0.3740+(i*14.7), screenH * 0.3694, screenW * 0.0047, screenH * 0.0250, tocolor(0, 220, 0, 215), false)
elseif getElementData (veh,"vehicle:bak") == 35 then
dxDrawRectangle(screenW * 0.3740+(i*10.5), screenH * 0.3694, screenW * 0.0037, screenH * 0.0250, tocolor(0, 220, 0, 215), false)
elseif getElementData (veh,"vehicle:bak") == 50 then
dxDrawRectangle(screenW * 0.3740+(i*7.35), screenH * 0.3694, screenW * 0.0015, screenH * 0.0250, tocolor(0, 220, 0, 215), false)
end
end
dxDrawText("Pojemno?? Baku: "..butla.."L", screenW * 0.4681, screenH * 0.4274, screenW * 0.4271, screenH * 0.5241, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
if tankujbenzyna == true then
dxDrawText("Cena Paliwa: "..string.format("%.2f",cena/115).."/#ccc000"..string.format("%.2f",cena/115*0.7).."#ffffff PLN", screenW * 0.4401, screenH * 0.5015, screenW * 0.4271, screenH * 0.5241, tocolor(255, 255, 255, 255), 1.20, "default-bold", "left", "top", false, false, false, true, false)
elseif tankujdiesel == true then
dxDrawText("Cena Paliwa: "..string.format("%.2f",cena/100).."/#ccc000"..string.format("%.2f",cena/100*0.7).."#ffffff PLN", screenW * 0.4401, screenH * 0.5015, screenW * 0.4271, screenH * 0.5241, tocolor(255, 255, 255, 255), 1.20, "default-bold", "left", "top", false, false, false, true, false)
end
if getVehicleEngineState ( getPedOccupiedVehicle ( localPlayer )) == true then
dxDrawText("Zga? silnik aby zatankowa? pojazd!", screenW * 0.4521, screenH * 0.9481, screenW * 0.5760, screenH * 0.3722, tocolor(255, 0, 0, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)
end
dxDrawText("Aby zatankowa? pojazd przytrzymaj \n#ff0000SPACJE", screenW * 0.4521, screenH * 0.9481, screenW * 0.5760, screenH * 0.3722, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, true, false)
end

function on2()
local a = interpolateBetween(20, 0, 0, 220, 0, 0, (getTickCount()-tick)/czas_wysuwania2, "Linear")
--exports["buttons"]:createCustomWindow("Stacja Benzynowa", screenW * 0.3651, screenH * 0.2389, screenW * 0.2938, screenH * 0.3343, tocolor(1, 0, 0, 135), false)
dxDrawRectangle(screenW * 0.3401, screenH * 0.2389, screenW * 0.3438, screenH * 0.3343, tocolor(30, 30, 30, a), false)
local veh = getPedOccupiedVehicle(localPlayer)
local butla = getElementData(veh,"vehicle:bak")
local LPG = tonumber(getElementData(veh,"vehicle:LPG"))
for i = 1,LPG do
dxDrawRectangle(screenW * 0.3740+(i*14.7), screenH * 0.3694, screenW * 0.0047, screenH * 0.0250, tocolor(0, 220, 0, 215), false)
end
dxDrawText("Pojemno?? Baku: "..butla.."L", screenW * 0.4681, screenH * 0.4274, screenW * 0.4271, screenH * 0.5241, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, false, false, false, false)
dxDrawText("Cena Paliwa: "..string.format("%.2f",cena/225).."/#ccc000"..string.format("%.2f",cena/225*0.7).."#ffffff PLN", screenW * 0.4401, screenH * 0.5015, screenW * 0.4271, screenH * 0.5241, tocolor(255, 255, 255, 255), 1.20, "default-bold", "left", "top", false, false, false, true, false)
if getVehicleEngineState ( getPedOccupiedVehicle ( localPlayer )) == true then
dxDrawText("Zga? silnik aby zatankowa? pojazd!", screenW * 0.4521, screenH * 0.9481, screenW * 0.5760, screenH * 0.3722, tocolor(255, 0, 0, 255), 1.50, "default-bold", "center", "center", false, false, false, false, false)
end
dxDrawText("Aby zatankowa? pojazd przytrzymaj \n#ff0000SPACJE", screenW * 0.4521, screenH * 0.9481, screenW * 0.5760, screenH * 0.3722, tocolor(255, 255, 255, 255), 1.50, "default-bold", "center", "center", false, false, false, true, false)
end

addEventHandler("onClientClick",root,function(btn,state)
tick = getTickCount()
local veh = getPedOccupiedVehicle(localPlayer)
if btn and state then
if isdx == true then
if isMouseInPosition(screenW * 0.3844, screenH * 0.3880, screenW * 0.0583, screenH * 0.1019) and getElementData(veh, "vehicle:rodzaj") == "Diesel" then
if getVehicleEngineState ( getPedOccupiedVehicle ( localPlayer )) == true then return end
isdx = false
loadingfuel = true
removeEventHandler("onClientRender",root,dxrender)
addEventHandler("onClientRender",root,on)
tankujdiesel = true
elseif isMouseInPosition(screenW * 0.5781, screenH * 0.3889, screenW * 0.0583, screenH * 0.1019) and getElementData(veh, "vehicle:rodzaj") == "Benzyna" then
if getVehicleEngineState ( getPedOccupiedVehicle ( localPlayer )) == true then return end
removeEventHandler("onClientRender",root,dxrender)
addEventHandler("onClientRender",root,on)
loadingfuel = true
isdx = false
tankujbenzyna = true
elseif isMouseInPosition(screenW * 0.4812, screenH * 0.3889, screenW * 0.0583, screenH * 0.1019) and getElementData(veh, "Zamontowane:LPG") == "Tak" then
if getVehicleEngineState ( getPedOccupiedVehicle ( localPlayer )) == true then return end
removeEventHandler("onClientRender",root,dxrender)
addEventHandler("onClientRender",root,on2)
loadingfuel = true
isdx = false
tankujlpg = true
return end
end
end
end)

local tick = getTickCount()
function bind ()
local v = getPedOccupiedVehicle(localPlayer)
if v then
if getElementData(v,"vehicle:id") then
if getKeyState("space") and getTickCount()-tick > 500 and loadingfuel == true then
if getVehicleEngineState ( getPedOccupiedVehicle ( localPlayer )) == true then return end
local tick = getTickCount()
local veh = getPedOccupiedVehicle(localPlayer)
local kasa = getPlayerMoney(localPlayer)
local fuel = tonumber(getElementData(veh,"vehicle:fuel"))
local LPG = tonumber(getElementData(veh,"vehicle:LPG"))
local bak = getElementData (veh,"vehicle:bak")
local sponsor = getElementData(localPlayer,"player:sponsor")
if tankujlpg == true then
if LPG >= 24.99 then return end
end
if tankujdiesel == true or tankujbenzyna == true then
if bak == 25 and fuel >=24.99 then return end
if bak == 35 and fuel >=34.99 then return end
if bak == 50 and fuel >=49.99 then return end
end

if tankujdiesel == true then
if kasa < 20 then return end
setElementData(veh,"vehicle:fuel",fuel+0.01)
if sponsor == 1 then
elseif getElementData(localPlayer,"player:premium") then
triggerServerEvent("take",localPlayer, localPlayer, cena/115*0.7)
else
triggerServerEvent("take",localPlayer, localPlayer, cena/115)
end
elseif tankujbenzyna == true then
if kasa < 20 then return end
setElementData(veh,"vehicle:fuel",fuel+0.01)
if sponsor == 1 then
elseif getElementData(localPlayer,"player:premium") then
triggerServerEvent("take",localPlayer, localPlayer, cena/100*0.7)
else
triggerServerEvent("take",localPlayer, localPlayer, cena/100)
end
elseif tankujlpg == true then
if kasa < 12 then return end
setElementData(veh,"vehicle:LPG",LPG+0.01)
if sponsor == 1 then
elseif getElementData(localPlayer,"player:premium") then
triggerServerEvent("take",localPlayer, localPlayer, cena/225*0.7)
else
triggerServerEvent("take",localPlayer, localPlayer, cena/225)
end
end
end
end
end
end
addEventHandler("onClientRender",root,bind)

function bindend ()
if tankujbenzyna == true then
tankujbenzyna = false
elseif tankujdiesel == true then
tankujdiesel = false
elseif tankujlpg == true then
tankujlpg = false
end
if loadingfuel == true then
loadingfuel = false
removeEventHandler("onClientRender",root,on)
removeEventHandler("onClientRender",root,on2)
showCursor(false)
elseif loadingfuel == true then
removeEventHandler("onClientRender",root,on)
removeEventHandler("onClientRender",root,on2)
showCursor(false)
elseif isdx == true then
isdx = false
removeEventHandler("onClientRender",root,dxrender)
local veh = getPedOccupiedVehicle(localPlayer)
showCursor(false)
end
end
bindKey("backspace","down",bindend)


Tak wygl?da kod od strony clienta, jak to naprawi??
Chodzi o to aby wejsc w marker, a nastepnie kliknac H aby otworzyl sie panel.

Postaw piwo autorowi tego posta
 

 
Tagi: bindowanie :: wywołanie :: funckji.
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Bindowanie, wywołanie funckji. Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku