Wysłany: 2016-07-13, 07:19
misjane
Wiek: 29 Na forum: 5127 dni Posty: 46
Chcia?em napisa? funkcj? do konwertowania polskich znak?w w textdrawie tak ?e je?li co? napiszemy np. "?y?ka" to przekonwertuje nam s?owo na "lyzka".
Problem polega na tym, ?e albo nie nic si? nie zmienia a jak zmienie funkcje w cmd na: Kod: AddTextDrawTexT(playerid, KonwertujZnaki(msgstr);
to nic si? nie pojawia w textdrawie.
Aktualnie wygl?da to tak:
W cmd:
Kod: KonwertujZnaki(msgstr);
AddTextDrawTexT(playerid, msgstr);
funkcja do konwertowania
Kod: stock KonwertujZnaki(text[])
{
for (new i, j= strlen(text); i < j; ++i)
{
if (text[i] == '?') text[i] = 'e';
else if (text[i] == '?') text[i] = 'o';
else if (text[i] == '?') text[i] = 'a';
else if (text[i] == '?') text[i] = 's';
else if (text[i] == '?') text[i] = 'l';
else if (text[i] == '?') text[i] = 'z';
else if (text[i] == '?') text[i] = 'z';
else if (text[i] == '?') text[i] = 'c';
else if (text[i] == '?') text[i] = 'n';
else text[i] = text[i];
text[strlen(text)] = EOS;
}
return text;
}
Wysłany: 2016-07-13, 10:05
Combacior
Wiek: 29 Na forum: 5795 dni Posty: 1516
Piwa : 2161
Usu? ten kod
Kod: else text[i] = text[i];
text[strlen(text)] = EOS;
Ten return te?, tablic w PAWN nie da si? 'zwr?ci?'. Ten kod powinien by? dobry jaki masz
Kod: KonwertujZnaki(msgstr);
print(msgstr); //daj logi z tego
AddTextDrawTexT(playerid, msgstr);
Jak nie zadzia?a, to zapodaj logi z tej funkcji print i poka? funkcj? AddTextDrawTexT. Tutaj funkcja ze skryptu uDM
Kod: deletePolish(string[])
{
for(new x, j = strlen(string); x != j; x++)
{
switch(string[x])
{
case '?': string[x] = 'l';
case '?', '?': string[x] = 'z';
case '?': string[x] = 'c';
case '?': string[x] = 'n';
case '?': string[x] = 'e';
case '?': string[x] = 'o';
case '?': string[x] = 'a';
case '?': string[x] = 's';
case '?': string[x] = 'L';
case '?', '?': string[x] = 'Z';
case '?': string[x] = 'C';
case '?': string[x] = 'N';
case '?': string[x] = 'E';
case '?': string[x] = 'O';
case '?': string[x] = 'A';
case '?': string[x] = 'S';
}
}
}
Wysłany: 2016-07-13, 15:15
misjane
Wiek: 29 Na forum: 5127 dni Posty: 46
Niestety nie dzia?a a printf w konsoli:
Kod: KonwertujZnaki(msgstr);
printf(" ›› |LOG| %s",msgstr);
AddTextDrawTexT(playerid, msgstr);
Pokazuje wyraz z polskimi znakami tak jakby w og?le nie dzia?a?a funkcja a gdy zrobie:
Kod: printf(" ›› |LOG| %s",KonwertujZnaki(msgstr));
to warning 209: function "KonwertujZnaki" should return a value przy kompilacji dlatego tez by? u mnie return text;
Ta co poda?es deletePolish te? pokazuje to samo.
AddTextDrawTexT:
Kod: stock AddTextDrawTexT(playerid, msgstr[])
{
new f=0;
for(new i=5; i<PW_MAX_LINES; i++)
{
if(!strlen(PrivMessageText[i]) || PrivMessageText[i][0] == ' ')
{
format(PrivMessageText[i], 128, "%s ~w~: %s", PlayerName(playerid), msgstr);
TextDrawSetString(PrivMessageTD[i], PrivMessageText[i]);
f=1;
return 1;
}
}
if(!f)
{
for(new i=5; i<PW_MAX_LINES; i++)
{
if(i == 8)
{
format(PrivMessageText[i], 128, "%s ~w~: %s", PlayerName(playerid), msgstr);
TextDrawSetString(PrivMessageTD[i], PrivMessageText[i]);
return 1;
}
if(strlen(PrivMessageText[i]) && PrivMessageText[i][0] != ' ')
{
format(PrivMessageText[i], 128, PrivMessageText[i+1]);
TextDrawSetString(PrivMessageTD[i], PrivMessageText[i]);
}
}
}
return 0;
}
Wysłany: 2016-07-14, 10:56
Combacior
Wiek: 29 Na forum: 5795 dni Posty: 1516
Piwa : 2161
Czy ja da?em kod taki
Kod: printf(" ›› |LOG| %s",KonwertujZnaki(msgstr));
Czy taki
Kod:
Chyba jest r??nica, co? Dziwne, ?e u mnie taki kod dzia?a
Kod: public OnGameModeInit()
{
new gString[32] = "?y?ka";
deletePolish(gString);
return print(gString);
}
deletePolish(string[])
{
for(new x, j = strlen(string); x != j; x++)
{
switch(string[x])
{
case '?': string[x] = 'l';
case '?', '?': string[x] = 'z';
case '?': string[x] = 'c';
case '?': string[x] = 'n';
case '?': string[x] = 'e';
case '?': string[x] = 'o';
case '?': string[x] = 'a';
case '?': string[x] = 's';
case '?': string[x] = 'L';
case '?', '?': string[x] = 'Z';
case '?': string[x] = 'C';
case '?': string[x] = 'N';
case '?': string[x] = 'E';
case '?': string[x] = 'O';
case '?': string[x] = 'A';
case '?': string[x] = 'S';
}
}
}
Wysłany: 2016-07-14, 12:32
misjane
Wiek: 29 Na forum: 5127 dni Posty: 46
Nawet nie pomy?la?em ?e zwr?cisz na to uwag? ale
Kod:
i
Kod:
wy?wietlaj? to samo.
Ale ?eby nie by?o to prosz?: Logi za pomoc? print(msgstr);
A tutaj efekt w grze:
Twoja funkcja deletePolish robi to samo.
Tylko teraz zastanawiam si? ?e mo?e to przez to ?e u ciebie element do przekonwertowania wygl?da tak: (znajduje si? w OnGameModeInit
Kod: public OnGameModeInit()
{
new gString[32] = "?y?ka";
deletePolish(gString);
return print(gString);
}
a u mnie jest to element komendy dla gracza w zcmd:
Kod: CMD:pm(playerid,cmdtext[])
{
new graczID, msgstr[128];
if(sscanf(cmdtext,"us[128]",graczID, msgstr))
{
SendClientMessage(playerid, COLOR_WHITE, "›› |Info| U?yj /pm [ID] [tekst]");
return 1;
}else if(graczID == INVALID_PLAYER_ID){
SendClientMessage(playerid, COLOR_RED, "›› |Info| Gracz o podanym ID nie jest zalogowany.");
return 1;
}else if(playerid == graczID){
SendClientMessage(playerid, COLOR_RED, "›› |Info| Nie mo?esz pisa? do siebie.");
return 1;
}else{
KonwertujZnaki(msgstr);
print(msgstr);
AddTextDrawTexT(playerid, msgstr);
}
return 1;
}
Wysłany: 2016-07-14, 12:48
Combacior
Wiek: 29 Na forum: 5795 dni Posty: 1516
Piwa : 2161
Miejsce nie ma ?adnego znaczenia.
Wysłany: 2016-07-14, 12:50
misjane
Wiek: 29 Na forum: 5127 dni Posty: 46
Wiec w czym mo?e by? problem? Jest tak jakby w og?le tej funkcji tam nie by?o.
Wysłany: 2016-07-15, 03:21
IgrexolonO
Wiek: 34 Na forum: 6809 dni Posty: 1386
Piwa : 1062
Kod: #include <a_samp>
public OnFilterScriptInit()
{
new _char[] = "???????棳?񌜏???";
printf("Przed: %s", _char);
deletePolish(_char);
printf("Po: %s", _char);
}
deletePolish(string[])
{
for(new x, j = strlen(string); x != j; x++)
{
new bool:validated = true, switchValue = (j-1!=x) ? (string[x] | string[x + 1] << 8) : (string[x]);
switch(switchValue)
{
case 33988: string[x] = 0x41;
case 34244: string[x] = 0x61;
case 39108, 0x15c: string[x] = 0x45;
case 39364, 0x15d: string[x] = 0x65;
case 37827: string[x] = 0x4f;
case 46019, 0x176: string[x] = 0x6f;
case 34500: string[x] = 0x43;
case 34756: string[x] = 0x63;
case 33221: string[x] = 0x4c;
case 33477: string[x] = 0x6c;
case 33733: string[x] = 0x4e;
case 33989: string[x] = 0x6e;
case 39621: string[x] = 0x53;
case 39877: string[x] = 0x73;
case 47557, 48069: string[x] = 0x5a;
case 47813, 48325: string[x] = 0x7a;
default: { validated = false; }
}
if(validated)
{
j-=1;
for(new g=x;g!=j;g++)
string[g + 1] = string[g + 2];
string[j] = 0x0;
}
}
}
Wysłany: 2016-07-15, 07:28
misjane
Wiek: 29 Na forum: 5127 dni Posty: 46
Nie dzia?a
Kod: CMD:test(playerid, params[])
{
//fck(playerid);
new _char[] = "???????棳?񌜏???";
printf("Przed: %s", _char);
deletePolish(_char);
printf("Po: %s", _char);
return 1;
}
Kod: [07:26] [connection] incoming connection: 127.0.0.1:56601 id: 1
[07:26] [join] InTeRn has joined the server (1:127.0.0.1)
[07:27] Przed: ?????棳?񌜏???
[07:27] Po: ?????棳?񌜏???
[07:27] *** Audio Plugin: InTeRn (ID: 1) has connected
Wysłany: 2016-07-15, 11:25
IgrexolonO
Wiek: 34 Na forum: 6809 dni Posty: 1386
Piwa : 1062
Zamie? funkcj? na t? kt?r? podes?a?em, geniuszu.
Wysłany: 2016-07-15, 12:55
misjane
Wiek: 29 Na forum: 5127 dni Posty: 46
"IgrexolonO" napisał/a :Zamie? funkcj? na t? kt?r? podes?a?em, geniuszu.
A? tak t?py nie jestem , zmieni?em. Mo?e to nie jest wina funkcji nie wiem o co chodzi ani jak to naprawi? heh :<
Dobra Ju? chyba wiem tylko nadal nie wiem czym to jest spowodowane, zrobi?em to w osobnym pliku w filterscripts i zadzia?a?o co? nie tak jest z gm'em.
Ostatnio zmieniony przez misjane 2016-07-15, 13:06, w całości zmieniany 1 raz
Wysłany: 2016-07-15, 13:05
IgrexolonO
Wiek: 34 Na forum: 6809 dni Posty: 1386
Piwa : 1062
Kod: #include <a_samp>
public OnFilterScriptInit()
{
new _char[] = "???????棳?񌜏???";
deletePolish(_char);
}
deletePolish(string[])
{
for(new x, j = strlen(string); x != j; x+=2)
{
new switchValue = (j-1!=x) ? (string[x] | string[x + 1] << 8) : (string[x]);
printf("Index: %d, Val: %d", x, switchValue);
}
}
Wrzu? ten skrypt i poka? screena co zwr?ci konsola.
Wysłany: 2016-07-15, 13:11
misjane
Wiek: 29 Na forum: 5127 dni Posty: 46
Doda?em to w filterscript i w gamemod, efekt:
Wysłany: 2016-07-15, 13:15
IgrexolonO
Wiek: 34 Na forum: 6809 dni Posty: 1386
Piwa : 1062
W takim razie jeszcze to wrzu? do gamemode'a:
Kod: #include <a_samp>
public OnFilterScriptInit()
{
new _char[] = "???????棳?񌜏???";
deletePolish(_char);
}
deletePolish(string[])
{
for(new x, j = strlen(string); x != j; x++)
{
printf("Index: %d, Val Single: %d, Val Double: %d", x, string[x], (j-1!=x) ? (string[x] | string[x + 1] << 8) : (string[x]));
}
}
I poka? co zwr?ci.
Wysłany: 2016-07-15, 13:19
misjane
Wiek: 29 Na forum: 5127 dni Posty: 46
Tagi: zmiana :: polskich :: znaków
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: