Bean666 Posted May 3, 2015 Share Posted May 3, 2015 hello i'm currently working on a bankrob script right now but, is it possible when the marker got destroyed by destroyelement , it can recover again? here's my code of client.lua local bankmarker = createMarker( -725.01849, 969.94299, 11.4, "cylinder", 1.5, 255, 0, 0, 255 ) addEventHandler ( "onClientMarkerHit", bankmarker, function ( hitElement ) if ( hitElement == localPlayer and getElementType ( hitElement ) == "player" ) then local playerTeam = getPlayerTeam ( hitElement ) if ( playerTeam and getTeamName ( playerTeam ) == "Criminals" ) then triggerServerEvent ("stealstart",getLocalPlayer(),stealstart) triggerServerEvent ("trespass",getLocalPlayer(),trespass) setTimer ( destroyElement, 30000, 1, source, bankmarker ) end end end ) Link to comment
WhoAmI Posted May 3, 2015 Share Posted May 3, 2015 https://wiki.multitheftauto.com/wiki/OnElementDestroy Link to comment
Bean666 Posted May 3, 2015 Author Share Posted May 3, 2015 in elements i'm not good , i really need help on this one. Link to comment
Bean666 Posted May 3, 2015 Author Share Posted May 3, 2015 tried this but marker doensn't create and marker doesn't appear even tho i restart the script addEventHandler("onElementDestroy", getRootElement(), function (player) if getElementType(source) == "marker" then setTimer ( createElement, 30000, 1, source, bankmarker ) end Link to comment
Bean666 Posted May 3, 2015 Author Share Posted May 3, 2015 this is clientside not server side. Link to comment
Walid Posted May 3, 2015 Share Posted May 3, 2015 this is clientside not server side. addEventHandler("onClientElementDestroy", getRootElement(), function () if getElementType(source) == "marker" and source == bankmarker then setTimer ( function() createMarker( -725.01849, 969.94299, 11.4, "cylinder", 1.5, 255, 0, 0, 255 ) end,3000,1) end) Link to comment
Bean666 Posted May 3, 2015 Author Share Posted May 3, 2015 loading script failed: prison/client.lua:45 unexpected symbol near ')' what should i do Link to comment
Walid Posted May 3, 2015 Share Posted May 3, 2015 loading script failed: prison/client.lua:45 unexpected symbol near ')'what should i do addEventHandler("onClientElementDestroy", getRootElement(), function () if getElementType(source) == "marker" and source == bankmarker then setTimer ( function() createMarker( -725.01849, 969.94299, 11.4, "cylinder", 1.5, 255, 0, 0, 255 ) end,3000,1) end end ) Link to comment
Bean666 Posted May 3, 2015 Author Share Posted May 3, 2015 EDIT: When it creates the marker again, the trigger doesn't work anymore when i step in the new created marker. when i step in the new created marker , nothing happens Link to comment
Walid Posted May 3, 2015 Share Posted May 3, 2015 EDIT:When it creates the marker again, the trigger doesn't work anymore when i step in the new created marker. when i step in the new created marker , nothing happens You must define the marker like this : addEventHandler("onClientElementDestroy", getRootElement(), function () if getElementType(source) == "marker" and source == bankmarker then setTimer ( function() bankmarker = createMarker( -725.01849, 969.94299, 11.4, "cylinder", 1.5, 255, 0, 0, 255 ) end,3000,1) end end ) Link to comment
Bean666 Posted May 3, 2015 Author Share Posted May 3, 2015 do i just need to add that code in my client.lua? Link to comment
Walid Posted May 3, 2015 Share Posted May 3, 2015 do i just need to add that code in my client.lua? copy and past my code Link to comment
Walid Posted May 3, 2015 Share Posted May 3, 2015 do i just need to add that code in my client.lua? ofc man it's client side ,copy and past my code Link to comment
Bean666 Posted May 3, 2015 Author Share Posted May 3, 2015 img of problem: here is the line of 30-41 in my server.lua 34 is the killtimer( V ) function killPlayer( ) outputChatBox ( "Radio: the robber stopped stealing money!", getRootElement(), 100, 200, 0, true ) for i, v in ipairs( players[ source ] ) do if isTimer( v ) then killTimer( v ) players[ source ][ i ] = nil end end players[ source ] = nil end addEvent( "killplayer", true ) addEventHandler( "killplayer", root, killPlayer ) Link to comment
Walid Posted May 3, 2015 Share Posted May 3, 2015 Are you serious player[source] table ???? Post full code here Link to comment
Bean666 Posted May 3, 2015 Author Share Posted May 3, 2015 full server.lua local players = {} local ticks = {} addEvent("stealstart",true) addEventHandler("stealstart",root, function() if players[ source ] and players[ source ][ 3 ] then return end players[ source ] = {} players[ source ][ 1 ] = setTimer ( outputChatBox, 30000, 1, "You have successfully stolen 50000$ in the bank",source, 255, 0, 0, false) players[ source ][ 2 ] = setTimer ( givePlayerMoney, 30000, 1, source, 50000 ) players[ source ][ 3 ] = setTimer( function( ) end, 100, 1 ) setTimer( function( source ) players[ source ][ 3 ] = nil end, 100, 1, source ) if ( getPlayerMoney (source) >= 0 ) then outputChatBox("You need to wait 30 seconds to get your 50000$ stay in the marker to get the money", source, 255, 0, 0) end end) addEvent("trespass",true) addEventHandler("trespass",root, function() if ticks[ source ] and getTickCount( ) - ticks[ source ] < 1000 then return end ticks[ source ] = getTickCount() if ( getPlayerMoney (source) >= 0 ) then outputChatBox ( "Radio: Someone is robbing the bank! , all police respond immediately!", getRootElement(), 100, 200, 0, true ) end end) function killPlayer( ) outputChatBox ( "Radio: the Robber(s) stopped stealing money!", getRootElement(), 100, 200, 0, true ) for i, v in ipairs( players[ source ] ) do if isTimer( v ) then killTimer( v ) players[ source ][ i ] = nil end end players[ source ] = nil end addEvent( "killplayer", true ) addEventHandler( "killplayer", root, killPlayer ) Link to comment
Walid Posted May 3, 2015 Share Posted May 3, 2015 what are trying to do , i think you need this Wiki Link to comment
Bean666 Posted May 3, 2015 Author Share Posted May 3, 2015 all works dude , only doesn't work is the respawning marker. Link to comment
Walid Posted May 3, 2015 Share Posted May 3, 2015 all works dude , only doesn't work is the respawning marker. i'm sorry i can't help you your code is totaly wrong, you need to learn LUA language first . sorry Link to comment
Bean666 Posted May 3, 2015 Author Share Posted May 3, 2015 i know lua language , this code really works for me . i only need the marker to respawn and i have scripts posted in the community. 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