Problem WITH STRCMP - 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)
+--- Thread: Problem WITH STRCMP (
/showthread.php?tid=663739)
Problem WITH STRCMP -
jullyus - 10.02.2019
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.
Re: Problem WITH STRCMP -
ComDuck - 10.02.2019
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.