CMD:setname(playerid, params[]) {
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!");
new string[84], newname[20], id;
new originalname[MAX_PLAYER_NAME];
GetPlayerName(id, originalname, sizeof(originalname));
new plrIP[16];
if(sscanf(params, "uc[20]", id, newname)) return SendClientMessage(playerid, COLOR_RED, "[USAGE] - /setname [ID] [NewName]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "[NOTE] - Player not found!");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(id));
INI_WriteInt(File,"Admin",PlayerInfo[id][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[id][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[id][pDeaths]);
INI_WriteInt(File,"Score",GetPlayerScore(id));
INI_WriteInt(File,"Password",PlayerInfo[id][pPass]);
INI_WriteInt(File,"Muted",PlayerInfo[id][pMuted]);
INI_WriteInt(File,"VIP",PlayerInfo[id][pVIP]);
//INI_WriteInt(File,"Reward",PlayerInfo[playerid][pReward]);
INI_WriteInt(File,"IP",GetPlayerIp(id, plrIP, sizeof(plrIP)));
INI_WriteInt(File,"TimesWarned",PlayerInfo[id][pTimesWarned]);
INI_WriteInt(File,"TimeKicked",PlayerInfo[id][pTimesKicked]);
INI_WriteInt(File,"LoggedIn",PlayerInfo[id][pLoggedIn]);
INI_WriteInt(File,"Banned",PlayerInfo[id][pBanned]);
INI_WriteInt(File,"OriginalName",originalname); //error line
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
new receiver[MAX_PLAYER_NAME];
GetPlayerName(id, receiver, sizeof(receiver));
format(string, sizeof(string), "[ADMIN] - %s[%d] has used SETNAME on %s[%d]", pName, playerid, receiver, id);
SendMessageToAdmins(string);
format(string, sizeof(string), "* Your name has been changed to %s by %s[%d]", newname, pName, playerid);
SendClientMessage(id, COLOR_YELLOW, string);
format(string, sizeof(string), "%s", newname);
SetPlayerName(id, string);
return 1;
}
INI_WriteInt(File,"OriginalName",originalname); //error line
INI_WriteInt(File,"OriginalName",PlayerInfo[id][pOriginalName]);
\test2.pwn(2237) : error 006: must be assigned to an array
PlayerInfo[id][pOriginalName] = originalname;
PlayerInfo[id][pOriginalName] = GetPlayerName(id, originalname, sizeof(originalname));
INI_WriteString(File,"OriginalName",originalname);
pawn Код:
|
CMD:setname(playerid, params[]) {
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_RED, "[ADMIN] - You're not a high enough level to use this command!");
new string[84], newname[20], id;
new originalname[MAX_PLAYER_NAME];
PlayerInfo[id][pOriginalName] = GetPlayerName(id, originalname, sizeof(originalname)); //Should i edit something here?
new plrIP[16];
if(sscanf(params, "us[20]", id, newname)) return SendClientMessage(playerid, COLOR_RED, "[USAGE] - /setname [ID] [NewName]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "[NOTE] - Player not found!");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(id));
INI_WriteInt(File,"Admin",PlayerInfo[id][pAdmin]);
INI_WriteInt(File,"Kills",PlayerInfo[id][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[id][pDeaths]);
INI_WriteInt(File,"Score",GetPlayerScore(id));
INI_WriteInt(File,"Password",PlayerInfo[id][pPass]);
INI_WriteInt(File,"Muted",PlayerInfo[id][pMuted]);
INI_WriteInt(File,"VIP",PlayerInfo[id][pVIP]);
//INI_WriteInt(File,"Reward",PlayerInfo[playerid][pReward]);
INI_WriteInt(File,"IP",GetPlayerIp(id, plrIP, sizeof(plrIP)));
INI_WriteInt(File,"TimesWarned",PlayerInfo[id][pTimesWarned]);
INI_WriteInt(File,"TimeKicked",PlayerInfo[id][pTimesKicked]);
INI_WriteInt(File,"LoggedIn",PlayerInfo[id][pLoggedIn]);
INI_WriteInt(File,"Banned",PlayerInfo[id][pBanned]);
INI_WriteInt(File,"OriginalName",PlayerInfo[id][pOriginalName]);
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
new receiver[MAX_PLAYER_NAME];
GetPlayerName(id, receiver, sizeof(receiver));
format(string, sizeof(string), "[ADMIN] - %s[%d] has used SETNAME on %s[%d]", pName, playerid, receiver, id);
SendMessageToAdmins(string);
format(string, sizeof(string), "* Your name has been changed to %s by %s[%d]", newname, pName, playerid);
SendClientMessage(id, COLOR_YELLOW, string);
format(string, sizeof(string), "%s", newname);
SetPlayerName(id, string);
return 1;
}
PlayerInfo[id][pOriginalName] = GetPlayerName(id, originalname, sizeof(originalname));
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
strcpy(PlayerInfo[id][pOriginalName], originalname, MAX_PLAYER_NAME);
GetPlayerName returns the lenght of the player's name. This is not how we copy a string to another string.
pawn Код:
pawn Код:
|