manve1 Posted November 3, 2012 Share Posted November 3, 2012 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
TAPL Posted November 3, 2012 Share Posted November 3, 2012 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
manve1 Posted November 3, 2012 Author Share Posted November 3, 2012 TAPL, sorry for not mentioning, but how can i make it on client side? Link to comment
TAPL Posted November 3, 2012 Share Posted November 3, 2012 TAPL, sorry for not mentioning, but how can i make it on client side? Simple, change the event onMarkerHit to onClientMarkerHit. Link to comment
manve1 Posted November 3, 2012 Author Share Posted November 3, 2012 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
TAPL Posted November 3, 2012 Share Posted November 3, 2012 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
manve1 Posted November 3, 2012 Author Share Posted November 3, 2012 No Error, No Output Link to comment
TAPL Posted November 3, 2012 Share Posted November 3, 2012 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
AhmadQTR Posted November 3, 2012 Share Posted November 3, 2012 TAPL, i think you need to add getRootElement() near the output massage. Link to comment
TAPL Posted November 3, 2012 Share Posted November 3, 2012 TAPL, i think you need to add getRootElement() near the output massage. Read client side syntax. https://wiki.multitheftauto.com/wiki/OutputChatBox Link to comment
Castillo Posted November 3, 2012 Share Posted November 3, 2012 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
manve1 Posted November 4, 2012 Author Share Posted November 4, 2012 so how do i make that it would require all team mates in the marker before output? Link to comment
Castillo Posted November 4, 2012 Share Posted November 4, 2012 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
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