Jump to content

SOLVED


Bean666

Recommended Posts

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

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 by Guest
Link to comment

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
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

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 by Guest
Link to comment

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
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

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
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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...