SA-MP Forums Archive
How to do this for all players using foreach - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to do this for all players using foreach (/showthread.php?tid=625527)



How to do this for all players using foreach - iSanchez - 02.01.2017

Hello i am using y_text and y_languages to translate my server to multiple languages but I noticed the group "ALL_PLAYERS" is not coded at the moment in YSI 4.0, so I decided to simulate this group using foreach.

Код:
 foreach(new iplayerid : Player)
{
        Text_Send(iplayerid,$USER_HAS_CONNECTED, PName(playerid), playerid, GetPlayerCountry(playerid));
}
But I need that foreach loop everytime I need to use Text_Send.

Is there any possibility to make a macro or something to prevent putting it everytime?

Like, for example: Text_SendToAll (this function is disabled in YSI 4, I don't know why )


Thank you so much


Re: How to do this for all players using foreach - oMa37 - 03.01.2017

Make a function and call it however you want but with the same parameters as Text_Send (except the playerid parameter no need for it), and use the loop inside it.
I can't really show you an example code because i'm using the phone.


Respuesta: Re: How to do this for all players using foreach - iSanchez - 03.01.2017

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Make a function and call it however you want but with the same parameters as Text_Send (except the playerid parameter no need for it), and use the loop inside it.
I can't really show you an example code because i'm using the phone.
Hm the problem is, what I don't understand the parameters for Text_Send because it is defined as a macro under YSI_Players/y_text.inc

Код:
#define UNDO_MOVE|||
#define DO_MOVE|||%0``` %0DO_MOVE|||

#define Text_Send(%0,%1) PSF:_Text_Send(%0,DO_TEXT_SET:%1 UNDO_MOVE|||)



Re: How to do this for all players using foreach - SickAttack - 03.01.2017

Quote:
Originally Posted by oMa37
Посмотреть сообщение
Make a function and call it however you want but with the same parameters as Text_Send (except the playerid parameter no need for it), and use the loop inside it.
I can't really show you an example code because i'm using the phone.
He will have to do something similar to those SendFormattedMessage functions, which involves assembly.

It is possible to create a macro btw.


Re: How to do this for all players using foreach - oMa37 - 03.01.2017

Never used y_text actually, But i think it would work if you copy the function from the old YSI library and paste it in the one you got.

EDIT:

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
He will have to do something similar to those SendFormattedMessage functions, which involves assembly.

It is possible to create a macro btw.
Ah so it send a formatted message, didn't know ...