PDA

View Full Version : /changepassword problem


Face9000
29/12/2011, 06:28 PM
So,i have this command to change the password of the player if he cant access.

if(strcmp(cmd,"/changepassword",true) == 0)
{
if (adminlevel[playerid] >= 4)
{
new id = -1;
id = strval(strtok(cmdtext,idx));
new password[100];
password = strtok(cmdtext,idx);
if strval(password) == 0)return SendClientMessage(playerid,~0,"Usage: /changepassword [playerid] [new password]");
new playername[24];GetPlayerName(id,playername,40);
format(playername, 40, "%s",playername);
dini_IntSet(udb_encode(playername), "password", udb_hash(password));
SendClientMessage(playerid,~0,"Password successeful changed!");
return 1;
}


There is a problem: It gives me alot of general errors while compiling,what's wrong?

P.S The command is writed for changing the password of an OFFLINE player.

Norck
29/12/2011, 06:31 PM
Seems that you have missed a closing bracket, check this out:

if(strcmp(cmd,"/changepassword",true) == 0)
{
if (adminlevel[playerid] >= 4)
{
new id = -1;
id = strval(strtok(cmdtext,idx));
new password[100];
password = strtok(cmdtext,idx);
if strval(password) == 0)return SendClientMessage(playerid,~0,"Usage: /changepassword [playerid] [new password]");
new playername[24];GetPlayerName(id,playername,40);
format(playername, 40, "%s",playername);
dini_IntSet(udb_encode(playername), "password", udb_hash(password));
SendClientMessage(playerid,~0,"Password successeful changed!");
}
return 1;
}

Face9000
29/12/2011, 06:43 PM
Now error is at this line:

if strval(password) == 0)return SendClientMessage(playerid,~0,"Usage: /changepassword [playerid] [new password]");

error 001: expected token: "*then", but found ")"
error 029: invalid expression, assumed zero
error 001: expected token: ";", but found "return"

Norck
29/12/2011, 06:57 PM
Try now:

if (strval(password) == 0)return SendClientMessage(playerid,~0,"Usage: /changepassword [playerid] [new password]");

Face9000
29/12/2011, 07:05 PM
Thanks,is working now!