create an account.
#1

Hello. Basicly I need help to create a command so it creates an account on the server, example /createaccount name_name password.

I would appreciate it very much if someone could do this for me.

This is the dialog you get when you wanna register an account.

switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return SendClientMessage(playerid, COLOR_RED, "You aborted! Password was never changed.");
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Change your password!",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Change your password! DO NOT USE SAME AS ON LS-RP","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);

Rep to who ever helps me. Thanks.
Reply
#2

Do you use ZCMD and SSCANF ?
Reply
#3

Yeah, I do.
Reply
#4

pawn Код:
CMD:createaccount(playerid, params[])
{
    new uP, sV[34 + 1];
    if(unformat(params, "us[35]", uP, sV)) return SendClientMessage(playerid, -1, "USAGE: /createaccount [Name] [Password]");
    if(strlen(sV) < 5 || strlen(sV) > 34) return SendClientMessage(playerid, -1, "ERROR: Invalid lenghth");
   
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File, "data");
    INI_WriteInt(File, "Password", udb_hash(inputtext));
    INI_WriteInt(File, "Cash", 0);
    INI_WriteInt(File, "Admin", 0);
    INI_WriteInt(File, "Kills", 0);
    INI_WriteInt(File, "Deaths", 0);
    INI_Close(File);
   
    SendClientMessage(playerid, -1, "Account created!");
    return 1;
}
Reply
#5

I get those errors when I try compile it for some reason.

C:\Users\Lean\Desktop\MetroServer\gamemodes\Metrob yLean.pwn(550) : error 017: undefined symbol "unformat"
C:\Users\Lean\Desktop\MetroServer\gamemodes\Metrob yLean.pwn(555) : error 017: undefined symbol "inputtext"
Reply
#6

pawn Код:
CMD:createaccount(playerid, params[])
{
    new sP[MAX_PLAYER_NAME + 1], sV[34 + 1];
    if(sscanf(params, "s[MAX_PLAYER_NAME]s[35]", uP, sV)) return SendClientMessage(playerid, -1, "USAGE: /createaccount [Name] [Password]");
    if(strlen(sP) < 3 || strlen(sV) > MAX_PLAYER_NAME) return SendClientMessage(playerid, -1, "ERROR: Invalid name lenghth");
    if(strlen(sV) < 5 || strlen(sV) > 34) return SendClientMessage(playerid, -1, "ERROR: Invalid password lenghth");
   
   
    SetPlayerName(playerid, sP);
   
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File, "data");
    INI_WriteInt(File, "Password", udb_hash(sV));
    INI_WriteInt(File, "Cash", 0);
    INI_WriteInt(File, "Admin", 0);
    INI_WriteInt(File, "Kills", 0);
    INI_WriteInt(File, "Deaths", 0);
    INI_Close(File);
   
    SendClientMessage(playerid, -1, "Account created!");
    return 1;
}
Reply
#7

It still dosent work for some reason.
Reply
#8

Quote:

CMD:createaccount(playerid, params[])
{
new sP[MAX_PLAYER_NAME + 1], sV[34 + 1];
if(sscanf(params, "ss", uP, sV)) return SendClientMessage(playerid, -1, "USAGE: /createaccount [Name] [Password]");
if(strlen(sP) < 3 || strlen(sV) > MAX_PLAYER_NAME) return SendClientMessage(playerid, -1, "ERROR: Invalid name lenghth");
if(strlen(sV) < 5 || strlen(sV) > 34) return SendClientMessage(playerid, -1, "ERROR: Invalid password lenghth");


SetPlayerName(playerid, sP);

new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File, "data");
INI_WriteInt(File, "Password", udb_hash(sV));
INI_WriteInt(File, "Cash", 0);
INI_WriteInt(File, "Admin", 0);
INI_WriteInt(File, "Kills", 0);
INI_WriteInt(File, "Deaths", 0);
INI_Close(File);

SendClientMessage(playerid, -1, "Account created!");
return 1;
}

I can create accounts now but lets say I wanna create an account named Lean_Lean, I do /createaccount Lean_Lean changeme then the name im using IN GAME changes to Lean_Lean and the password also changes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)