CMD:setpassword(playerid, params[])
{
if(pData[playerid][Admin] >= 7)
{
new query[320], name[24], newpass[34], hash1[34],query1[320];
if(sscanf(params, "s[24]s[34]", name, newpass)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setpassword <PlayerName> <NewPassword>");
if(!AccountExists(name)) return SendClientMessage(playerid, red, "Account does not exists");
format(query1, sizeof(query1), "You have changed %s's password to %s", name, newpass);
SendClientMessage(playerid, COLOR_GREEN, query1);
new IRC[130];
format(IRC, sizeof(IRC), "1,8* Admin %s (ID: %d) changed %s's password.",GetName(playerid), playerid, name);
IRC_GroupSay(groupID, "&#ZoneX", IRC);
IRC_GroupSay(groupID, IRC_aCHANNEL, IRC);
WP_Hash(hash1, 129, newpass);
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Password` = '%s' WHERE `Username` = '%e'", hash1, name);
mysql_tquery(mysql, query);
return 1;
}
else return ShowMessage(playerid, COLOR_YELLOW, 1, 7);
}
CMD:setpassword(playerid, params[])
{
if(pData[playerid][Admin] >= 7)
{
new query[320], name[24], newpass[34], hash1[34],query1[320];
if(sscanf(params, "s[24]s[34]", name, newpass)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /setpassword <PlayerName> <NewPassword>");
if(!AccountExists(name)) return SendClientMessage(playerid, red, "Account does not exists");
format(query1, sizeof(query1), "You have changed %s's password to %s", name, newpass);
SendClientMessage(playerid, COLOR_GREEN, query1);
new IRC[130];
format(IRC, sizeof(IRC), "1,8* Admin %s (ID: %d) changed %s's password.",GetName(playerid), playerid, name);
IRC_GroupSay(groupID, "&#ZoneX", IRC);
IRC_GroupSay(groupID, IRC_aCHANNEL, IRC);
WP_Hash(hash1, 129, newpass);
mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Password` = '%s' WHERE `Username` = '%e'", hash1, name);
mysql_tquery(mysql, query);
new name2[MAX_PLAYER_NAME];
for(new targetid = 0, maxid = GetPlayerPoolSize(); targetid <= maxid; targetid++) {
if(IsPlayerConnected(targetid)) {
GetPlayerName(targetid, name2, MAX_PLAYER_NAME);
if(!strcmp(name, name2)) {
//Player is online, set his password variable to new password, example:
format(pData[playerid][Password], sizeof(Password), "%s", hash1);
break;
}
}
}
return 1;
}
else return ShowMessage(playerid, COLOR_YELLOW, 1, 7);
}
PHP код:
|
format(pData[playerid][Password], sizeof(Password), "%s", hash1); D:\samp folder\ZoneX - ZX\gamemodes\ZoneX.pwn(3058) : error 039: constant symbol has no size
Replace sizeof(Password) with the cell usage of Password, it should be easy to find if you actually know what you're doing:
Go to the enum you're storing the player variables at and look for Password[cells], take that cell number and replace it with sizeof(..) |
Or create a define MAX_PASS_SIZE and use that for any and all of your password strings.
Just rather than putting in [34] in to code, to find out later you need to change it somewhere and because you hardcoded the value rather than making something like this, you have more bugs and confusion. I'm just gonna say, are you sure the password set feature is actually working? |