Jump to content

conteo de jugadores en una ColSphere


BorderLine

Recommended Posts

Posted

Mi pregunta es, como, o de que manera puedo hacer para hacer un conteo de cuantos jugadores hay dentro de la zona definida chatSphere. El punto es, agregar el numero al outputChatBox para saber cuantas personas leyeron el dicho mensaje.

Mi codigo

local chatRadius = 70 
  
function sendMessageToNearbyPlayers ( message, messageType ) 
    if ( messageType == 0 ) then 
        local posX, posY, posZ = getElementPosition ( source ) 
  
        local chatSphere = createColSphere ( posX, posY, posZ, chatRadius ) 
        local nearbyPlayers = getElementsWithinColShape ( chatSphere, "player" ) 
        destroyElement ( chatSphere ) 
  
         for index, nearbyPlayer in ipairs( nearbyPlayers ) do 
                local team = getPlayerTeam(source) 
                if (team) then 
                         red, green, blue = getTeamColor( team ) 
                    end    
            outputChatBox( "{Local}"..getPlayerName ( source )..": #ffffff".. message, nearbyPlayer, red, green, blue, true ) 
        end 
        cancelEvent ( ) 
    end 
end 
addEventHandler ( "onPlayerChat", getRootElement(), sendMessageToNearbyPlayers ) 

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted

algo como esto?

outputChatBox( "[Local]["..#nearbyPlayer.."]"..getPlayerName ( source )..": #ffffff".. message, nearbyPlayer, red, green, blue, true ) 

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted

no, segun lo que vi en tu script nearbyPlayer representa a 1 jugador de esa tabla, nearbyPlayers (con la S al final) es la tabla con todos por lo tanto seria #nearbyPlayers en lugar de #nearbyPlayer, quedaria asi

  
outputChatBox( "[Local]["..#nearbyPlayers.."]"..getPlayerName ( source )..": #ffffff".. message, nearbyPlayer, red, green, blue, true ) 
  

(solo cambie #nearbyPlayer por #nearbyPlayers)

Posted

ooh claro se me paso la S xD lo testeare ensegida man.. muchas gracias

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

  • Recently Browsing   0 members

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