02.03.2015, 12:46
PHP код:
CMD:oban(playerid,params[])
{
new targetname[24];
new Name[MAX_PLAYER_NAME];
new Msg[128];
new file[100], File:PFile, str1[100] , str2[100];
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 3
if (APlayerData[playerid][PlayerLevel] >= 3)
{
if(sscanf(params, "s[24]", targetname)) return SendClientMessage(playerid, -1, "Correct Usage: /oban [Player's Name]");
else
{
// Get the name of the admin
GetPlayerName(playerid, Name, sizeof(Name));
// Construct the complete filename for this player's account
format(file, sizeof(file), PlayerFile, targetname);
// Check if the file exists
if (fexist(file))
{
PFile = fopen(file, io_append); // Open the playerfile for appending (this command only appends a new line to overwrite the bantime)
format(str1, 100, "BanTime 2147483640\r\n");// Construct the line: "BanTime <0>"
format(str2,100,"Bans 5\r\n");
fwrite(PFile, str2);
fwrite(PFile, str1); // And save it to the file
fclose(PFile); // Close the file
format(Msg, 128, "%s %s has offline-banned %s", AdminLevelName[APlayerData[playerid][PlayerLevel]], Name, targetname);
SendClientMessageToAll(0x808080FF, Msg);
}
else
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}There is no account with that playername");
}
}
}
return 1;
}
PHP код:
Data1
Data2
Ban
BanTime
Data5
Data6
Ban//This gets created again instead of overwriting the above vars
Bantime//