Wysłany: 2016-03-31, 13:48
marcin778
Krytyk serwerów MTA
Wiek: 24 Na forum: 4149 dni Posty: 2268
Nick w MP: Marcineg
Piwa : 4662
Takie pytanie czym si? r??ni
Więcej informacji znajdziesz w Wikipedii MTA: cancelEvent
od
Domy?lam si?, ?e cancelEvent anuluje dany event a remove usuwa. Je?li tak jest to prosz? o wyt?umaczenie do czego u?ywamy te obie funkcje.
Wysłany: 2016-03-31, 13:59
AteX
Wiek: 26 Na forum: 4015 dni Posty: 927
Nick w MP: #AteX
Piwa : 8360
Dok?adnie tak jest.
cancelEvent() u?ywa si? do anulowania danego eventu, je?eli np. nie spe?nia warunk?w albo po prostu nie chcemy, aby jaki? event si? wykonywa?, np. wsiadanie do pojazdu.
Przyk?ad:
addEventHandler ( "onPlayerChat" , root ,function()
if getElementData ( source , "niemozepisac" ) then
cancelEvent ()
end
end )
A removeEventHandler usuwa dany event i przydaje si? m.in. do usuwania eventu onClientRender, kt?rego np. u?yli?my do dxDraw. My?l?, ?e przyk?ad z wiki wystarczy:
function drawText () -- A function to draw the text we want
dxDrawText ( text , 10 , 100 ) -- creates a dx text 10 pixels from left , 100 from top of the screen
end
function doText ( command , ...)
if command == "starttext" then -- if player wrote / starttext
text = table . concat ({...}, " " ) -- then we retrieve the text
addEventHandler ( "onClientRender" , getRootElement (), drawText ) -- and since addEventHandler and removeEventHandler 's syntax is the same, we just define the function we use later
elseif command == "stoptext" then
removeEventHandler("onClientRender", getRootElement(), drawText) -- this time we use removeEventHandler
end
end
addCommandHandler("starttext", doText) -- add two command handlers to doText function
addCommandHandler("stoptext", doText)
Ostatnio zmieniony przez AteX 2016-03-31, 14:02, w całości zmieniany 1 raz
Wysłany: 2016-03-31, 14:02
marcin778
Krytyk serwerów MTA
Wiek: 24 Na forum: 4149 dni Posty: 2268
Nick w MP: Marcineg
Piwa : 4662
W zupe?no?ci wystarczy. Mo?na zamkn??
Tagi: sprawy :: eventowe
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: