server:unknown Error When There is an Command. -
This is happening to all of my commands. Why?
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(register, 8, cmdtext);
dcmd(login, 5, cmdtext);
dcmd(logout, 6, cmdtext);
dcmd(password, 8, cmdtext);
return 0;
}
dcmd_register(playerid, params[])
{
if(gPlayerInfo[playerid][PLAYER_REGGED] == 1)
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You have already registered!");
else if(!params[0])
return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /register [password]");
else if(strlen(params) < gSettings[PASS_MIN] || strlen(params) > gSettings[PASS_MAX])
{
new string[128];
format(string, sizeof(string), "ERROR: Password must be between %d and $d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
else
{
new password = num_hash(params);
gPlayerInfo[playerid][PLAYER_PASS] = password;
gPlayerInfo[playerid][PLAYER_REGGED] = 1;
gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
new string[128]; format(string, sizeof(string), "You have successfully registered your account with the password \'%s\'. You have been automatically logged in.", params);
return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
}
}
dcmd_login(playerid, params[])
{
if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 1)
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-in.");
else if(!params[0])
return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /login [password]");
else
{
new password = num_hash(params);
if(gPlayerInfo[playerid][PLAYER_PASS] == password)
{
gPlayerInfo[playerid][PLAYER_LOGGED] = 1;
GetPlayerIp(playerid, gPlayerInfo[playerid][PLAYER_IP], 16);
return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged in to your account.");
}
else
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
}
}
dcmd_logout(playerid, params[])
{
#pragma unused params
if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register.");
else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You are already logged-out.");
else
{
gPlayerInfo[playerid][PLAYER_LOGGED] = 0;
return SendClientMessage(playerid, COLOUR_LIGHTBLUE, "You have successfully logged out of your account.");
}
}
dcmd_password(playerid, params[])
{
if(gPlayerInfo[playerid][PLAYER_REGGED] != 1)
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must register first to do that! Use /register [password] to register and login.");
else if(gPlayerInfo[playerid][PLAYER_LOGGED] == 0)
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: You must be logged-in to do that! Use /login [password] to login.");
else
{
new tmp[256],
tmp2[256],
index;
tmp = strtok(params, index);
if(!strlen(tmp))
return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
tmp2 = strtok(params, index);
if(!strlen(tmp2))
return SendClientMessage(playerid, COLOUR_ORANGE, "USAGE: /password [password] [new password]");
new oldpassword = num_hash(tmp), newpassword = num_hash(tmp2);
if(gPlayerInfo[playerid][PLAYER_PASS] == oldpassword)
{
if(oldpassword == newpassword)
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Your old password can not be the same as your new password.");
else if(strlen(tmp2) < gSettings[PASS_MIN] || strlen(tmp2) > gSettings[PASS_MAX])
{
new string[100]; format(string, sizeof(string), "ERROR: Your new password must be between %d and %d characters long!", gSettings[PASS_MIN], gSettings[PASS_MAX]);
return SendClientMessage(playerid, COLOUR_ORANGE, string);
}
gPlayerInfo[playerid][PLAYER_PASS] = newpassword;
new string[128]; format(string, sizeof(string), "You have successfully changed your password from \'%s\' to \'%s\'.", tmp, tmp2);
return SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
}
else
return SendClientMessage(playerid, COLOUR_ORANGE, "ERROR: Incorrect password.");
}
}
Re: server:unknown Error When There is an Command. -
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(register, 8, cmdtext);
dcmd(login, 5, cmdtext);
dcmd(logout, 6, cmdtext);
dcmd(password, 8, cmdtext);
return 1;
}
Re: server:unknown Error When There is an Command. -