rafull6 Posted February 5, 2012 Share Posted February 5, 2012 (edited) Hey, guys! Today one guy shared Bank Robbery script for me, but there is one problem with it: After the robbery, there is cooldown time (the time before the next one robbery will be available), and when those time left, and robbery is available you need to reconnect to the server, or window with button "start robbering" would not start. Here is my code: addEvent("stopplaySoundRobbery",true) bankMarker = createMarker(364.00500488281,163.38682556152,1008.3828125,"cylinder",3,150,0,0,255) bankBip = createBlip ( 2416.5532226563, 1124.1168212891, 10.8203125, 36, 2) setElementInterior(bankMarker,3,364.00500488281,163.38682556152,1007.4828125) --3 int missionState = 0 bankColshape = createColCircle ( 2414.1735839844,1123.9982910156,10.8203125,1) addEventHandler("onClientColShapeLeave",bankColshape, function( LeaveElement, matchingDimension ) if ( LeaveElement == getLocalPlayer() ) then -- if missionState == 1 then if getElementData(LeaveElement,"bank") == 1 then outputChatBox("`Миссия провалена вы не захватили банк!",255,0,0) triggerServerEvent("ServerPlaySoundRobberyStop",root) killTimer(bankRobberTimer) setElementData(LeaveElement,"bank",2) --setElementData(getLocalPlayer(),"bank",nil) setTimer(function() setElementData(LeaveElement,"bank",0) end,60000) end -- end end end ) addEventHandler("onClientPlayerWasted",getLocalPlayer(), function() --if missionState == 1 then if getElementData(getLocalPlayer(),"bank") == 1 then outputChatBox("`Миссия провалена вы не захватили банк!",255,0,0) triggerServerEvent("ServerPlaySoundRobberyStop",root) --setElementData(getLocalPlayer(),"bank",nil) setElementData(getLocalPlayer(),"bank",2) killTimer(bankRobberTimer) setTimer(function() setElementData(getLocalPlayer(),"bank",0) end,60000) end --end end ) addEvent("playSoundRobbery",true) addEventHandler("playSoundRobbery",root, function() sound = playSound3D("alarm.mp3", 364.00500488281,163.38682556152,1010.3828125, true) setSoundMaxDistance ( sound, 50 ) end ) addEvent("playSoundRobberyStop",true) addEventHandler("playSoundRobberyStop",root, function() stopSound( sound ) end ) --[[ addEvent("stopplaySoundRobbery",true) addEventHandler("stopplaySoundRobbery",root, function() stopSound( sound ) end ) ]] addEventHandler("onClientMarkerHit",bankMarker, function( hitElement, matchingDimension ) --if missionState == 1 then --end if hitElement == getLocalPlayer() then if getElementData(hitElement,"bank") == 1 then return elseif getElementData(hitElement,"bank") == 2 then return end showCursor(true) bankWindow = guiCreateWindow(0.3184,0.3568,0.3809,0.306,"ROBBER",true) buttonYes = guiCreateButton(36,147,89,46,"Yes",false,bankWindow) buttonNo = guiCreateButton(251,147,89,46,"No",false,bankWindow) addEventHandler ( "onClientGUIClick", buttonYes, function( ) showCursor(false) guiSetVisible(bankWindow,false) triggerServerEvent("ServerPlaySoundRobbery",root) --triggerServerEvent("ServerPlaySoundRobbery",getLocalPlayer()) outputChatBox("`Вы захватили банк вы должны продержаться 5 минут.",255,0,0) outputChatBox("`Вы сможете захватить банк через 180 минут.",255,0,0) outputChatBox("`Если вы выйдите из банка то миссия будет провалена!",255,0,0) setElementData(hitElement,"bank",1) callServerfunction("setPlayerWantedLevel",hitElement, 6 ) --missionState = 1 bankRobberTimer = setTimer(function() outputChatBox("`Вы успешно ограбили банк вы получили 100 000 $.",255,0,0) triggerServerEvent("ServerPlaySoundRobberyStop",root) setTimer(function() setElementData(getLocalPlayer(),"bank",0) end,60000) givePlayerMoney(100000) end,60000,1) --300000 end ) addEventHandler ( "onClientGUIClick", buttonNo, function ( ) showCursor(false) guiSetVisible(bankWindow,false) end ) end end ) function callServerfunction(funcname, ...) local arg = { ... } if (arg[1]) then for key, value in next, arg do if (type(value) == "number") then arg[key] = tostring(value) end end end triggerServerEvent("onClientCallsServerFunction", resourceRoot , funcname, unpack(arg)) end addCommandHandler("data",function() setElementData(getLocalPlayer(),"bank",0) end ) How to fix this failure? Edited February 6, 2012 by Guest Link to comment
Kenix Posted February 5, 2012 Share Posted February 5, 2012 Explain better. addEvent( "stopplaySoundRobbery",true ) addEvent( "playSoundRobbery",true ) addEvent( "playSoundRobberyStop",true ) bankMarker = createMarker( 364.00500488281,163.38682556152,1008.3828125,"cylinder",3,150,0,0,255 ) bankBip = createBlip ( 2416.5532226563, 1124.1168212891, 10.8203125, 36, 2 ) setElementInterior( bankMarker,3,364.00500488281,163.38682556152,1007.4828125 ) --3 int missionState = 0 bankColshape = createColCircle ( 2414.1735839844,1123.9982910156,10.8203125,1 ) addEventHandler( "onClientColShapeLeave",bankColshape, function( LeaveElement, matchingDimension ) if LeaveElement == localPlayer then if getElementData( LeaveElement,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end setElementData( LeaveElement,"bank",2 ) setTimer( function ( player ) setElementData( player,"bank",0 ) end, 60000, 1,LeaveElement ) end end end ) addEventHandler( "onClientPlayerWasted",localPlayer, function( ) if getElementData( source,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( source,"bank",2 ) if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end setTimer( function( player ) setElementData( player,"bank",0 ) end, 60000, 1 , source ) end end ) addEventHandler( "playSoundRobbery",root, function( ) sound = playSound3D ("alarm.mp3", 364.00500488281,163.38682556152,1010.3828125, true ) setSoundMaxDistance ( sound, 50 ) end ) addEventHandler( "playSoundRobberyStop",root, function( ) stopSound( sound ) end ) addEventHandler( "onClientMarkerHit",bankMarker, function( hitElement, matchingDimension ) if hitElement == localPlayer then if getElementData( hitElement,"bank" ) == 1 or etElementData( hitElement,"bank" ) == 2 then return end showCursor( true ) bankWindow = guiCreateWindow(0.3184,0.3568,0.3809,0.306,"ROBBER",true) buttonYes = guiCreateButton(36,147,89,46,"Yes",false,bankWindow) buttonNo = guiCreateButton(251,147,89,46,"No",false,bankWindow) addEventHandler ( "onClientGUIClick", buttonYes, function( ) showCursor( false ) guiSetVisible( bankWindow,false ) triggerServerEvent( "ServerPlaySoundRobbery",root ) --triggerServerEvent("ServerPlaySoundRobbery",localPlayer) outputChatBox( "`Вы захватили банк вы должны продержаться 5 минут.",255,0,0 ) outputChatBox( "`Вы сможете захватить банк через 180 минут.",255,0,0 ) outputChatBox( "`Если вы выйдите из банка то миссия будет провалена!",255,0,0 ) setElementData( hitElement,"bank",1 ) callServerfunction( "setPlayerWantedLevel",hitElement, 6 ) --missionState = 1 if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end bankRobberTimer = setTimer( function( ) outputChatBox("`Вы успешно ограбили банк вы получили 100 000 $.",255,0,0) triggerServerEvent("ServerPlaySoundRobberyStop",root) setTimer( function( ) setElementData( localPlayer,"bank",0 ) end, 60000 , 1 ) callServerfunction( 'givePlayerMoney',localPlayer,100000 ) end, 60000, 1 ) --300000 end ,false ) addEventHandler ( "onClientGUIClick", buttonNo, function ( ) showCursor( false ) guiSetVisible( bankWindow,false ) end ,false ) end end ) function callServerfunction( funcname, ... ) local arg = { ... } if arg[1] then for key, value in next, arg do if type( value ) == "number" then arg[ key ] = tostring( value ) end end end triggerServerEvent( "onClientCallsServerFunction", resourceRoot , funcname, unpack( arg ) ) end addCommandHandler( "data", function( ) setElementData( localPlayer,"bank",0 ) end ) Link to comment
rafull6 Posted February 5, 2012 Author Share Posted February 5, 2012 Explain better. addEvent( "stopplaySoundRobbery",true ) addEvent( "playSoundRobbery",true ) addEvent( "playSoundRobberyStop",true ) bankMarker = createMarker( 364.00500488281,163.38682556152,1008.3828125,"cylinder",3,150,0,0,255 ) bankBip = createBlip ( 2416.5532226563, 1124.1168212891, 10.8203125, 36, 2 ) setElementInterior( bankMarker,3,364.00500488281,163.38682556152,1007.4828125 ) --3 int missionState = 0 bankColshape = createColCircle ( 2414.1735839844,1123.9982910156,10.8203125,1 ) addEventHandler( "onClientColShapeLeave",bankColshape, function( LeaveElement, matchingDimension ) if LeaveElement == localPlayer then if getElementData( LeaveElement,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end setElementData( LeaveElement,"bank",2 ) setTimer( function ( player ) setElementData( player,"bank",0 ) end, 60000, 1,LeaveElement ) end end end ) addEventHandler( "onClientPlayerWasted",localPlayer, function( ) if getElementData( source,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( source,"bank",2 ) if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end setTimer( function( player ) setElementData( player,"bank",0 ) end, 60000, 1 , source ) end end ) addEventHandler( "playSoundRobbery",root, function( ) sound = playSound3D ("alarm.mp3", 364.00500488281,163.38682556152,1010.3828125, true ) setSoundMaxDistance ( sound, 50 ) end ) addEventHandler( "playSoundRobberyStop",root, function( ) stopSound( sound ) end ) addEventHandler( "onClientMarkerHit",bankMarker, function( hitElement, matchingDimension ) if hitElement == localPlayer then if getElementData( hitElement,"bank" ) == 1 or etElementData( hitElement,"bank" ) == 2 then return end showCursor( true ) bankWindow = guiCreateWindow(0.3184,0.3568,0.3809,0.306,"ROBBER",true) buttonYes = guiCreateButton(36,147,89,46,"Yes",false,bankWindow) buttonNo = guiCreateButton(251,147,89,46,"No",false,bankWindow) addEventHandler ( "onClientGUIClick", buttonYes, function( ) showCursor( false ) guiSetVisible( bankWindow,false ) triggerServerEvent( "ServerPlaySoundRobbery",root ) --triggerServerEvent("ServerPlaySoundRobbery",localPlayer) outputChatBox( "`Вы захватили банк вы должны продержаться 5 минут.",255,0,0 ) outputChatBox( "`Вы сможете захватить банк через 180 минут.",255,0,0 ) outputChatBox( "`Если вы выйдите из банка то миссия будет провалена!",255,0,0 ) setElementData( hitElement,"bank",1 ) callServerfunction( "setPlayerWantedLevel",hitElement, 6 ) --missionState = 1 if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end bankRobberTimer = setTimer( function( ) outputChatBox("`Вы успешно ограбили банк вы получили 100 000 $.",255,0,0) triggerServerEvent("ServerPlaySoundRobberyStop",root) setTimer( function( ) setElementData( localPlayer,"bank",0 ) end, 60000 , 1 ) callServerfunction( 'givePlayerMoney',localPlayer,100000 ) end, 60000, 1 ) --300000 end ,false ) addEventHandler ( "onClientGUIClick", buttonNo, function ( ) showCursor( false ) guiSetVisible( bankWindow,false ) end ,false ) end end ) function callServerfunction( funcname, ... ) local arg = { ... } if arg[1] then for key, value in next, arg do if type( value ) == "number" then arg[ key ] = tostring( value ) end end end triggerServerEvent( "onClientCallsServerFunction", resourceRoot , funcname, unpack( arg ) ) end addCommandHandler( "data", function( ) setElementData( localPlayer,"bank",0 ) end ) Strange but it doesn't work Link to comment
Kenix Posted February 5, 2012 Share Posted February 5, 2012 It should work. addEvent( "stopplaySoundRobbery",true ) addEvent( "playSoundRobbery",true ) addEvent( "playSoundRobberyStop",true ) local timerShape,timerWasted bankMarker = createMarker( 364.00500488281,163.38682556152,1008.3828125,"cylinder",3,150,0,0,255 ) bankBip = createBlip ( 2416.5532226563, 1124.1168212891, 10.8203125, 36, 2 ) setElementInterior( bankMarker,3,364.00500488281,163.38682556152,1007.4828125 ) --3 int missionState = 0 bankColshape = createColCircle ( 2414.1735839844,1123.9982910156,10.8203125,1 ) addEventHandler( "onClientColShapeLeave",bankColshape, function( LeaveElement, matchingDimension ) if LeaveElement == localPlayer then if getElementData( LeaveElement,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( LeaveElement,"bank",2 ) if isTimer( timerShape ) then killTimer( timerShape ) end timerShape = setTimer( function ( player ) setElementData( player,"bank",0 ) end, 60000, 1,LeaveElement ) end end end ) addEventHandler( "onClientPlayerWasted",localPlayer, function( ) if getElementData( source,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( source,"bank",2 ) if isTimer( timerWasted ) then killTimer( timerWasted ) end timerWasted = setTimer( function( player ) setElementData( player,"bank",0 ) end, 60000, 1 , source ) end end ) addEventHandler( "playSoundRobbery",root, function( ) sound = playSound3D ("alarm.mp3", 364.00500488281,163.38682556152,1010.3828125, true ) setSoundMaxDistance ( sound, 50 ) end ) addEventHandler( "playSoundRobberyStop",root, function( ) stopSound( sound ) end ) addEventHandler( "onClientMarkerHit",bankMarker, function( hitElement, matchingDimension ) if hitElement == localPlayer then if getElementData( hitElement,"bank" ) == 1 or etElementData( hitElement,"bank" ) == 2 then return end showCursor( true ) bankWindow = guiCreateWindow(0.3184,0.3568,0.3809,0.306,"ROBBER",true) buttonYes = guiCreateButton(36,147,89,46,"Yes",false,bankWindow) buttonNo = guiCreateButton(251,147,89,46,"No",false,bankWindow) addEventHandler ( "onClientGUIClick", buttonYes, function( ) showCursor( false ) guiSetVisible( bankWindow,false ) triggerServerEvent( "ServerPlaySoundRobbery",root ) --triggerServerEvent("ServerPlaySoundRobbery",localPlayer) outputChatBox( "`Вы захватили банк вы должны продержаться 5 минут.",255,0,0 ) outputChatBox( "`Вы сможете захватить банк через 180 минут.",255,0,0 ) outputChatBox( "`Если вы выйдите из банка то миссия будет провалена!",255,0,0 ) setElementData( hitElement,"bank",1 ) callServerfunction( "setPlayerWantedLevel",hitElement, 6 ) --missionState = 1 if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end bankRobberTimer = setTimer( function( ) outputChatBox("`Вы успешно ограбили банк вы получили 100 000 $.",255,0,0) triggerServerEvent("ServerPlaySoundRobberyStop",root) setTimer( function( ) setElementData( localPlayer,"bank",0 ) end, 60000 , 1 ) callServerfunction( 'givePlayerMoney',localPlayer,100000 ) end, 60000, 1 ) --300000 end ,false ) addEventHandler ( "onClientGUIClick", buttonNo, function ( ) showCursor( false ) guiSetVisible( bankWindow,false ) end ,false ) end end ) function callServerfunction( funcname, ... ) local arg = { ... } if arg[1] then for key, value in next, arg do if type( value ) == "number" then arg[ key ] = tostring( value ) end end end triggerServerEvent( "onClientCallsServerFunction", resourceRoot , funcname, unpack( arg ) ) end addCommandHandler( "data", function( ) setElementData( localPlayer,"bank",0 ) end ) /debugscript 3? Link to comment
Castillo Posted February 5, 2012 Share Posted February 5, 2012 addEvent( "stopplaySoundRobbery",true ) addEvent( "playSoundRobbery",true ) addEvent( "playSoundRobberyStop",true ) local timerShape,timerWasted bankMarker = createMarker( 364.00500488281,163.38682556152,1008.3828125,"cylinder",3,150,0,0,255 ) bankBip = createBlip ( 2416.5532226563, 1124.1168212891, 10.8203125, 36, 2 ) setElementInterior( bankMarker,3,364.00500488281,163.38682556152,1007.4828125 ) --3 int missionState = 0 bankColshape = createColCircle ( 2414.1735839844,1123.9982910156,10.8203125,1 ) addEventHandler( "onClientColShapeLeave",bankColshape, function( LeaveElement, matchingDimension ) if LeaveElement == localPlayer then if getElementData( LeaveElement,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( LeaveElement,"bank",2 ) if isTimer( timerShape ) then killTimer( timerShape ) end timerShape = setTimer( function ( player ) setElementData( player,"bank",0 ) end, 60000, 1,LeaveElement ) end end end ) addEventHandler( "onClientPlayerWasted",localPlayer, function( ) if getElementData( source,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( source,"bank",2 ) if isTimer( timerWasted ) then killTimer( timerWasted ) end timerWasted = setTimer( function( player ) setElementData( player,"bank",0 ) end, 60000, 1 , source ) end end ) addEventHandler( "playSoundRobbery",root, function( ) sound = playSound3D ("alarm.mp3", 364.00500488281,163.38682556152,1010.3828125, true ) setSoundMaxDistance ( sound, 50 ) end ) addEventHandler( "playSoundRobberyStop",root, function( ) stopSound( sound ) end ) addEventHandler( "onClientMarkerHit",bankMarker, function( hitElement, matchingDimension ) if hitElement == localPlayer then if getElementData( hitElement,"bank" ) == 1 or getElementData( hitElement,"bank" ) == 2 then return end showCursor( true ) bankWindow = guiCreateWindow(0.3184,0.3568,0.3809,0.306,"ROBBER",true) buttonYes = guiCreateButton(36,147,89,46,"Yes",false,bankWindow) buttonNo = guiCreateButton(251,147,89,46,"No",false,bankWindow) addEventHandler ( "onClientGUIClick", buttonYes, function( ) showCursor( false ) guiSetVisible( bankWindow,false ) triggerServerEvent( "ServerPlaySoundRobbery",root ) --triggerServerEvent("ServerPlaySoundRobbery",localPlayer) outputChatBox( "`Вы захватили банк вы должны продержаться 5 минут.",255,0,0 ) outputChatBox( "`Вы сможете захватить банк через 180 минут.",255,0,0 ) outputChatBox( "`Если вы выйдите из банка то миссия будет провалена!",255,0,0 ) setElementData( hitElement,"bank",1 ) callServerfunction( "setPlayerWantedLevel",hitElement, 6 ) --missionState = 1 if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end bankRobberTimer = setTimer( function( ) outputChatBox("`Вы успешно ограбили банк вы получили 100 000 $.",255,0,0) triggerServerEvent("ServerPlaySoundRobberyStop",root) setTimer( function( ) setElementData( localPlayer,"bank",0 ) end, 60000 , 1 ) callServerfunction( 'givePlayerMoney',localPlayer,100000 ) end, 60000, 1 ) --300000 end ,false ) addEventHandler ( "onClientGUIClick", buttonNo, function ( ) showCursor( false ) guiSetVisible( bankWindow,false ) end ,false ) end end ) function callServerfunction( funcname, ... ) local arg = { ... } if arg[1] then for key, value in next, arg do if type( value ) == "number" then arg[ key ] = tostring( value ) end end end triggerServerEvent( "onClientCallsServerFunction", resourceRoot , funcname, unpack( arg ) ) end addCommandHandler( "data", function( ) setElementData( localPlayer,"bank",0 ) end ) Link to comment
Kenix Posted February 5, 2012 Share Posted February 5, 2012 My bad forgot 'g' in function getElementData addEvent( "stopplaySoundRobbery",true ) addEvent( "playSoundRobbery",true ) addEvent( "playSoundRobberyStop",true ) local timerShape,timerWasted bankMarker = createMarker( 364.00500488281,163.38682556152,1008.3828125,"cylinder",3,150,0,0,255 ) bankBip = createBlip ( 2416.5532226563, 1124.1168212891, 10.8203125, 36, 2 ) setElementInterior( bankMarker,3,364.00500488281,163.38682556152,1007.4828125 ) --3 int missionState = 0 bankColshape = createColCircle ( 2414.1735839844,1123.9982910156,10.8203125,1 ) addEventHandler( "onClientColShapeLeave",bankColshape, function( LeaveElement, matchingDimension ) if LeaveElement == localPlayer then if getElementData( LeaveElement,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( LeaveElement,"bank",2 ) if isTimer( timerShape ) then killTimer( timerShape ) end timerShape = setTimer( function ( player ) setElementData( player,"bank",0 ) end, 60000, 1,LeaveElement ) end end end ) addEventHandler( "onClientPlayerWasted",localPlayer, function( ) if getElementData( source,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( source,"bank",2 ) if isTimer( timerWasted ) then killTimer( timerWasted ) end timerWasted = setTimer( function( player ) setElementData( player,"bank",0 ) end, 60000, 1 , source ) end end ) addEventHandler( "playSoundRobbery",root, function( ) sound = playSound3D ("alarm.mp3", 364.00500488281,163.38682556152,1010.3828125, true ) setSoundMaxDistance ( sound, 50 ) end ) addEventHandler( "playSoundRobberyStop",root, function( ) stopSound( sound ) end ) addEventHandler( "onClientMarkerHit",bankMarker, function( hitElement, matchingDimension ) if hitElement == localPlayer then if getElementData( hitElement,"bank" ) == 1 or getElementData( hitElement,"bank" ) == 2 then return end showCursor( true ) bankWindow = guiCreateWindow(0.3184,0.3568,0.3809,0.306,"ROBBER",true) buttonYes = guiCreateButton(36,147,89,46,"Yes",false,bankWindow) buttonNo = guiCreateButton(251,147,89,46,"No",false,bankWindow) addEventHandler ( "onClientGUIClick", buttonYes, function( ) showCursor( false ) guiSetVisible( bankWindow,false ) triggerServerEvent( "ServerPlaySoundRobbery",root ) --triggerServerEvent("ServerPlaySoundRobbery",localPlayer) outputChatBox( "`Вы захватили банк вы должны продержаться 5 минут.",255,0,0 ) outputChatBox( "`Вы сможете захватить банк через 180 минут.",255,0,0 ) outputChatBox( "`Если вы выйдите из банка то миссия будет провалена!",255,0,0 ) setElementData( hitElement,"bank",1 ) callServerfunction( "setPlayerWantedLevel",hitElement, 6 ) --missionState = 1 if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end bankRobberTimer = setTimer( function( ) outputChatBox("`Вы успешно ограбили банк вы получили 100 000 $.",255,0,0) triggerServerEvent("ServerPlaySoundRobberyStop",root) setTimer( function( ) setElementData( localPlayer,"bank",0 ) end, 60000 , 1 ) callServerfunction( 'givePlayerMoney',localPlayer,100000 ) end, 60000, 1 ) --300000 end ,false ) addEventHandler ( "onClientGUIClick", buttonNo, function ( ) showCursor( false ) guiSetVisible( bankWindow,false ) end ,false ) end end ) function callServerfunction( funcname, ... ) local arg = { ... } if arg[1] then for key, value in next, arg do if type( value ) == "number" then arg[ key ] = tostring( value ) end end end triggerServerEvent( "onClientCallsServerFunction", resourceRoot , funcname, unpack( arg ) ) end addCommandHandler( "data", function( ) setElementData( localPlayer,"bank",0 ) end ) It should work. Link to comment
rafull6 Posted February 5, 2012 Author Share Posted February 5, 2012 Thank you) Now it is working perfectly) Thank you very much!!!!! P.S. Is it possible to add in this code next thing. Marke will appear when cooldown is finished, and disappear when robbery is done Link to comment
Kenix Posted February 5, 2012 Share Posted February 5, 2012 Thank you) Now it is working perfectly)Thank you very much!!!!! No problem. addEvent( "stopplaySoundRobbery",true ) addEvent( "playSoundRobbery",true ) addEvent( "playSoundRobberyStop",true ) local timerShape,timerWasted bankMarker = createMarker( 364.00500488281,163.38682556152,1008.3828125,"cylinder",3,150,0,0,255 ) bankBip = createBlip ( 2416.5532226563, 1124.1168212891, 10.8203125, 36, 2 ) setElementInterior( bankMarker,3,364.00500488281,163.38682556152,1007.4828125 ) --3 int missionState = 0 bankColshape = createColCircle ( 2414.1735839844,1123.9982910156,10.8203125,1 ) addEventHandler( "onClientColShapeLeave",bankColshape, function( LeaveElement, matchingDimension ) if LeaveElement == localPlayer then if getElementData( LeaveElement,"bank" ) == 1 then setElementAlpha( bankMarker,255 ) outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( LeaveElement,"bank",2 ) if isTimer( timerShape ) then killTimer( timerShape ) end timerShape = setTimer( function ( player ) setElementData( player,"bank",0 ) end, 60000, 1,LeaveElement ) end end end ) addEventHandler( "onClientPlayerWasted",localPlayer, function( ) if getElementData( source,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) setElementAlpha( bankMarker,255 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( source,"bank",2 ) if isTimer( timerWasted ) then killTimer( timerWasted ) end timerWasted = setTimer( function( player ) setElementData( player,"bank",0 ) end, 60000, 1 , source ) end end ) addEventHandler( "playSoundRobbery",root, function( ) sound = playSound3D ("alarm.mp3", 364.00500488281,163.38682556152,1010.3828125, true ) setSoundMaxDistance ( sound, 50 ) end ) addEventHandler( "playSoundRobberyStop",root, function( ) stopSound( sound ) end ) addEventHandler( "onClientMarkerHit",bankMarker, function( hitElement, matchingDimension ) if hitElement == localPlayer then if getElementData( hitElement,"bank" ) == 1 or getElementData( hitElement,"bank" ) == 2 then return end showCursor( true ) bankWindow = guiCreateWindow(0.3184,0.3568,0.3809,0.306,"ROBBER",true) buttonYes = guiCreateButton(36,147,89,46,"Yes",false,bankWindow) buttonNo = guiCreateButton(251,147,89,46,"No",false,bankWindow) addEventHandler ( "onClientGUIClick", buttonYes, function( ) showCursor( false ) guiSetVisible( bankWindow,false ) triggerServerEvent( "ServerPlaySoundRobbery",root ) --triggerServerEvent("ServerPlaySoundRobbery",localPlayer) outputChatBox( "`Вы захватили банк вы должны продержаться 5 минут.",255,0,0 ) setElementAlpha( bankMarker,0 ) outputChatBox( "`Вы сможете захватить банк через 180 минут.",255,0,0 ) outputChatBox( "`Если вы выйдите из банка то миссия будет провалена!",255,0,0 ) setElementData( hitElement,"bank",1 ) callServerfunction( "setPlayerWantedLevel",hitElement, 6 ) --missionState = 1 if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end bankRobberTimer = setTimer( function( ) outputChatBox("`Вы успешно ограбили банк вы получили 100 000 $.",255,0,0) triggerServerEvent("ServerPlaySoundRobberyStop",root) setTimer( function( ) setElementData( localPlayer,"bank",0 ) setElementAlpha( bankMarker,255 ) end, 60000 , 1 ) callServerfunction( 'givePlayerMoney',localPlayer,100000 ) end, 60000, 1 ) --300000 end ,false ) addEventHandler ( "onClientGUIClick", buttonNo, function ( ) showCursor( false ) guiSetVisible( bankWindow,false ) end ,false ) end end ) function callServerfunction( funcname, ... ) local arg = { ... } if arg[1] then for key, value in next, arg do if type( value ) == "number" then arg[ key ] = tostring( value ) end end end triggerServerEvent( "onClientCallsServerFunction", resourceRoot , funcname, unpack( arg ) ) end addCommandHandler( "data", function( ) setElementData( localPlayer,"bank",0 ) end ) So if you start bank robbing marker is hide. If bank robber is done marker become show in next 1 min. If you left bank robbing or die marker show. Link to comment
rafull6 Posted February 5, 2012 Author Share Posted February 5, 2012 Awesome! Kenix you're genius! Thank you very much again!!! Link to comment
Kenix Posted February 6, 2012 Share Posted February 6, 2012 Little fix, at the request of the author. addEvent( "stopplaySoundRobbery",true ) addEvent( "playSoundRobbery",true ) addEvent( "playSoundRobberyStop",true ) local timerShape,timerWasted bankMarker = createMarker( 364.00500488281,163.38682556152,1008.3828125,"cylinder",3,150,0,0,255 ) bankBip = createBlip ( 2416.5532226563, 1124.1168212891, 10.8203125, 36, 2 ) setElementInterior( bankMarker,3,364.00500488281,163.38682556152,1007.4828125 ) --3 int missionState = 0 bankColshape = createColCircle ( 2414.1735839844,1123.9982910156,10.8203125,1 ) addEventHandler( "onClientColShapeLeave",bankColshape, function( LeaveElement, matchingDimension ) if LeaveElement == localPlayer then if getElementData( LeaveElement,"bank" ) == 1 then setElementAlpha( bankMarker,255 ) outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( LeaveElement,"bank",2 ) if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end if isTimer( timerShape ) then killTimer( timerShape ) end timerShape = setTimer( function ( player ) setElementData( player,"bank",0 ) end, 60000, 1,LeaveElement ) end end end ) addEventHandler( "onClientPlayerWasted",localPlayer, function( ) if getElementData( source,"bank" ) == 1 then outputChatBox( "`Миссия провалена вы не захватили банк!",255,0,0 ) setElementAlpha( bankMarker,255 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( source,"bank",2 ) if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end if isTimer( timerWasted ) then killTimer( timerWasted ) end timerWasted = setTimer( function( player ) setElementData( player,"bank",0 ) end, 60000, 1 , source ) end end ) addEventHandler( "playSoundRobbery",root, function( ) sound = playSound3D ("alarm.mp3", 364.00500488281,163.38682556152,1010.3828125, true ) setSoundMaxDistance ( sound, 50 ) end ) addEventHandler( "playSoundRobberyStop",root, function( ) stopSound( sound ) end ) addEventHandler( "onClientMarkerHit",bankMarker, function( hitElement, matchingDimension ) if hitElement == localPlayer then if getElementData( hitElement,"bank" ) == 1 or getElementData( hitElement,"bank" ) == 2 then return end showCursor( true ) bankWindow = guiCreateWindow(0.3184,0.3568,0.3809,0.306,"ROBBER",true) buttonYes = guiCreateButton(36,147,89,46,"Yes",false,bankWindow) buttonNo = guiCreateButton(251,147,89,46,"No",false,bankWindow) addEventHandler ( "onClientGUIClick", buttonYes, function( ) showCursor( false ) guiSetVisible( bankWindow,false ) triggerServerEvent( "ServerPlaySoundRobbery",root ) --triggerServerEvent("ServerPlaySoundRobbery",localPlayer) outputChatBox( "`Вы захватили банк вы должны продержаться 5 минут.",255,0,0 ) setElementAlpha( bankMarker,0 ) outputChatBox( "`Вы сможете захватить банк через 180 минут.",255,0,0 ) outputChatBox( "`Если вы выйдите из банка то миссия будет провалена!",255,0,0 ) setElementData( hitElement,"bank",1 ) callServerfunction( "setPlayerWantedLevel",hitElement, 6 ) --missionState = 1 if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end bankRobberTimer = setTimer( function( ) outputChatBox("`Вы успешно ограбили банк вы получили 100 000 $.",255,0,0) triggerServerEvent("ServerPlaySoundRobberyStop",root) setTimer( function( ) setElementData( localPlayer,"bank",0 ) setElementAlpha( bankMarker,255 ) end, 60000 , 1 ) callServerfunction( 'givePlayerMoney',localPlayer,100000 ) end, 60000, 1 ) --300000 end ,false ) addEventHandler ( "onClientGUIClick", buttonNo, function ( ) showCursor( false ) guiSetVisible( bankWindow,false ) end ,false ) end end ) function callServerfunction( funcname, ... ) local arg = { ... } if arg[1] then for key, value in next, arg do if type( value ) == "number" then arg[ key ] = tostring( value ) end end end triggerServerEvent( "onClientCallsServerFunction", resourceRoot , funcname, unpack( arg ) ) end addCommandHandler( "data", function( ) setElementData( localPlayer,"bank",0 ) end ) Link to comment
rafull6 Posted February 6, 2012 Author Share Posted February 6, 2012 perfect) Like allways) Link to comment
rafull6 Posted February 6, 2012 Author Share Posted February 6, 2012 One more question. I have a little problem. When robbery started, and player makes reconnect/disconnect -> then when he joins the server, and hits bank marker - he can't start robbery. Nothig happens. I think it's because of the timer. He dies, and time stops. I tried to add this code to main script to fix this problem but script stops work addEventHandler ( "onPlayerQuit", getRootElement(), quitPlayer function( ) if getElementData( source,"bank" ) == 1 then setElementAlpha( bankMarker,255 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( source,"bank",2 ) if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end if isTimer( timerWasted ) then killTimer( timerWasted ) end timerWasted = setTimer( function( player ) setElementData( player,"bank",0 ) end, 60000, 1 , source ) end end ) Where is my mistake? Link to comment
Kenix Posted February 6, 2012 Share Posted February 6, 2012 1.variable quitPlayer nil in your script 2.addEventHandler have only 5 arguments and 4 argument is getPropagated but you use function 3.You forgot , Fixed code. addEventHandler ( "onPlayerQuit", root, function( ) if getElementData( source,"bank" ) == 1 then setElementAlpha( bankMarker,255 ) triggerServerEvent( "ServerPlaySoundRobberyStop",root ) setElementData( source,"bank",2 ) if isTimer( bankRobberTimer ) then killTimer( bankRobberTimer ) end if isTimer( timerWasted ) then killTimer( timerWasted ) end timerWasted = setTimer( function( player ) setElementData( player,"bank",0 ) end, 60000, 1 , source ) end end ) https://wiki.multitheftauto.com/wiki/AddEventHandler Learn it viewtopic.php?f=141&t=32458 Link to comment
rafull6 Posted February 6, 2012 Author Share Posted February 6, 2012 You saved my ass again Link to comment
rafull6 Posted February 6, 2012 Author Share Posted February 6, 2012 Kenix, should this fixed code save robbery "cooldown" after player disconnects from the server? In my case when I'm making reconnect I can rob the bank without any cooldown Link to comment
Kenix Posted February 7, 2012 Share Posted February 7, 2012 (edited) I rewrite this code. Edited February 7, 2012 by Guest Link to comment
Kenix Posted February 7, 2012 Share Posted February 7, 2012 Full rewrite Client addEvent( 'onClientRobberMenu',true ) addEvent( 'onSoundRobbery',true ) addEvent( 'onSoundRobberyStop',true ) local bankWindow = guiCreateWindow( 0.3184,0.3568,0.3809,0.306,"ROBBER",true ) local buttonYes = guiCreateButton( 36,147,89,46,"Yes",false,bankWindow ) local buttonNo = guiCreateButton( 251,147,89,46,"No",false,bankWindow ) guiSetVisible( bankWindow,false ) addEventHandler( "onSoundRobbery",root, function( ) sound = playSound3D ( "alarm.mp3", 364.00500488281,163.38682556152,1010.3828125, true ) setSoundMaxDistance ( sound, 50 ) end ) addEventHandler( "onSoundRobberyStop",root, function( ) if isElement( sound ) then stopSound( sound ) end end ) addEventHandler( 'onClientRobberMenu',localPlayer, function( ) showCursor( true ) guiSetVisible( bankWindow,true ) addEventHandler ( "onClientGUIClick", buttonYes, function( ) showCursor( false ) guiSetVisible( bankWindow,false ) outputChatBox( "`Вы захватили банк вы должны продержаться 5 минут.",255,0,0 ) outputChatBox( "`Вы сможете захватить банк через 180 минут.",255,0,0 ) outputChatBox( "`Если вы выйдите из банка то миссия будет провалена!",255,0,0 ) triggerServerEvent( 'onStartRobber',localPlayer ) end ,false ) addEventHandler ( "onClientGUIClick", buttonNo, function ( ) showCursor( false ) guiSetVisible( bankWindow,false ) end ,false ) end ) Server addEvent( 'onStartRobber',true ) addEvent( 'onEndRobber',true ) local timer,timerOpenBank local bankMarker = createMarker( 364.00500488281,163.38682556152,1008.3828125,"cylinder",3,150,0,0,255 ) local bankBip = createBlip ( 2416.5532226563, 1124.1168212891, 10.8203125, 36, 2 ) setElementInterior( bankMarker,3,364.00500488281,163.38682556152,1007.4828125 ) local bankColshape = createColCircle ( 2414.1735839844,1123.9982910156,10.8203125,1 ) function findMarker( source ) if isElement( source ) then local ret = false for _,v in pairs( getElementsByType 'marker' ) do if getElementData( v,'attack' ) == source then ret = v end end return ret end return false end function resetRobber( ) setElementData( bankMarker,'attack',nil ) setElementData( bankColshape,'attackShape',nil ) end function setRobberDefault( ) if isTimer( timerOpenBank ) then killTimer( timerOpenBank ) end if isTimer( timer ) then killTimer( timer ) end setElementData( bankMarker,'attack',nil ) setElementData( bankColshape,'attackShape',nil ) setElementAlpha( bankMarker,255 ) setElementData( bankMarker,'protected',nil ) setElementData( bankColshape,'protectedShape',nil ) triggerClientEvent( 'onSoundRobberyStop',root ) end addEventHandler( 'onColShapeLeave',bankColshape, function( LeaveElement,dim ) if getElementType( LeaveElement ) == 'player' then if getElementData( source,'attackShape' ) == LeaveElement then outputChatBox( "`Миссия провалена вы не захватили банк!",LeaveElement,255,0,0 ) setRobberDefault( ) end end end ) addEventHandler( 'onPlayerWasted',root, function( ) if findMarker( source ) then outputChatBox( "`Миссия провалена вы не захватили банк!",source,255,0,0 ) setRobberDefault( ) end end ) addEventHandler( 'onPlayerQuit',root, function( ) if findMarker( source ) then setRobberDefault( ) end end ) addEventHandler( "onMarkerHit",bankMarker, function( hitElement, matchingDimension ) if getElementType( hitElement ) == 'player' then if not getElementData( source,'attack' ) and not getElementData( source,'protected' ) then triggerClientEvent( hitElement,'onClientRobberMenu',hitElement,source ) else outputChatBox( 'Кто-то захватывает банк ',hitElement,255,0,0 ) end end end ) addEventHandler( 'onEndRobber',root, function( marker ) setElementData( bankMarker,'protected','y' ) setElementData( bankColshape,'protectedShape','y' ) if isTimer( timerOpenBank ) then killTimer( timerOpenBank ) end timerOpenBank = setTimer( setRobberDefault,10000,1 ) -- время через которое банк можно будет снова ограбить end ) addEventHandler( 'onStartRobber',root, function( ) setElementAlpha( bankMarker, 0 ) setElementData( bankMarker,'attack',source ) setElementData( bankColshape,'attackShape',source ) setPlayerWantedLevel( source,6 ) triggerClientEvent( 'onSoundRobbery',root ) if isTimer( timer ) then killTimer( timer ) end timer = setTimer( function( player,mark ) outputChatBox( "`Вы успешно ограбили банк вы получили 100 000 $.",player,255,0,0 ) resetRobber( ) givePlayerMoney( player,100000 ) triggerClientEvent( 'onSoundRobberyStop',root ) triggerEvent( 'onEndRobber',player,mark ) end, 60000,1,source,bankMarker ) end ) Updated. Link to comment
Jokeℝ1472771893 Posted October 3, 2012 Share Posted October 3, 2012 Still don't work.Something wrong in Server.Lua 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