[Question] Auto black list for faction members
#1

Hello, I have made for my godfather edit server, a atuomatic black list system for the faction members. The auto black list system makes if someone ho has joined a faction and he hasnt stayed 1 week in the faction he gets black listed and he cant join any faction and he has to wait 1 week to rejoin again.
I think the system is not so well made, its based on the date and month, when someone gets /invite the server writes in his account BLDayExpire = ActualDay+6 and BLMonthExpire= ActualMonth

Here is what I did:

pawn Код:
public OnPlayerSpawn(playerid)
{
    new bldayexp = PlayerInfo[playerid][pBLDateExpire];
    new blmonthexp = PlayerInfo[playerid][pBLDateExpire2];
    new Year, Month, Day;
    getdate(Year, Month, Day);
    if(Day >= bldayexp)
    {
      if(Month >= blmonthexp)
      {
            SendClientMessage(playerid, COLOR_LIGHTRED, "** You can now quit your faction ! You can ask the leader for /uninvite or type /quitfaction **");
            PlayerInfo[playerid][pExitFaction] = 0;
        }
    }
}
pawn Код:
//----------------------------------[INVITE]------------------------------------------------
    if(strcmp(cmd, "/invite", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /invite [playerid/PartOfName]");
                return 1;
            }
            new para1;
            new ftext[20];
            para1 = ReturnUser(tmp);
            if (PlayerInfo[playerid][pLeader] >= 1)
            {
              if(IsPlayerConnected(para1))
              {
                if(para1 != INVALID_PLAYER_ID)
                {
                      if (gTeam[para1]==TEAM_GREEN && PlayerInfo[para1][pMember] == 0 && PlayerInfo[para1][pFMember] == 255)
                      {
                        if(PlayerInfo[para1][pJob] > 0)
                        {
                          SendClientMessage(playerid, COLOR_GREY, "  Can't invite him, player has a Job !");
                          return 1;
                        }
                        if(PlayerInfo[para1][pExitFaction] >= 1)
                        {
                          SendClientMessage(playerid, COLOR_GREY, "  Can't invite him, the player didnt stay 1 week in a faction, and now he is Black Listed");
                          return 1;
                        }
                        if(PlayerInfo[playerid][pLeader] == 1) { PlayerInfo[para1][pTeam] = 2; gTeam[para1] = 2; ftext = "Police Force"; ChosenSkin[para1] = 280; SetPlayerSkin(para1, 280); }
                        else if(PlayerInfo[playerid][pLeader] == 2) { PlayerInfo[para1][pTeam] = 2; gTeam[para1] = 2; ftext = "FBI/ATF"; ChosenSkin[para1] = 286; SetPlayerSkin(para1, 286); }
                        else if(PlayerInfo[playerid][pLeader] == 3) { PlayerInfo[para1][pTeam] = 3; gTeam[para1] = 3; ftext = "LS Council"; ChosenSkin[para1] = 17; SetPlayerSkin(para1, 17); }
                        else if(PlayerInfo[playerid][pLeader] == 4) { PlayerInfo[para1][pTeam] = 1; gTeam[para1] = 1; ftext = "Sevile Boulevard"; ChosenSkin[para1] = 105; SetPlayerSkin(para1, 105); }
                        else if(PlayerInfo[playerid][pLeader] == 5) { PlayerInfo[para1][pTeam] = 5; gTeam[para1] = 5; ftext = "Corleone"; ChosenSkin[para1] = 258; SetPlayerSkin(para1, 120); }
                        else if(PlayerInfo[playerid][pLeader] == 6) { PlayerInfo[para1][pTeam] = 5; gTeam[para1] = 5; ftext = "Yakuza"; ChosenSkin[para1] = 123; SetPlayerSkin(para1, 123); }
                        else if(PlayerInfo[playerid][pLeader] == 8) { PlayerInfo[para1][pTeam] = 10; gTeam[para1] = 12; ftext = "Cobras MC"; ChosenSkin[para1] = 181; SetPlayerSkin(para1, 181); }
                        else if(PlayerInfo[playerid][pLeader] == 9) { PlayerInfo[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "CNN Studio"; ChosenSkin[para1] = 148; SetPlayerSkin(para1, 148); }
                        else if(PlayerInfo[playerid][pLeader] == 7) { PlayerInfo[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "Glen Park OG's"; ChosenSkin[para1] = 102; SetPlayerSkin(para1, 102); }
                        else if(PlayerInfo[playerid][pLeader] == 10) { PlayerInfo[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "Kings of Streets"; ChosenSkin[para1] = 206; SetPlayerSkin(para1, 206); }
                        else if(PlayerInfo[playerid][pLeader] == 11) { PlayerInfo[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "The Triads"; ChosenSkin[para1] = 122; SetPlayerSkin(para1, 122); }
                        else if(PlayerInfo[playerid][pLeader] == 12) { PlayerInfo[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "Mara Salvatrucha 13"; ChosenSkin[para1] = 116; SetPlayerSkin(para1, 116); }
                        else if(PlayerInfo[playerid][pLeader] == 13) { PlayerInfo[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "Russian Bratva"; ChosenSkin[para1] = 111; SetPlayerSkin(para1, 111); }
                            else if(PlayerInfo[playerid][pLeader] == 15) { PlayerInfo[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "Romanian Mafia"; ChosenSkin[para1] = 60; SetPlayerSkin(para1, 60); }
                        else if(PlayerInfo[playerid][pLeader] == 17) { PlayerInfo[para1][pTeam] = 12; gTeam[para1] = 12; ftext = "The Agency"; ChosenSkin[para1] = 185; SetPlayerSkin(para1, 185); }
                        else { return 1; }
                        new Year, Month, Day;
                        getdate(Year, Month, Day);
                            GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                            GetPlayerName(playerid, sendername, sizeof(sendername));
                            PlayerInfo[para1][pMember] = PlayerInfo[playerid][pLeader];
                            PlayerInfo[para1][pRank] = 1;
                            PlayerInfo[para1][pBLDateExpire] = Day+6;
                        PlayerInfo[para1][pBLDateExpire2] = Month;
                        PlayerInfo[para1][pExitFaction] = 0;
                            printf("AdmCmd: %s has invited %s to join %s.", sendername, giveplayer, ftext);
                            format(string, sizeof(string), "  You have Joined the %s, you were invited by Leader %s", ftext, sendername);
                            SendClientMessage(para1, COLOR_LIGHTBLUE, string);
                            format(string, sizeof(string), "  You have Invited %s to join the %s.", giveplayer,ftext);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                            SetPlayerInterior(para1,0);
                            new rand = random(sizeof(gInviteSpawns));
                            SetPlayerPos(para1, gInviteSpawns[rand][0], gInviteSpawns[rand][1], gInviteSpawns[rand][2]); // Warp the player
                            SetPlayerFacingAngle(para1, gInviteSpawns[rand][3]);
                            SetPlayerCameraPos(para1,gInviteSpawns[rand][0] + 3, gInviteSpawns[rand][1], gInviteSpawns[rand][2]);
                            SetPlayerCameraLookAt(para1,gInviteSpawns[rand][0], gInviteSpawns[rand][1], gInviteSpawns[rand][2]);
                            TogglePlayerControllable(para1, 0);
                          SelectChar[para1] = 255;
                          SelectCharID[para1] = PlayerInfo[para1][pMember];
                          SelectCharPlace[para1] = 1;
                          PlayerInfo[para1][pModel] = ChosenSkin[para1];
                        PlayerInfo[para1][pChar] = ChosenSkin[para1];
                          SendClientMessage(para1, COLOR_LIGHTRED, "* Use 'next' to Select the char you want to use.");
                          SendClientMessage(para1, COLOR_LIGHTRED, "* If you've found the Char you want to use, type 'done'.");
                        }
                        else
                        {
                          SendClientMessage(playerid, COLOR_GREY, " That player is currently Wanted / a Different Team / or already a Family Member.");
                          return 1;
                        }
                    }
                }//not connected
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command(leaders only)!");
            }
        }
        return 1;
    }
pawn Код:
//----------------------------------[UNINVITE]------------------------------------------------
    if(strcmp(cmd, "/uninvite", true) == 0)
    {
      if(IsPlayerConnected(playerid))
      {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /uninvite [playerid/PartOfName]");
                return 1;
            }
            new para1;
            para1 = ReturnUser(tmp);
            if(PlayerInfo[playerid][pLeader] == 1 && PlayerInfo[para1][pMember] != 1)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 2 && PlayerInfo[para1][pMember] != 2)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 3 && PlayerInfo[para1][pMember] != 3)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 4 && PlayerInfo[para1][pMember] != 4)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 5 && PlayerInfo[para1][pMember] != 5)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 6 && PlayerInfo[para1][pMember] != 6)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 7 && PlayerInfo[para1][pMember] != 7)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 8 && PlayerInfo[para1][pMember] != 8)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 9 && PlayerInfo[para1][pMember] != 9)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 10 && PlayerInfo[para1][pMember] != 10)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 11 && PlayerInfo[para1][pMember] != 11)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 12 && PlayerInfo[para1][pMember] != 12)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if(PlayerInfo[playerid][pLeader] == 17 && PlayerInfo[para1][pMember] != 17)
            {
              SendClientMessage(playerid, COLOR_GRAD2, "Access denied!");
                return 1;
            }
            if (PlayerInfo[playerid][pLeader] >= 1)
            {
              if(IsPlayerConnected(para1))
              {
                if(para1 != INVALID_PLAYER_ID)
                {
                      if (PlayerInfo[para1][pMember] > 0)
                      {
                        if(PlayerInfo[para1][pExitFaction] == 0)
                        {
                          new Year, Month, Day;
                            getdate(Year, Month, Day);
                          SendClientMessage(playerid, COLOR_GREY, "  That player didnt stay 1 week in the faction, therfore he is now Black Listed !");
                          PlayerInfo[para1][pExitFaction] = 1;
                          PlayerInfo[para1][pBLDateExpire] = Day+7;
                            PlayerInfo[para1][pBLDateExpire2] = Month;
                          return 1;
                        }
                            GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                            GetPlayerName(playerid, sendername, sizeof(sendername));
                            printf("AdmCmd: %s has uninvited %s.", sendername, giveplayer);
                            format(string, sizeof(string), "* You have been kicked from a Family / Police Force, by Leader %s.", sendername);
                            SendClientMessage(para1, COLOR_LIGHTBLUE, string);
                            SendClientMessage(para1, COLOR_LIGHTBLUE, "* You are now a Civilian again.");
                    gTeam[para1] = 3;
                            PlayerInfo[para1][pTeam] = 3;
                            PlayerInfo[para1][pMember] = 0;
                            PlayerInfo[para1][pRank] = 0;
                            PlayerInfo[para1][pChar] = 0;
                            new rand = random(sizeof(CIV));
                            SetSpawnInfo(para1, gTeam[para1], CIV[rand],0.0,0.0,0.0,0,0,0,0,0,0,0);
                            PlayerInfo[para1][pModel] = CIV[rand];
                            MedicBill[para1] = 0;
                            SpawnPlayer(para1);
                            format(string, sizeof(string), "  You have kicked %s from his Family / Police Force.", giveplayer);
                            SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
                        }
                    }
                }//not connected
            }
            else
            {
                SendClientMessage(playerid, COLOR_GRAD1, "  you are not authorized to use that command(Leaders only)!");
            }
        }
        return 1;
    }
Does this system work properly? I ask the scripters that realy know if this works as I want it to work ?
If i did not do something wright please post here and tell me where I made a mistake
Reply
#2

You'll have problems if you are near the end of a month. Imagine it's 28 of november, the membership would expire the 24 of november.
To check if a player's membership is expired, you should first check if the saved month and the current one are the same. If they are, then check the day. If they aren't, you'll have to figure out a way to know how many days passed since the start of the month and the day from the previous from which the player joined.
Also remember that in new year, the old month may be 12, and the new one may be 1, which is smaller than 12.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)