SA-MP Forums Archive
strlen crash - 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: strlen crash (/showthread.php?tid=178166)



strlen crash - BuLLeT[LTU] - 20.09.2010

When i type gangname very long, server crashes. What's wrong?

pawn Код:
if(dialogid == 20){
if(response){
new gangname[20];
if(sscanf(inputtext, "s",gangname)){
ShowPlayerDialog(playerid,20,DIALOG_STYLE_INPUT,"Бveskite gaujos pavadinimа. PATARIMAS: vietoje tarpш naudokite _ юenklа","Pavadinimas:","Gerai","Atрaukti");
return 1;
}
if (strlen(inputtext) < 5 || strlen(inputtext) > 20){
SendClientMessage(playerid,COLOR_GRAD1,"*[INFO]: Gaujos pavadinimа negali saudaryti maюiau kaip 5 ir daugiau kaip 20 simboliш.");
ShowPlayerDialog(playerid,20,DIALOG_STYLE_INPUT,"Бveskite gaujos pavadinimа. PATARIMAS: vietoje tarpш naudokite _ юenklа","Pavadinimas:","Gerai","Atрaukti");
return 1;
}
Thanks for help. Working script:
pawn Код:
if(dialogid == 20){
if(response){
new gangname[256];
if(sscanf(inputtext, "s[257]",gangname)){
ShowPlayerDialog(playerid,20,DIALOG_STYLE_INPUT,"Бveskite gaujos pavadinimа. PATARIMAS: vietoje tarpш naudokite _ юenklа","Pavadinimas:","Gerai","Atрaukti");
return 1;
}
if (strlen(gangname) < 5 || strlen(gangname) > 20){
SendClientMessage(playerid,COLOR_GRAD1,"*[INFO]: Gaujos pavadinimа negali saudaryti maюiau kaip 5 ir daugiau kaip 20 simboliш.");
ShowPlayerDialog(playerid,20,DIALOG_STYLE_INPUT,"Бveskite gaujos pavadinimа. PATARIMAS: vietoje tarpш naudokite _ юenklа","Pavadinimas:","Gerai","Atрaukti");
return 1;
}



Re: strlen crash - willsuckformoney - 20.09.2010

pawn Код:
if(dialogid == 20){
if(response){
new gangname[20];
if(sscanf(inputtext, "s",gangname)){
ShowPlayerDialog(playerid,20,DIALOG_STYLE_INPUT,"Бveskite gaujos pavadinimа. PATARIMAS: vietoje tarpш naudokite _ юenklа","Pavadinimas:","Gerai","Atрaukti");
return 1;
}
if (strlen(inputtext) < 5 || strlen(inputtext) > 20){
SendClientMessage(playerid,COLOR_GRAD1,"*[INFO]: Gaujos pavadinimа negali saudaryti maюiau kaip 5 ir daugiau kaip 20 simboliш.");
ShowPlayerDialog(playerid,20,DIALOG_STYLE_INPUT,"Бveskite gaujos pavadinimа. PATARIMAS: vietoje tarpш naudokite _ юenklа","Pavadinimas:","Gerai","Atрaukti");
}
return 1;
}
First try that if that don't work try this...

pawn Код:
if(dialogid == 20){
if(response){
new gangname[20];
if(sscanf(inputtext, "s",gangname)){
ShowPlayerDialog(playerid,20,DIALOG_STYLE_INPUT,"Бveskite gaujos pavadinimа. PATARIMAS: vietoje tarpш naudokite _ юenklа","Pavadinimas:","Gerai","Atрaukti");
return 1;
}
SendClientMessage(playerid,COLOR_GRAD1,"*[INFO]: Gaujos pavadinimа negali saudaryti maюiau kaip 5 ir daugiau kaip 20 simboliш.");
ShowPlayerDialog(playerid,20,DIALOG_STYLE_INPUT,"Бveskite gaujos pavadinimа. PATARIMAS: vietoje tarpш naudokite _ юenklа","Pavadinimas:","Gerai","Atрaukti");
return 1;
}



Re: strlen crash - BuLLeT[LTU] - 20.09.2010

It's bug with strlen not with code.. Maybe my strlen is old? What can i use else instead of it?


Re: strlen crash - BuLLeT[LTU] - 21.09.2010

Someone write few suggestions..


Re: strlen crash - Sascha - 21.09.2010

try this:

Код:
if(dialogid == 20){
if(response){
new gangname[20];
if(sscanf(inputtext, "s",gangname)){
ShowPlayerDialog(playerid,20,DIALOG_STYLE_INPUT,"Бveskite gaujos pavadinimа. PATARIMAS: vietoje tarpш naudokite _ юenklа","Pavadinimas:","Gerai","Atрaukti");
return 1;
}
if (strlen(inputtext) < 5 && strlen(inputtext) > 20){
SendClientMessage(playerid,COLOR_GRAD1,"*[INFO]: Gaujos pavadinimа negali saudaryti maюiau kaip 5 ir daugiau kaip 20 simboliш.");
ShowPlayerDialog(playerid,20,DIALOG_STYLE_INPUT,"Бveskite gaujos pavadinimа. PATARIMAS: vietoje tarpш naudokite _ юenklа","Pavadinimas:","Gerai","Atрaukti");
}
return 1;
}



Re: strlen crash - BuLLeT[LTU] - 21.09.2010

I'm using plugin.


Re: strlen crash - BuLLeT[LTU] - 21.09.2010

Thank you ****** for a hint.