strlen crash
#1

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;
}
Reply
#2

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;
}
Reply
#3

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

Someone write few suggestions..
Reply
#5

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;
}
Reply
#6

I'm using plugin.
Reply
#7

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


Forum Jump:


Users browsing this thread: 1 Guest(s)