Bean666 Posted April 26, 2016 Share Posted April 26, 2016 (edited) SOLVED Edited April 26, 2016 by Guest Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 (edited) BUMP "Edited script" not in a GUI anymore REMOVED Edited April 26, 2016 by Guest Link to comment
Tekken Posted April 26, 2016 Share Posted April 26, 2016 Make it server-side, creating markers client side is not the best idea in this case. local marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 100); addEventHandler("onMarkerHit", marker, function(player) if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Resistances") then outputChatBox("Wait 30 seconds in the marker, don't leave it! or the mission will fail!", player, 255, 0, 0); outputChatBox("Military Broadcast: Attention Soldiers! The military vault is under attack!", getRootElement(), 0, 200, 0); timer = setTimer(givePlayerMoney, 5000, 1, player, 5000); end end); Also if you want to delete that timer from other function you must not make it a local variable, if not is better to delete the variable. Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 (edited) it worked. but now is it possible if the player dies it kills the timer? Edited April 26, 2016 by Guest Link to comment
Tekken Posted April 26, 2016 Share Posted April 26, 2016 (edited) Yes it is, just make a table. Also add onPlayerQuit and onMarkerLeave local timeTable = {}; addEventHandler("onMarkerHit", marker, function(player) if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Resistances") then outputChatBox("Wait 30 seconds in the marker, don't leave it! or the mission will fail!", player, 255, 0, 0); outputChatBox("Military Broadcast: Attention Soldiers! The military vault is under attack!", getRootElement(), 0, 200, 0); timeTable[player] = setTimer(givePlayerMoney, 5000, 1, player, 5000); end end); addEventHandler("onPlayerWasted", getRootElement(), function() if isTimer(timeTable[source]) then killTimer(timeTable[source]); timeTable[source] = nil; end end); addEventHandler("onPlayerQuit", getRootElement(), function() if isTimer(timeTable[source]) then killTimer(timeTable[source]); timeTable[source] = nil; end end); addEventHandler("onMarkerLeave", marker, function(player) if isTimer(timeTable[player]) then killTimer(timeTable[player]); timeTable[player] = nil; end end); Edited May 1, 2016 by Guest Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 getting these 2 errors. Link to comment
Tekken Posted April 26, 2016 Share Posted April 26, 2016 local marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 100); forgot to add this line Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 yep ik. realized before u comment haha Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 now for the last one. is it possible that there'll be a cooldown? like if you finished the robbery. the marker will disappear for a minute and then it will comeback? thanks. Link to comment
Tekken Posted April 26, 2016 Share Posted April 26, 2016 Everything is possible. local marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 100); local timeTable = {}; addEventHandler("onMarkerHit", marker, function(player) if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Resistances") then outputChatBox("Wait 30 seconds in the marker, don't leave it! or the mission will fail!", player, 255, 0, 0); outputChatBox("Military Broadcast: Attention Soldiers! The military vault is under attack!", getRootElement(), 0, 200, 0); timeTable[player] = setTimer(function() givePlayerMoney(player, 5000); destroyElement(marker); setTimer(function() marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 100); end, 60000, 1); end, 5000, 1); end end); function checkTimer(element) if isTimer(timeTable[element]) then killTimer(timeTable[element]); timeTable[element] = nil; end end addEventHandler("onPlayerWasted", getRootElement(), function() checkTimer(source); end); addEventHandler("onPlayerQuit", getRootElement(), function() checkTimer(source); end); addEventHandler("onMarkerLeave", marker, function(player) checkTimer(player); end); Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 EDIT: Btw if the marker is recreated, when i come back the function doesnt work anymore, it doesnt give me money now. btw is it also possible its not working if you're in a vehicle?"srry for asking too much >.<" Link to comment
Tekken Posted April 26, 2016 Share Posted April 26, 2016 EDIT:Btw if the marker is recreated, when i come back the function doesnt work anymore, it doesnt give me money now. btw is it also possible its not working if you're in a vehicle? Yes it is possible to work with car as well, but will need some changes if i'm not mistaken. And did you tested if it work's when enter the recreated marker? Cause I am not sure if it's a question or a fact. Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 (edited) yep i tested when the marker was recreated. it didnt work. the money doesn't give it to me the message dont pop up, btw i ment, if im in a vehicle i enter the marker, function works. i want it disabled. i only want the function working with people on foot. Edited April 26, 2016 by Guest Link to comment
Tekken Posted April 26, 2016 Share Posted April 26, 2016 Not sure but test again: local marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 100); local timeTable = {}; addEventHandler("onMarkerHit", marker, function(player) if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Resistances") then outputChatBox("Wait 30 seconds in the marker, don't leave it! or the mission will fail!", player, 255, 0, 0); outputChatBox("Military Broadcast: Attention Soldiers! The military vault is under attack!", getRootElement(), 0, 200, 0); timeTable[player] = setTimer(function() givePlayerMoney(player, 5000); destroyElement(marker); marker = nil; setTimer(function() marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 100); end, 60000, 1); end, 5000, 1); end end); function checkTimer(element) if isTimer(timeTable[element]) then killTimer(timeTable[element]); timeTable[element] = nil; end end addEventHandler("onPlayerWasted", getRootElement(), function() checkTimer(source); end); addEventHandler("onPlayerQuit", getRootElement(), function() checkTimer(source); end); addEventHandler("onMarkerLeave", marker, function(player) checkTimer(player); end); Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 EDIT:Btw if the marker is recreated, when i come back the function doesnt work anymore, it doesnt give me money now. btw is it also possible its not working if you're in a vehicle? Yes it is possible to work with car as well, but will need some changes if i'm not mistaken. i ment, if i enter the marker with a vehicle, the function works. i dont want it working with a vehicle i only want the function working if the player is on foot. and btw still not working even marker recreated. Link to comment
Tekken Posted April 26, 2016 Share Posted April 26, 2016 Now should work. local timeTable = {}; local marker = createMarker(-2405, -597.53125, 131.9, "cylinder", 7.0, 0, 180, 0, 100); local isMarerHidden = false; addEventHandler("onMarkerHit", marker, function(player) if isPedInVehicle(player) then return; end if (isMarerHidden == true) then return; end if (getPlayerTeam(player) and getTeamName(getPlayerTeam(player)) == "Resistances") then outputChatBox("Wait 30 seconds in the marker, don't leave it! or the mission will fail!", player, 255, 0, 0); outputChatBox("Military Broadcast: Attention Soldiers! The military vault is under attack!", getRootElement(), 0, 200, 0); timeTable[player] = setTimer(function() givePlayerMoney(player, 5000); setElementAlpha(marker, 0); isMarerHidden = true; setTimer(function() setElementAlpha(marker, 100); isMarerHidden = false; end, 60000, 1); end, 5000, 1); end end); function checkTimer(element) if isTimer(timeTable[element]) then killTimer(timeTable[element]); timeTable[element] = nil; end end addEventHandler("onPlayerWasted", getRootElement(), function() checkTimer(source); end); addEventHandler("onPlayerQuit", getRootElement(), function() checkTimer(source); end); addEventHandler("onMarkerLeave", marker, function(player) checkTimer(player); end); Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 Thank you. i owe you alot Link to comment
Tekken Posted April 26, 2016 Share Posted April 26, 2016 Thank you. i owe you alot You're welcome. Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 last question: if a player completes the mission the marker will disappear right? will it disappear for other players that haven't completed the mission yet? Link to comment
Tekken Posted April 26, 2016 Share Posted April 26, 2016 last question:if a player completes the mission the marker will disappear right? will it disappear for other players that haven't completed the mission yet? and: everything works but. when i come into the marker. leave , come again. leave. come again. and when ill stay. the mission completes but it doubles, triples, etcs the money. What do you mean? Explain better I do not understand. Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 no its fixed now. but what i mean is if im done with the marker. i get the money. marker disappears. but when another player is still in progress and still dont have the money. will the marker disappear for him too? Link to comment
Tekken Posted April 26, 2016 Share Posted April 26, 2016 no its fixed now. but what i mean is if im done with the marker. i get the money. marker disappears. but when another player is still in progress and still dont have the money. will the marker disappear for him too? Yes it will, but the timer will continue and he will get the money, you must do a check for that and kill all timers, after first player get the money. Link to comment
Bean666 Posted April 26, 2016 Author Share Posted April 26, 2016 how do i kill all the timers after first player gets the money? 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