SA-MP Forums Archive
Setvip with expired time - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Setvip with expired time (/showthread.php?tid=507544)



Setvip with expired time - [IND]Crazy - 18.04.2014

how to make setvip with expired time ?
like /setvip [playerid] [AccountType] [Expired]
example /setvip 0 1 30days
this my script
pawn Код:
CMD:setvip(playerid,params[])
{
    if(PlayerInfo[playerid][LoggedIn] == 1)
    {
        if(PlayerInfo[playerid][Level] >= 5 || IsPlayerAdmin(playerid))
        {
            new tmp [256];
            new tmp2[256];
            new Index;
            tmp  = strtok(params,Index);
            tmp2 = strtok(params,Index);
            if(isnull(params)) return
            SendClientMessage(playerid, red, "Usage: /setvip [PlayerID] [AccountType (0-3)]") &&
            SendClientMessage(playerid, orange, "Function: Will set the Account Type of the Specific Player (0-NormalAcc,1-Silver,2-Gold,3-Premium)");

            new player1, type, playername[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME], string[128];
            player1 = strval(tmp);
            if(isnull(tmp2)) return
            SendClientMessage(playerid, red, "Usage: /setvip [PlayerID] [AccountType (0-3)]") &&
            SendClientMessage(playerid, orange, "Function: Will set the Account Type of the Specific Player (1-Silver,2-Gold,3-Premium)");
            type = strval(tmp2);

            if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
            {
                if(PlayerInfo[player1][LoggedIn] == 1)
                {
                if(type > 3)
                return SendClientMessage(playerid,red,"ERROR: Invalid Account Type!");
                if(type == PlayerInfo[player1][pVip])
                return SendClientMessage(playerid,red,"ERROR: Player is already have this Account Type!");
                CMDMessageToAdmins(playerid,"SetVip");
                GetPlayerName(player1, playername, sizeof(playername));
                GetPlayerName(playerid, adminname, sizeof(adminname));
                new year,month,day;
                new hour,minute,second;
                getdate(year, month, day);
                gettime(hour,minute,second);

                switch(type)
                {
                    case 1: AccType = "Silver";
                    case 2: AccType = "Gold";
                    case 3: AccType = "Premium";
                }
                if(type > 0)
                format(string,sizeof(string),"|- Administrator %s has set your Account Type to: %s",adminname,AccType);
                else
                format(string,sizeof(string),"|- Administrator %s has set your Account Type to: 'Normal Account!",adminname);
                SendClientMessage(player1,0x66C178AA,string);
                if(type > PlayerInfo[player1][pVip])
                GameTextForPlayer(player1,"Promoted", 2000, 3);
                else GameTextForPlayer(player1,"Demoted", 2000, 3);

                format(string,sizeof(string),"You have given %s Account Type: %s on '%d/%d/%d' at '%d:%d:%d'", playername, AccType, day, month, year, hour, minute, second);
                SendClientMessage(playerid,0x00C378AA,string);
                format(string,sizeof(string),"Administrator %s has made %s Account Type: %s",adminname, playername, AccType);
                SaveToFile("AdminLog",string);
                dUserSetINT(PlayerName2(player1)).("AccountType",(type));
                PlayerInfo[player1][pVip] = type;
                return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
                }
                else return SendClientMessage(playerid,red,"ERROR: This player is not Registred or Logged!");
            }
             else return SendClientMessage(playerid, red, "Player is not connected");
        }
        else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
    }
    else return SendClientMessage(playerid,red,"ERROR: You must be logged in to use this commands");
}
thanks before .
rep ++ helped


Re: Setvip with expired time - RenovanZ - 18.04.2014

You must learn Unix Timestamp first.
Click here to read the tutorials!