Banning system
#1

So guys i have a pretty simple banning system although how it could be possible to save time date etc on the folder also is it right do i have any mistake?
pawn Код:
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;
    }
no errors just not to waste time
I want to save date,time etc... how it could be possible.. Thanks.
Reply
#2

Use Printf
https://sampwiki.blast.hk/wiki/Printf
And put Gettime in format
https://sampwiki.blast.hk/wiki/Gettime
Reply
#3

Quote:
Originally Posted by CroM256
Посмотреть сообщение
I see there is getdate too so it actually helps thanks!
Reply
#4

Quote:
Originally Posted by vassilis
Посмотреть сообщение
I see there is getdate too so it actually helps thanks!
If still needed:

pawn Код:
/*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*/
(You need to create Bans.txt at "scriptfiles" ..)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)