BorderLine Posted August 13, 2012 Posted August 13, 2012 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
-Gus- Posted August 13, 2012 Posted August 13, 2012 para contar la cantidad de jugadores tendrias que usar #nearbyPlayers el "#" hace que retorne un numero representando la cantidad de elementos que hay en la tabla. Scripts made by me: Killcam : http://forum.mtasa.com/viewtopic.php?f=108&t=46385 Positionsaver(Race-DM) http://community.mtasa.com/index.php?p=resources&s=details&id=3850
BorderLine Posted August 13, 2012 Author Posted August 13, 2012 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
-Gus- Posted August 13, 2012 Posted August 13, 2012 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) Scripts made by me: Killcam : http://forum.mtasa.com/viewtopic.php?f=108&t=46385 Positionsaver(Race-DM) http://community.mtasa.com/index.php?p=resources&s=details&id=3850
BorderLine Posted August 14, 2012 Author Posted August 14, 2012 ooh claro se me paso la S 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
-Gus- Posted August 14, 2012 Posted August 14, 2012 ok de nada Scripts made by me: Killcam : http://forum.mtasa.com/viewtopic.php?f=108&t=46385 Positionsaver(Race-DM) http://community.mtasa.com/index.php?p=resources&s=details&id=3850
-Gus- Posted August 14, 2012 Posted August 14, 2012 devuelve un numero, pero los numeros tambien funcionan con outputChatBox, por ejemplo outputChatBox(1) es lo mismo que outputChatBox("1") Scripts made by me: Killcam : http://forum.mtasa.com/viewtopic.php?f=108&t=46385 Positionsaver(Race-DM) http://community.mtasa.com/index.php?p=resources&s=details&id=3850
Alexs Posted August 14, 2012 Posted August 14, 2012 text: The text string that you wish to send to the chat window. If more than 128 characters it will not be showed in chat. Developer @ MYVAL
-Gus- Posted August 14, 2012 Posted August 14, 2012 en la wiki dice eso pero a mi me funcionó también de la manera que yo dije, acabo de probarlo con esto: numero = 1234 outputChatBox("el numero es "..numero) number es un numero en lugar de un string y sin embargo el mensaje sale bien. Scripts made by me: Killcam : http://forum.mtasa.com/viewtopic.php?f=108&t=46385 Positionsaver(Race-DM) http://community.mtasa.com/index.php?p=resources&s=details&id=3850
Recommended Posts