How could i? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How could i? (
/showthread.php?tid=269626)
How could i? -
FireCat - 17.07.2011
pawn Код:
stock SendLangMessageToAll(const eng[],const esp[])
{
new string[250];
for(new i = 0; i < MAX_PLAYERS;i++)
{
if(GetLang(i) == 1)
{
format(string,sizeof(string),"%s",eng);
}
if(GetLang(i) == 2)
{
format(string,sizeof(string),"%s",esp);
}
SendClientMessage(i,green2,string);
}
return 1;
}
That when i do in a function or command SendLangMessageToAll("Hello","Hola");
But how could i make that so i can do SendLangMessageToAll("Hello there %s","Hola %s",GetPlayerName(playerid,pName,sizeof(pName));
Re: How could i? -
MoroDan - 17.07.2011
Quote:
Originally Posted by FireCat
pawn Код:
stock SendLangMessageToAll(const eng[],const esp[]) { new string[250]; for(new i = 0; i < MAX_PLAYERS;i++) { if(GetLang(i) == 1) { format(string,sizeof(string),"%s",eng); } if(GetLang(i) == 2) { format(string,sizeof(string),"%s",esp); } SendClientMessage(i,green2,string); } return 1; }
That when i do in a function or command SendLangMessageToAll("Hello","Hola");
But how could i make that so i can do SendLangMessageToAll("Hello there %s","Hola %s",GetPlayerName(playerid,pName,sizeof(pName));
|
Format the string and send it like parameter. E.g.:
PHP код:
format(string, sizeof(string), "Hello there %s", "FireCat");
format(string1, sizeof(string), "Hola %s", "FireCat");
SendLangMessageToAll(string, string1);
And your function can be edited a bit:
PHP код:
stock SendLangMessageToAll(const eng[], const esp[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
SendClientMessage(i, green2, (!(GetLang(i) == 2) ? (eng) : (esp)));
}
return 1;
}
Re: How could i? -
RyDeR` - 17.07.2011
pawn Код:
#if !defined SendLanguageMessage
static
__langString[128]
;
#define SendLanguageMessage(%0,%1,%2,%3,%4,%5) \
format(__langString, sizeof(__langString), (%2) ? (%3) : (%4), %5), SendClientMessage((%0), (%1), __langString)
#pragma unused __langString
#endif
Then just create a global variable (or PVar) where you assign the language. (0 for English, 1 for your language).
pawn Код:
SendLanguageMessage(playerid, color, IndexLanguageVar, "Hello there %s", "Hola %s", GetName(playerid));
Re: How could i? -
FireCat - 17.07.2011
Quote:
Originally Posted by RyDeR`
pawn Код:
#if !defined SendLanguageMessage static __langString[128] ; #define SendLanguageMessage(%0,%1,%2,%3,%4,%5) \ format(__langString, sizeof(__langString), (%2) ? (%3) : (%4), %5), SendClientMessage((%0), (%1), __langString) #pragma unused __langString #endif
Then just create a global variable (or PVar) where you assign the language. (0 for English, 1 for your language).
pawn Код:
SendLanguageMessage(playerid, color, IndexLanguageVar, "Hello there %s", "Hola %s", GetName(playerid));
|
I didn't understand that. Explain better
I really need it fast, it's crashing my server! :@