Problem WITH STRCMP
#1

Code:
if(dialogid==PINLS){
if(response == 1){
if(inveh==true){
new str[4+1] = "1234";
new string[4+1];
new ltr = strlen(inputtext);
format(string,sizeof(string),"%s",inputtext);
if(!strcmp(str,string,true)){
SendClientMessage(playerid,COLOR_NORMAL_PLAYER,"Verificando...");
SendClientMessage(playerid,COLOR_WHITE,"Aceptado, puedes aterrizar");
KillTimer(timer[playerid]);
GangZoneStopFlashForPlayer(playerid, aerols[0]);
invasor=false;
cont1=true;
pinpuesto=true;
return 1;
}else{
SendClientMessage(playerid,COLOR_WHITE,"MAL INGRESO DE ID");
}


if(ltr > 5|| ltr < 5){
SendClientMessage(playerid, COLOR_WHITE, "Tu pin debe tener 4 caracteres exactos");
}
}
}
}
їHow i do a restriction that just permit me, put 4 characters?, and if i put more or less to 4 on Dialog it give me a message.
Reply
#2

Use strlen to get the string length of the input, and create a condition to check it against the number 4. If it exceeds 4 characters, then show your error dialog. Else, proceed with your main function. Do note that strlen will also count spaces, punctuation and other symbols in its calculation.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)