Jump to content

Needed help


manve1

Recommended Posts

I have a problem, i'm trying to make that you would need to wait till all of your team mates are in the same marker before mission ends, but i just don't get how too make it, at least could you give me example or all of the functions? :) thank you.

Link to comment
  • Other Languages Moderators
function getPlayerContInMarker(theMarker) 
     i = 0 
     for _, player in ipairs(getElementsByType("player")) do 
          if isElementWithinMarker(player, theMarker) then 
               i = i + 1 
          end 
     end 
     return i 
end 
  
addEventHandler("onMarkerHit", theMarker, 
function() 
     local playersInMarker = getPlayerContInMarker(theMarker) 
     local playersInTeam = countPlayersInTeam(getTeamFromName("> Team Name <")) 
     if (playersInMarker == playersInTeam) then 
          -- do whatever you want 
     end 
end) 

Link to comment

My function looks like this now:

function markerFinnishingIMPORTANT() 
    if getPlayerTeam( localPlayer, 'Trolls' ) then 
    local markerFinnishing = createMarker( 226, -1812, 5, "cylinder", 10, 125, 125, 0, 100 ); 
    createBlipAttachedTo( markerFinnishing, 23, 3, 255, 255, 255, 255, 0, 9999 ); 
function getPlayerCountInMarker(theMarker) 
     i = 0 
     for _, player in ipairs(getElementsByType("player")) do 
          if isElementWithinMarker(player, theMarker) then 
               i = i + 1 
          end 
     end 
     return i 
end 
        addEventHandler('onClientMarkerHit', markerFinnishing, 
        function() 
            if getPlayerTeam( localPlayer, 'Trolls' ) then 
         local playersInMarker = getPlayersInMarker(markerFinnishing) 
         local playersInTeam = countPlayersInTeam(getTeamFromName("Trolls")) 
         if (#playersInMarker == playersInTeam) then 
            outputChatBox( '#FF0000INFO: #FFFFFFWait 5 minutes before you will be taken', 255, 255, 255, true ) 
        else 
            outputChatBox( '#FF0000INFO: #FFFFFFYou need to wait for the team mates.', 255, 255, 255, true ) 
            end 
        end 
    end) 
    end 
end 

i get no error, but it doesn't output anything when i enter the marker :\

Link to comment
  • Other Languages Moderators
function getPlayerCountInMarker(theMarker) 
     i = 0 
     for _, player in ipairs(getElementsByType("player")) do 
          if isElementWithinMarker(player, theMarker) then 
               i = i + 1 
          end 
     end 
     return i 
end 
  
TrollsTeam = getTeamFromName("Trolls") 
  
function markerFinnishingIMPORTANT() 
     if getPlayerTeam(localPlayer) == TrollsTeam then 
     local markerFinnishing = createMarker(226, -1812, 5, "cylinder", 10, 125, 125, 0, 100) 
     createBlipAttachedTo(markerFinnishing, 23, 3, 255, 255, 255, 255, 0, 9999 ) 
     addEventHandler('onClientMarkerHit', markerFinnishing, 
     function(player) 
          if getPlayerTeam(player) == TrollsTeam and player == localPlayer then 
               local playersInMarker = getPlayersInMarker(markerFinnishing) 
               local playersInTeam = countPlayersInTeam(TrollsTeam) 
               if (#playersInMarker == playersInTeam) then 
                    outputChatBox('#FF0000INFO: #FFFFFFWait 5 minutes before you will be taken', 255, 255, 255, true) 
               else 
                    outputChatBox('#FF0000INFO: #FFFFFFYou need to wait for the team mates.', 255, 255, 255, true) 
               end 
          end 
     end) 
     end 
end 

Link to comment
  • Other Languages Moderators
function getPlayerCountInMarker(theMarker) 
     i = 0 
     for _, player in ipairs(getElementsByType("player")) do 
          if isElementWithinMarker(player, theMarker) then 
               i = i + 1 
          end 
     end 
     return i 
end 
  
TrollsTeam = getTeamFromName("Trolls") 
  
function markerFinnishingIMPORTANT() 
     if getPlayerTeam(localPlayer) == TrollsTeam then 
     local markerFinnishing = createMarker(226, -1812, 5, "cylinder", 10, 125, 125, 0, 100) 
     createBlipAttachedTo(markerFinnishing, 23, 3, 255, 255, 255, 255, 0, 9999 ) 
     addEventHandler('onClientMarkerHit', markerFinnishing, 
     function(player) 
          if getPlayerTeam(player) == TrollsTeam and player == localPlayer then 
               local playersInMarker = getPlayerCountInMarker(markerFinnishing) 
               local playersInTeam = countPlayersInTeam(TrollsTeam) 
               if (playersInMarker == playersInTeam) then 
                    outputChatBox('#FF0000INFO: #FFFFFFWait 5 minutes before you will be taken', 255, 255, 255, true) 
               else 
                    outputChatBox('#FF0000INFO: #FFFFFFYou need to wait for the team mates.', 255, 255, 255, true) 
               end 
          end 
     end) 
     end 
end 

Link to comment
function getPlayerContInMarker(theMarker) 
     i = 0 
     for _, player in ipairs(getElementsByType("player")) do 
          if isElementWithinMarker(player, theMarker) then 
               i = i + 1 
          end 
     end 
     return i 
end 
  
addEventHandler("onMarkerHit", theMarker, 
function() 
     local playersInMarker = getPlayerContInMarker(theMarker) 
     local playersInTeam = countPlayersInTeam(getTeamFromName("> Team Name <")) 
     if (playersInMarker == playersInTeam) then 
          -- do whatever you want 
     end 
end) 

That's not required, you can get the amount of players by using:

getElementsWithinColShape 

with:

getElementColShape 

Link to comment
addEventHandler ( "onMarkerHit", theMarker, 
    function ( ) 
        local team = getTeamFromName ( "> Team Name <" ) 
        local playersInMarker = #getPlayersByTeamInsideMarker ( theMarker, team ) 
        local playersInTeam = countPlayersInTeam ( team ) 
        if ( playersInMarker == playersInTeam ) then 
            -- do whatever you want 
        end 
    end 
) 
  
function getPlayersByTeamInsideMarker ( theMarker, theTeam ) 
    local players = { } 
    for _, player in ipairs ( getElementsWithinColShape ( getElementColShape ( theMarker ), "player" ) ) do 
        if ( getPlayerTeam ( player ) == theTeam ) then 
            table.insert ( players, player ) 
        end 
    end 
  
    return players 
end 

Should do the job.

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