CMD:ban(playerid,params[])
{
new id,reason[70],string[120],gname[MAX_PLAYER_NAME];
if(pinfo[playerid][Admin] < 4) return 0;
if(pinfo[playerid][Admin] < pinfo[id][Admin]) return SendClientMessage(playerid,COLOR_RED," (ERROR): You can't ban a higher level admin!");
if(sscanf(params,"us[70]",id,reason)) return SendClientMessage(playerid, COLOR_RED," (ERROR): /ban [playerid] [reason]");
if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, " (ERROR): The id/username you have typed is invalid!");
GetPlayerName(id,gname,sizeof(gname));
format(string,sizeof(string),"CCNR SYSTEM: %s has been banned from the server. Reason: %s",gname,reason);
SendClientMessageToAll(COLOR_PINK,string);
pinfo[id][Banned] = 1;
Ban(id);
return 1;
}
Use Printf
https://sampwiki.blast.hk/wiki/Printf And put Gettime in format https://sampwiki.blast.hk/wiki/Gettime |
/*Code here*/
new sender[MAX_PLAYER_NAME], receiver[MAX_PLAYER_NAME];
GetPlayerName(playerid, sender, sizeof(sender));
GetPlayerName(id, receiver, sizeof(receiver));
new File:Bans = fopen("Bans.txt", io_append);
if(Bans)
{
new y, m, d, h, mi, s;
getdate(y,m,d);
gettime(h,mi,s);
format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s banned by %s for %s\r\n", d, m, y, h, mi, s, sender, receiver, reason);
fwrite(Bans, string);
fclose(Bans);
printf("- Successfully added ban to Bans.txt - %s banned by %s due to %s at %i/%i/%i", sender, receiver, reason, d, m, y);
}
else
{
printf("- Couldn't write ban at Bans.txt - %s banned by %s due to %s at %i/%i/%i", sender, receiver, reason, d, m, y);
}
/*Rest of code here*/