Tokio Posted September 16, 2017 Share Posted September 16, 2017 i have this code in client side: function onMachineClick(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, element) if element and getElementType( element ) == "object" and button == "left" and state == "down" and getElementModel(element) == 1829 then triggerServerEvent ("eszakirablas", root, getLocalPlayer()) end end addEventHandler("onClientClick", getRootElement(), onMachineClick) but i want add this to server side, is it possible? Link to comment
Tokio Posted September 16, 2017 Author Share Posted September 16, 2017 1 minute ago, Dimos7 said: i think you can't Why? Link to comment
Mr.Loki Posted September 16, 2017 Share Posted September 16, 2017 Here u go: https://wiki.multitheftauto.com/wiki/OnElementClicked Link to comment
Tokio Posted September 16, 2017 Author Share Posted September 16, 2017 7 minutes ago, Mr.Loki said: Here u go: https://wiki.multitheftauto.com/wiki/OnElementClicked this why not working? function tesztteszt( theButton, theState, thePlayer, absoluteX, absoluteY, worldX, worldY, worldZ, element ) if element and getElementType( element ) == "object" and theButton == "left" and theState == "down" and getElementModel(element) == 1829 then if ( idozito [ thePlayer ] ~= nil ) then outputChatBox ( "#01AC41[SuperFun] #FFffFFA következő széfrablásig várnod kell #01AC41".. math.floor ( getTimerDetails ( idozito [ thePlayer ] ) / 60000+1 ) .." percet.", thePlayer, 255, 0, 0, true ); else setElementFrozen(thePlayer, true) setPedAnimation(thePlayer , "rob_bank", "cat_safe_rob", 10000, true, true, true, false) setTimer(setElementFrozen,10000,1,thePlayer,false) setTimer(setPedAnimation,10000,1,thePlayer) randomM = math.random(500000,1500000) setTimer(function() givePlayerMoney(thePlayer,randomM) end,10000,1) setTimer(outputChatBox, 10000,1,"#01AC41[SuperFun] #FFffFFÖsszesen raboltál #01AC41"..randomM.." #ffffffforintot.",thePlayer,255,255,255,true) setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatod a széfet! #01AC41(/eszaki)",thePlayer,255,255,255,true) setTimer(Boltrablas,900000,1) idozito [ thePlayer ] = setTimer ( function ( thePlayer ) idozito [ thePlayer ] = nil; end, 900000, 1, thePlayer); end end end addEventHandler( "onElementClicked", getRootElement(), tesztteszt ) Link to comment
Mr.Loki Posted September 16, 2017 Share Posted September 16, 2017 Invalid function parameters check the wiki for them. 1 Link to comment
Tokio Posted September 16, 2017 Author Share Posted September 16, 2017 22 minutes ago, Mr.Loki said: Invalid function parameters check the wiki for them. function erablas( button, state, thePlayer ) if button == "left" and state == "down" then if getElementType( source ) == "object" then local x, y, z = getElementPosition( thePlayer ) local x1, y1, z1 = getElementPosition( source ) local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ) if distance < 4 then if ( idozito [ thePlayer ] ~= nil ) then outputChatBox ( "#01AC41[SuperFun] #FFffFFA következő széfrablásig várnod kell #01AC41".. math.floor ( getTimerDetails ( idozito [ thePlayer ] ) / 60000+1 ) .." percet.", thePlayer, 255, 0, 0, true ); else setElementFrozen(thePlayer, true) setPedAnimation(thePlayer , "rob_bank", "cat_safe_rob", 10000, true, true, true, false) setTimer(setElementFrozen,10000,1,thePlayer,false) setTimer(setPedAnimation,10000,1,thePlayer) randomM = math.random(500000,1500000) setTimer(function() givePlayerMoney(thePlayer,randomM) end,10000,1) setTimer(outputChatBox, 10000,1,"#01AC41[SuperFun] #FFffFFÖsszesen raboltál #01AC41"..randomM.." #ffffffforintot.",thePlayer,255,255,255,true) setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatóvá vált a széf! #01AC41(/eszaki)",root,255,255,255,true) setTimer(Boltrablas,900000,1) idozito [ thePlayer ] = setTimer ( function ( thePlayer ) idozito [ thePlayer ] = nil; end, 900000, 1, thePlayer); end else outputChatBox ( "#01AC41[SuperFun] #FFffFFTúl messze vagy a széftől! Gyere közelebb, nem harap..", thePlayer, 255, 0, 0, true ); end end end end addEventHandler( "onElementClicked", getRootElement( ), erablas ) Now working, but i have a problem.. Why can i rob the thing, when other player robbed? Link to comment
Mr.Loki Posted September 16, 2017 Share Posted September 16, 2017 (edited) Insert the source into your idozito table instead of thePlayer. Edited September 16, 2017 by Mr.Loki Correction 1 Link to comment
Tokio Posted September 16, 2017 Author Share Posted September 16, 2017 24 minutes ago, Mr.Loki said: You can use set and getElementData to make a simple check to see if it's being robbed or insert the element into your idozito table then check to see if it is in the table. setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatóvá vált a széf! #01AC41(/eszaki)",root,255,255,255,true) when the thing can rob again, flood this text how to fix this? Link to comment
Mr.Loki Posted September 16, 2017 Share Posted September 16, 2017 show me the code you have now Link to comment
Tokio Posted September 16, 2017 Author Share Posted September 16, 2017 1 minute ago, Mr.Loki said: show me the code you have now function erablas( button, state, thePlayer ) if button == "left" and state == "down" then if getElementType( source ) == "object" and getElementModel(source) == 1829 then local x, y, z = getElementPosition( thePlayer ) local x1, y1, z1 = getElementPosition( source ) local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ) if distance < 4 then if ( idozito [ thePlayer ] ~= nil ) then outputChatBox ( "#01AC41[SuperFun] #FFffFFA következő széfrablásig várnod kell #01AC41".. math.floor ( getTimerDetails ( idozito [ thePlayer ] ) / 60000+1 ) .." percet.", thePlayer, 255, 0, 0, true ); else setElementFrozen(thePlayer, true) setPedAnimation(thePlayer , "rob_bank", "cat_safe_rob", 10000, true, true, true, false) setTimer(setElementFrozen,10000,1,thePlayer,false) setTimer(setPedAnimation,10000,1,thePlayer) randomM = math.random(500000,1500000) setTimer(function() givePlayerMoney(thePlayer,randomM) destroyElement(safe) end,10000,1) setTimer(outputChatBox, 10000,1,"#01AC41[SuperFun] #FFffFFÖsszesen raboltál #01AC41"..randomM.." #ffffffforintot.",thePlayer,255,255,255,true) setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatóvá vált a széf! #01AC41(/eszaki)",root,255,255,255,true) setTimer(Boltrablas,900000,1) idozito [ thePlayer ] = setTimer ( function ( thePlayer ) idozito [ thePlayer ] = nil; end, 900000, 1, thePlayer); end else outputChatBox ( "#01AC41[SuperFun] #FFffFFTúl messze vagy a széftől! Gyere közelebb, nem harap..", thePlayer, 255, 0, 0, true ); end end end end addEventHandler( "onElementClicked", getRootElement( ), erablas ) Link to comment
Mr.Loki Posted September 16, 2017 Share Posted September 16, 2017 Try this function erablas( button, state, thePlayer ) if button == "left" and state == "down" then if getElementType( source ) == "object" and getElementModel(source) == 1829 then local x, y, z = getElementPosition( thePlayer ) local x1, y1, z1 = getElementPosition( source ) local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ) if distance < 4 then if ( idozito [ source ] ~= nil ) then outputChatBox ( "#01AC41[SuperFun] #FFffFFA következő széfrablásig várnod kell #01AC41".. math.floor ( getTimerDetails ( idozito [ thePlayer ] ) / 60000+1 ) .." percet.", thePlayer, 255, 0, 0, true ); else setElementFrozen(thePlayer, true) setPedAnimation(thePlayer , "rob_bank", "cat_safe_rob", 10000, true, true, true, false) setTimer(setElementFrozen,10000,1,thePlayer,false) setTimer(setPedAnimation,10000,1,thePlayer) randomM = math.random(500000,1500000) setTimer(function() givePlayerMoney(thePlayer,randomM) destroyElement(safe) end,10000,1) setTimer(outputChatBox, 10000,1,"#01AC41[SuperFun] #FFffFFÖsszesen raboltál #01AC41"..randomM.." #ffffffforintot.",thePlayer,255,255,255,true) setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatóvá vált a széf! #01AC41(/eszaki)",root,255,255,255,true) setTimer(Boltrablas,900000,1) idozito [ source ] = setTimer ( function ( ) idozito [ source ] = nil; end, 900000, 1, source); end else outputChatBox ( "#01AC41[SuperFun] #FFffFFTúl messze vagy a széftől! Gyere közelebb, nem harap..", thePlayer, 255, 0, 0, true ); end end end end addEventHandler( "onElementClicked", getRootElement( ), erablas ) 1 Link to comment
Tokio Posted September 16, 2017 Author Share Posted September 16, 2017 32 minutes ago, Mr.Loki said: Try this function erablas( button, state, thePlayer ) if button == "left" and state == "down" then if getElementType( source ) == "object" and getElementModel(source) == 1829 then local x, y, z = getElementPosition( thePlayer ) local x1, y1, z1 = getElementPosition( source ) local distance = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ) if distance < 4 then if ( idozito [ source ] ~= nil ) then outputChatBox ( "#01AC41[SuperFun] #FFffFFA következő széfrablásig várnod kell #01AC41".. math.floor ( getTimerDetails ( idozito [ thePlayer ] ) / 60000+1 ) .." percet.", thePlayer, 255, 0, 0, true ); else setElementFrozen(thePlayer, true) setPedAnimation(thePlayer , "rob_bank", "cat_safe_rob", 10000, true, true, true, false) setTimer(setElementFrozen,10000,1,thePlayer,false) setTimer(setPedAnimation,10000,1,thePlayer) randomM = math.random(500000,1500000) setTimer(function() givePlayerMoney(thePlayer,randomM) destroyElement(safe) end,10000,1) setTimer(outputChatBox, 10000,1,"#01AC41[SuperFun] #FFffFFÖsszesen raboltál #01AC41"..randomM.." #ffffffforintot.",thePlayer,255,255,255,true) setTimer(outputChatBox, 900000, 1,"#01AC41[SuperFun - #8C8C8CÉszaki] #FFffFFAz #01AC41északin #FFffFFújra kirabolhatóvá vált a széf! #01AC41(/eszaki)",root,255,255,255,true) setTimer(Boltrablas,900000,1) idozito [ source ] = setTimer ( function ( ) idozito [ source ] = nil; end, 900000, 1, source); end else outputChatBox ( "#01AC41[SuperFun] #FFffFFTúl messze vagy a széftől! Gyere közelebb, nem harap..", thePlayer, 255, 0, 0, true ); end end end end addEventHandler( "onElementClicked", getRootElement( ), erablas ) Working fine, thanks! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now