Jump to content
  • 0

pomoc Více řadku


Pavel Tuček

Dotaz

Popis problému:

Zdravím, rád bych se zeptal, jak jde udelat to, že například když hráč napíše do chatu neco dlouheho, aby se to rozdelilo do dvou řadku? Za odpověd velice děkuju.

 

Chyby/varování kompilátoru a při běhu:

--

 

Kód:

 

--

 

 

 

Dodatečné poznámky:

--

Link to comment
Share on other sites

2 odpovědí na tuto otázku

Recommended Posts

  • 0
  • Globální moderátor

Takto obecně do více řádků:

new str[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque arcu nunc, fringilla ut placerat vitae, accumsan eu urna. Cras id posuere eros, eu blandit leo.";
	
#define split_chars 50

for(new i = 0, j = strlen(str)/split_chars; i <= j; i++){ 
     new tmp[split_chars];
     if((strlen(str)-(i*split_chars)) > split_chars)
          strmid(tmp, str, split_chars*i, split_chars*(i+1));
     else
	  strmid(tmp,str,split_chars*i,strlen(str),sizeof(tmp));

     print(tmp);
}

Output:

Lorem ipsum dolor sit amet, consectetur adipiscin
 elit. Pellentesque arcu nunc, fringilla ut place
at vitae, accumsan eu urna. Cras id posuere eros,
 eu blandit leo.

Jestli to chceš mít na dva řádky, tak si s tím pohraj. Je to jenom o strmid (v podstatě funkce, která extrahuje znaky do jiné proměnné). Taky pak bacha na OnPlayerText s returnem

Link to comment
Share on other sites

  • 0

public OnPlayerText(playerid, text[])
{
new PlayerText[2][65], string[145];
strmid(PlayerText[0],text,0,64);
strmid(PlayerText[1],text,64,128);
if(strlen(text) > 64)
{
format(string,sizeof(string),"{%06x}%s {FFFFFF}(%d): %s", GetPlayerColor(playerid) >>> 8, Jmeno(playerid), playerid, PlayerText[0]);
SendClientMessageToAll(0xFFFFFFFF,string);
format(string,sizeof(string),"%s",PlayerText[1]);
SendClientMessageToAll(0xFFFFFFFF,string);
}
else
{
format(string,sizeof(string),"{%06x}%s {FFFFFF}(%d): %s", GetPlayerColor(playerid) >>> 8, Jmeno(playerid), playerid, text);
SendClientMessageToAll(0xFFFFFFFF,string);
}
return 0;
}
  • Líbí se mi to! (+1) 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...