if(sscanf(params, "d", pass)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /changeadminpin [Pin code]");
if(strlen(pass) < 4 || strlen(pass) > 4) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: The pincode must be 4 digits.");
C:\Users\fabio\Desktop\International Roleplay\gamemodes\I-RP.pwn(2306) : error 035: argument type mismatch (argument 1) C:\Users\fabio\Desktop\International Roleplay\gamemodes\I-RP.pwn(2328) : error 035: argument type mismatch (argument 1) Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 2 Errors.
Evening,
I want to check if the pincode an administrator selected is 4 digits long. I tried to do that this way. PHP код:
Код:
C:\Users\fabio\Desktop\International Roleplay\gamemodes\I-RP.pwn(2306) : error 035: argument type mismatch (argument 1) C:\Users\fabio\Desktop\International Roleplay\gamemodes\I-RP.pwn(2328) : error 035: argument type mismatch (argument 1) Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 2 Errors. |
if(strlen(params) != 4) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: The pincode must be 4 digits.");
if(sscanf(params, "d", pass)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /changeadminpin [Pin code]");
CMD:changeadminpin(playerid, params[])
{
new pass[4], string[128];
if(PlayerInfo[playerid][pAdmin] >= 1)
{
if(sscanf(params, "s[4]", pass)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /changeadminpin [Pin code]");
if(strlen(pass) != 4) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: The pincode must be 4 digits.");
sscanf(pass, "i", PlayerInfo[playerid][pSecKey]);
format(string, sizeof(string), "{FFFFFF}SERVER: You've successfully changed your pin code to %s.", pass);
SendClientMessage(playerid, COLOR_WHITE, string);
}
else return SendClientMessage(playerid, COLOR_GRAD2, NOTADMIN);
return 1;
}
strcpy(pass, PlayerInfo[playerid][pSecKey]);
Make sure to save the pin as a string because numbers that start with a zero will bug out.. like "0000" or "0123"..
It should be: PHP код:
And don't forget to change all instances of integer to a 4 digit string. |
Make sure to save the pin as a string because numbers that start with a zero will bug out.. like "0000" or "0123"..
It should be: PHP код:
And don't forget to change all instances of integer to a 4 digit string. |
Weird, It works perfect now but if I set someone else or mine admin pin to "0000" the "SendClientMessage" displays "0". How to solve this? |
printf("This number will have three leading zeros: %4i", 0);
//Output: "This number will have three leading zeros: 0000"
printf("These numbers will all be four digits, with leading zeros if needed: %4i, %4i, %4i", 12, 555, 045);
//Output: "These numbers will all be four digits, with leading zeros if needed: 0012, 0555, 0045"
False, it will not bug out. If you want to print the leading zero's you can easily do so.
You shouldn't use two sscanf strings for that. If you'd do it like I said it would be better. It's your code however, do as you will. Now about the leading zero's. You shouldn't store it as a string to get them. You said:The correct way to do this would be this (example): pawn Код:
|