CMD:setname(playerid, params[]) { new giveplayerid, newname[24], string[128], sendername[MAX_PLAYER_NAME], giveplayer[MAX_PLAYER_NAME]; if(PlayerInfo[playerid][pAdmin] >= 3) { if(!sscanf(params, "us[24]", giveplayerid, newname)) { if(IsPlayerConnected(giveplayerid)) { if(giveplayerid != INVALID_PLAYER_ID) { new string6[50]; format(string6, sizeof(string6), "Accounts/%s.ini", newname); format(string, sizeof(string), "Accounts/%s.ini", newname); if(fexist(string)) { SendClientMessage(playerid, COLOR_GRAD1, "That name is already registered."); return 1; } strmid(sendername, PlayerName(playerid), 0, MAX_PLAYER_NAME); strmid(giveplayer, PlayerName(giveplayerid), 0, MAX_PLAYER_NAME); SetPlayerName(giveplayerid, newname); format(string, sizeof(string), "Accounts/%s.ini", giveplayer); SaveAccounts(); if(INI_Exist(string6)) { fremove(string); } else { SendClientMessage(playerid, COLOR_NICERED, "There was a problem with saving the account! Reverting changes..."); SetPlayerName(giveplayerid, giveplayer); if(INI_Exist(string6)) // For some odd reason it exists? { fremove(string6); SaveAccounts(); } } format(string, sizeof(string), " You have renamed %s to %s !", giveplayer, newname); SendInfoMessage(playerid,2,"0", string); format(string, sizeof(string), "Your name has been changed from %s to %s.", giveplayer, newname); SendInfoMessage(giveplayerid,2,"0", string); } } } else { SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setname [playerid/PartOfName] [name]"); } } else { SendClientMessage(playerid, COLOR_GRAD1, " {FF0000}ERROR{FFFFFF}: you do not have sufficient permissions!"); } return 1; }
CMD:setname(playerid, params[]) { new string[128], giveplayerid, name[MAX_PLAYER_NAME]; new playername[MAX_PLAYER_NAME]; if(sscanf(params, "us[24]", giveplayerid, name)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setname [playerid/partofname] [newname]"); if(IsPlayerConnected(giveplayerid)) { if(PlayerInfo[playerid][pAdmin] >= 4) { if(!INI_Exist(name)) { new newname[MAX_PLAYER_NAME + 10]; GetPlayerName(giveplayerid, playername, sizeof(playername)); format(newname, sizeof(newname), "Accounts/%s.ini", name); format(string, sizeof(string), "{FF1B31}[Administration]{FFFFFF} %s has renamed %s to %s.", PlayerName(playerid), playername, newname); ABroadCast(COLOR_GRAD1,string,2); format(newname, sizeof(newname), "Accounts/%s.ini", playername); fremove(newname); if(INI_Exist(playername)) // If it doesn't get removed, blank the file with write io and check its length when a player attempts to authenticate (it'll be 0) { new File: BlankTheFile = fopen(newname, io_write); SendClientMessage(playerid, COLOR_GRAD2, "The old account couldn't be removed completely (it's been blanked for future use)."); fclose(BlankTheFile); } } else { SendClientMessage(playerid, COLOR_WHITE, "This name is already registered."); } } else { SendClientMessage(playerid, COLOR_GRAD2, "You're not authorised to use this command."); } } else { SendClientMessage(playerid, COLOR_GRAD2, "No Such Player"); } return 1; }
format(string6, sizeof(string6), "Accounts/%s.ini", newname);
format(string6, sizeof(string6), "Accounts/%s.ini", PlayerName(playerid));
if(INI_Exist(string6))
{
fremove(string);
}
if(INI_Exist(string6))
{
fremove(string6);
}
CMD:setname(playerid, params[]) { new string[128], giveplayerid, name[MAX_PLAYER_NAME]; new playername[MAX_PLAYER_NAME]; if(sscanf(params, "us[24]", giveplayerid, name)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setname [playerid/partofname] [newname]"); if(IsPlayerConnected(giveplayerid)) { if(PlayerInfo[playerid][pAdmin] >= 4) { if(!DoesAccountExist(name)) { new newname[MAX_PLAYER_NAME + 10]; GetPlayerName(giveplayerid, playername, sizeof(playername)); format(newname, sizeof(newname), "Accounts/%s.ini", name); format(string, sizeof(string), " Your name has been changed from %s to %s.", GetPlayerNameEx(giveplayerid), name); SendClientMessage(giveplayerid,COLOR_YELLOW,string); format(string, sizeof(string), " You have changed %s's name to %s.", GetPlayerNameEx(giveplayerid), name); SendClientMessage(playerid,COLOR_YELLOW,string); SetPlayerName(giveplayerid, name); format(newname, sizeof(newname), "Accounts/%s.ini", playername); fremove(newname); if(DoesAccountExist(playername)) // If it doesn't get removed, blank the file with write io and check its length when a player attempts to authenticate (it'll be 0) { new File: BlankTheFile = fopen(newname, io_write); SendClientMessage(playerid, COLOR_GRAD2, "The old account couldn't be removed completely (it's been blanked for future use)."); fclose(BlankTheFile); } } else { SendClientMessage(playerid, COLOR_WHITE, "This name is already registered."); } } else { SendClientMessage(playerid, COLOR_GRAD2, "You're not authorised to use this command."); } } else { SendClientMessage(playerid, COLOR_GRAD2, "No Such Player"); } return 1; }
stock DoesAccountExist(account_name[]) { new sz_accStr[MAX_PLAYER_NAME + 12], File:f_Handle; format(sz_accStr, sizeof(sz_accStr), "Accounts/%s.ini", account_name); if(fexist(sz_accStr)) { if(!(f_Handle = fopen(sz_accStr, io_read))) { return 1; } if(flength(f_Handle) > 0) { fclose(f_Handle); return 1; } fclose(f_Handle); } return 0; }
CMD:setname(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GRAD1, " {FF0000}ERROR{FFFFFF}: you do not have sufficient permissions!");
new giveplayerid, newname[MAX_PLAYER_NAME];
if(!sscanf(params, "us[24]", giveplayerid, newname)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setname [playerid/PartOfName] [name]");
if(!IsPlayerConnected(giveplayerid) || giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GRAD1, " {FF0000}ERROR{FFFFFF}: player is not connected!");
//Perhaps check if the player is logged in and/or registered here?
new string[90];
format(string, sizeof(string), "Accounts/%s.ini", newname);
if(fexist(string)) return SendClientMessage(playerid, COLOR_GRAD1, "That name is already registered.");
new string2[40];
format(string2, sizeof(string2), "Accounts/%s.ini", PlayerName(giveplayerid));
if(INI_Exist(string2)) fremove(string2);
else SendClientMessage(playerid, COLOR_NICERED, "There was a problem with saving the account! Reverting changes...");
//SaveAccounts(); //Wrong. You should be transferring the player's current stats from his current account to the new account
SetPlayerName(giveplayerid, newname);
format(string, sizeof(string), " You have renamed %s to %s !", PlayerName(giveplayerid), newname);
SendInfoMessage(playerid, 2, "0", string);
format(string, sizeof(string), "Your name has been changed from %s to %s.", PlayerName(giveplayerid), newname);
SendInfoMessage(giveplayerid, 2, "0", string);
return 1;
}
pawn Код:
|