LEANCMD:(createacc)
{
new
sP[MAX_PLAYER_NAME + 1],
sV[34 + 1],
fString[256];
if(!(PlayerInfo[playerid][pAdmin] >= 3)) return SCM(playerid, COLOR_GREY,"You are not authorized to use this command");
if(sscanf(params, "s", sP)) return SendClientMessage(playerid, -1, "USAGE: /createacc [NAME_SURNAME]");
if(strlen(sP) < 3 || strlen(sV) > MAX_PLAYER_NAME) return SendClientMessage(playerid, -1, "ERROR: Invalid name lenghth");
new sendername[MAX_PLAYER_NAME], string[256];
GetPlayerName(playerid, sendername, sizeof(sendername));
format(fString, sizeof fString, "Users/%s.ini", sP);
new INI:File = INI_Open(fString);
INI_SetTag(File, "data");
INI_WriteInt(File,"Password",udb_hash("changeit"));
INI_WriteInt(File, "Cash", 0);
INI_WriteInt(File, "Admin", 0);
INI_WriteInt(File, "Kills", 1);
INI_WriteInt(File, "Deaths", 1);
INI_WriteInt(File, "Skin", 266);
INI_WriteInt(File, "Logs", 1);
INI_WriteInt(File, "Banned", 0);
INI_WriteInt(File, "Crim", 0);
INI_WriteInt(File, "Pw", 0);
INI_Close(File);
SendClientMessage(playerid, -1, "Account created!");
format(string,sizeof(string), "AdmWarn: Admin[%i] %s has created an account with the name: %s",PlayerInfo[playerid][pAdmin], sendername, sP);
SendAdminMessage(COLOR_YELLOW, string);
format(string,sizeof(string),"[%d-%d-%d] AdmWarn: Admin[%i] %s has created an account with the name: %s",GetDay(),GetMonth(),GetYear(),PlayerInfo[playerid][pAdmin],sendername, sP);
Log("/logs/Accounts.txt",string);
return 1;
}
I tryed with this if(sscanf(params, "s[37]", sP)) return SendClientMessage(playerid, -1, "USAGE: /createacc [NAME_SURNAME]");
but then when I do /createacc Test_Test it gives me an error |
Please post the error, because that is the correct way to declare a size for the string.
|
// MAX_PLAYER_NAME = 24 + 1 = 25 if(sscanf(params, "s[25]", sP)) return SendClientMessage(playerid, 0x00000000, "USAGE: /createacc [NAME_SURNAME]");
if(strlen(sP) < 3 || strlen(sV) > MAX_PLAYER_NAME) // sP ???
You must declare the size of the array where you will store the string!
I am not sure, but you cannot use -1 colour param. in SendClientMessage Код:
// MAX_PLAYER_NAME = 24 + 1 = 25 if(sscanf(params, "s[25]", sP)) return SendClientMessage(playerid, 0x00000000, "USAGE: /createacc [NAME_SURNAME]"); Also You copy much: Код:
if(strlen(sP) < 3 || strlen(sV) > MAX_PLAYER_NAME) // sP ??? |
new
sP[ 24 ]
;
if(sscanf(params, "s[24]", sP)) return SendClientMessage( .. );
// rest
-1 is defined as 0xFFFFFFFF.
It should be: pawn Код:
|