ban warn cmd
#1

How can I make that script will read how much ban warnings player has when he will connect?
For now I have this:

pawn Код:
enum PlayerData
{
    Bwarnings, // ------
};
new PlayerInfo[MAX_PLAYERS][PlayerData];
And I have command:

pawn Код:
dcmd_bwarn(playerid,params[]) { // ban warn
    if(PlayerInfo[playerid][Level] >= 2) { // admins lvl 2 or more
        new tmp[256], tmp2[256], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
        if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, red, "USAGE: /bwarn [playerid] [reason]"); // error msg
        new warned = strval(tmp), str[128]; // defines
        if(PlayerInfo[warned][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(warned) && warned != INVALID_PLAYER_ID) { // if is player connected and it's not invalid ID
            if(warned != playerid) { // you can't warn yourself
                CMDMessageToAdmins(playerid,"WARN"); // msg to admins
                PlayerInfo[warned][Bwarnings]++;
                if( PlayerInfo[warned][Bwarnings] == MAX_BWARNINGS) {
                    format(str, sizeof (str), "***Administrator \"%s\" has kicked \"%s\".  (Reason: %s) (Warning: %d/%d)***", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Warnings], MAX_WARNINGS);
                    SendClientMessageToAll(grey, str);
                    SaveToFile("KickLog",str);  Kick(warned); //
                    return PlayerInfo[warned][Bwarnings] = 0; // ban warns
                } else {
                    format(str, sizeof (str), "***Administrator \"%s\" has given \"%s\" a BAN warning.  (Reason: %s) (Warning: %d/%d)***", pName(playerid), pName(warned), params[1+strlen(tmp)], PlayerInfo[warned][Bwarnings], MAX_BWARNINGS);
                    return SendClientMessageToAll(yellow, str);
                }
            } else return SendClientMessage(playerid, red, "ERROR: You cannot warn yourself");
        } else return SendClientMessage(playerid, red, "ERROR: Player is not connected");
    } else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
So how can I make that banwarns will be saved to player? And when he will connect it will read from file and when he will disconnect they will be saved?

REP+ for every helper
Reply
#2

Uhm, Under OnPlayerConnect.

Add this:-

pawn Код:
SendClientMessage(playerid, COLOR_GREEN, "You have %d ban warnings out of %d", PlayerInfo[warned][Bwarnings], MAX_BWARNGINGS
I dont know which one will work.

pawn Код:
new string[128];
format(string,sizeof(string),"You have %d ban warnings out of %d warnings.",PlayerInfo[warned][Bwarnings], MAX_WARNINGS);
SendClientMessage(playerid, COLOR_GREEN, string);
EDIT: Damn, I thought you already have saving system, Sorry i didn't read your message it was at last

Can you show me few codes of saving? It will be under OnPlayerDisconnect.
Reply
#3

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    SeatBelt[playerid] = 0;
    Smask[playerid] = 0;
   
    TextDrawDestroy(JoinText[playerid]);
    Delete3DTextLabel(MaskIDLab[playerid]);

    new PlayerName[MAX_PLAYER_NAME], str[128];
    GetPlayerName(playerid, PlayerName, sizeof(PlayerName));

    if(ServerInfo[ConnectMessages] == 1)
    {
        for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && playerid != i)
        {
            switch (reason)
            {
                case 0: format(str, sizeof(str), "[!] %s (%d) has left West Coast Life Roleplay. (Timeout)", PlayerName, playerid);
                case 1: format(str, sizeof(str), "[!] %s (%d) has left West Coast Life Roleplay. (Leaving)", PlayerName, playerid);
                case 2: format(str, sizeof(str), "[!] %s (%d) has left West Coast Life Roleplay. (Kicked/Banned)", PlayerName, playerid);
            }
            if(PlayerInfo[i][Level] > 1) SendClientMessage(i,grey,str);
            else {
                //format(string,sizeof(string),"[!] %s (%d) has joined West Coast Life Roleplay.", PlayerName, playerid);
                //SendClientMessage(i,grey,string);
            }
        }
    }

    if(PlayerInfo[playerid][Jailed]==1){
        new file[MAX_PLAYER_NAME+10], plaName[MAX_PLAYER_NAME];
        GetPlayerName(playerid,plaName, sizeof(plaName));
        format(file, sizeof(file), "%s.jail", plaName);
        new File:jailfile = fopen(file, io_write);
        new numstr[16];
        format(numstr, sizeof(numstr), "%i", PlayerInfo[playerid][JailTime]);
        fwrite(jailfile, numstr);
        fclose(jailfile);
    }

    if(PlayerInfo[playerid][LoggedIn] == 1)
    {
        SavePlayer(playerid);
        for(new i; i < 13; i++)
        {
            GivePlayerWeapon(playerid, --pSpawnWeapon[playerid][i], --pSpawnAmmo[playerid][i]);
        }
    }
    if(udb_Exists(PlayerName2(playerid))) dUserSetINT(PlayerName2(playerid)).("LoggedIn",0);
    PlayerInfo[playerid][LoggedIn] = 0;
    PlayerInfo[playerid][Level] = 0;
    PlayerInfo[playerid][Jailed] = 0;
    PlayerInfo[playerid][Frozen] = 0;

    if(PlayerInfo[playerid][Jailed] == 1) KillTimer( JailTimer[playerid] );
    if(PlayerInfo[playerid][Frozen] == 1) KillTimer( FreezeTimer[playerid] );
    if(ServerInfo[Locked] == 1) KillTimer( LockKickTimer[playerid] );

    if(PlayerInfo[playerid][pCar] != -1) CarDeleter(PlayerInfo[playerid][pCar]);

    #if defined ENABLE_SPEC
    for(new x=0; x<MAX_PLAYERS; x++)
        if(GetPlayerState(x) == PLAYER_STATE_SPECTATING && PlayerInfo[x][SpecID] == playerid)
            AdvanceSpectate(x);
    #endif

    return 1;
}
I was working with saving system but years ago ^^
Reply
#4

Anyone please? How can I detect how much "Bwarnings" player has? I'm using dini
Reply
#5

pawn Код:
/*OnPlayerConnect*/

/*Under the dini_int, stats loading or w.e*/
format(string, sizeof(string), "* You have %d BAN warnings!", PlayerInfo[playerid][Bwarnings]);
SendClientMessage(playerid, -1, string);
Reply
#6

Okay this is for sending message but I need that line you commented I need to LOAD this from file how can I do that?
Reply
#7

Use Y_INI
Reply
#8

Quote:
Originally Posted by Kyance
Посмотреть сообщение
pawn Код:
/*OnPlayerConnect*/

/*Under the dini_int, stats loading or w.e*/
format(string, sizeof(string), "* You have %d BAN warnings!", PlayerInfo[playerid][Bwarnings]);
SendClientMessage(playerid, -1, string);
You are correct but, Here we don't have funcs to save warnings in user file, I am not good in dini.
Reply
#9

Quote:
Originally Posted by Extraordinariness
Посмотреть сообщение
Use Y_INI
It won't fix my problem, I'm using dini so I need help with dini, anyone please?
Reply
#10

Bump
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)