PHP код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <dini>
#pragma tabsize 0
#define COLOR_WHITE (0xFFFFFFAA)
#define COLOR_GREY (0xAFAFAFAA)
enum pInfo {
pAdmin
};
new PlayerInfo[MAX_PLAYERS][pInfo];
new bool: aDuty[MAX_PLAYERS];
PlayerName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}
ReturnIP(playerid)
{
static
ip[16];
GetPlayerIp(playerid, ip, sizeof(ip));
return ip;
}
CMD:aduty(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] < 1)
return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if (!aDuty[playerid]) {
SendClientMessage(playerid, -1, "You are now in adminduty!");
aDuty[playerid] = true;
} else {
SendClientMessage(playerid, -1, "You are no longer adminduty!");
aDuty[playerid] = false;
}
return 1;
}
CMD:aname(playerid, params[])
{
new string[128], file[32], text[MAX_PLAYER_NAME];
if (PlayerInfo[playerid][pAdmin] < 1)
return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if (sscanf(params, "s[24]", text))
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /aname [name]");
if (aDuty[playerid])
return SendClientMessage(playerid, COLOR_GREY, "You must be off duty to change your admin name.");
// Start of detecting space in name
new end, temp[32], temp2[32];
end = strfind(text, " ",true);
if(end != -1)
{
strmid(temp, text, 0, end);
format(temp, sizeof(temp), "%s_", temp);
strdel(text, 0, end);
strmid(temp2, text, 1, strlen(text));
format(text, 24, "");
strcat(text, temp, sizeof(temp));
strcat(text, temp2, sizeof(temp2));
}
// End of detecting space in name
format(file, sizeof(file), "users/%s.ini", text);
if(dini_Exists(file))
{
format(file, sizeof(file), "users/%s.ini", PlayerName(playerid));
if(strlen(dini_Get(file, "AdminName")) && strcmp(dini_Get(file, "AdminName"), text))
{
SendClientMessage(playerid, COLOR_GREY, "Name is already in use.");
return 1;
}
}
format(string, sizeof(string), " You have changed your admin name to: {FF6347}%s", text);
SendClientMessage(playerid, COLOR_WHITE, string);
format(file, sizeof(file), "users/%s.ini", PlayerName(playerid));
format(file, sizeof(file), "users/%s.ini", dini_Get(file, "AdminName"));
if(dini_Exists(file)) dini_Remove(file);
format(file, sizeof(file), "users/%s.ini", PlayerName(playerid));
dini_Set(file, "AdminName", text);
format(file, sizeof(file), "users/%s.ini",dini_Get(file, "AdminName"));
dini_Create(file);
dini_Set(file, "OldName", PlayerName(playerid));
dini_IntSet(file, "Admin", PlayerInfo[playerid][pAdmin]);
dini_IntSet(file, "AdminAccount", 1);
dini_IntSet(file, "Age", 25);
dini_IntSet(file, "Gender", 1);
dini_IntSet(file, "Tutorial", 1);
dini_Set(file, "IP", ReturnIP(playerid));
return 1;
}