Why does it keep saying this
#1

I have been trying to make a vip system where it lasts for like a month but everytime i set my self to level one vip log out and log back in it says your vip has run out

I am saving it fine

Please Help

pawn Код:
OnPlayerConnect(playerid)
{
            new timestamp = gettime();
    new VIPTimee =  Player[playerid][VIPTime];

    if(timestamp > VIPTimee)
    {
        SendClientMessage(playerid, WHITE, "Your VIP has expired if you wish you buy it again please visit the forums");
        Player[playerid][VipRank] = 0;
    }
    else
    {
        new timeleft = Player[playerid][VIPTime] - timestamp;
        new string[50];
        format(string, sizeof(string), "You have %i vip hours left", timeleft/3600);
        SendClientMessage(playerid, WHITE, string);
    }
}
pawn Код:
command(changeviplevel, playerid, params[])
{
    new level, id, string[128], string2[128];
    if(sscanf(params, "ud", id, level))
    {
        if(Player[playerid][AdminLevel] >= 1)
        {
            SendClientMessage(playerid, WHITE, "SYNTAX: /changeviplevel [playerid] [level]");
        }
    }
    else
    {
        if(Player[playerid][AdminLevel] >= 5)
        {
            if(level > 4 ) return SendClientMessage(playerid, RED, "Avaliable levels 1 - 4");
            if(IsPlayerConnectedEx(id))
            {
                Player[id][VipRank] = level;
                if(level == 1)
                {
                    Player[id][VIPTime] = gettime() + 2592000;
                }
                if(level == 2)
                {
                    Player[id][VIPTime] = gettime() + 2592000;
                }
                if(level == 3)
                {
                    Player[id][VIPTime] = gettime() + 7776000;
                }
                if(level == 4)
                {
                    Player[id][VIPTime] = gettime() + 31536000;
                }

                format(string, sizeof(string), "%s's VIP level has been changed to %d, by %s.", GetName(id), level, GetName(playerid));
                format(string2, sizeof(string2), "%s's VIP level has been changed to %d by %s.", GetName(id), level, GetName(playerid));
                for(new i = 0; i < MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnectedEx(i) && Player[i][VipRank] >= 1)
                    {
                        SendClientMessage(i, YELLOW, string);
                        SetPlayerColor(playerid, YELLOW);
                    }
                    if(level == 0)
                    {
                        SendClientMessage(i, YELLOW, string2);
                        SetPlayerColor(playerid, WHITE);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, WHITE, "That player is not connected or isn't logged in.");
            }
        }
    }
    return 1;
}
If you need any more code just ask

Thank You
Reply
#2

Quote:

I am saving it fine

But are you loading it right?
Reply
#3

Just add on player connect to load the viptime otherwise, it won't works.
Reply
#4

I think im saving it right...

This is my saveplayerdata

pawn Код:
public SavePlayerData(playerid)
{
    if(Player[playerid][Authenticated] == 1)
    {
        GetPlayerPos(playerid, Player[playerid][LastX], Player[playerid][LastY], Player[playerid][LastZ]);
        GetPlayerHealth(playerid, Player[playerid][LastHealth]);
        GetPlayerArmour(playerid, Player[playerid][LastArmour]);
        Player[playerid][LastInterior] = GetPlayerInterior(playerid);

        new string[128];

        if(Player[playerid][AdminDuty] >= 1)
        {
            format(string, sizeof(string), "Accounts/%s.ini", Player[playerid][NormalName]);
        }
        else
        {
            format(string, sizeof(string), "Accounts/%s.ini", GetName(playerid));
        }

        if(!fexist(string))
        {
            dini_Create(string);
        }

        dini_Set(string, "Password", Player[playerid][Password]);
        dini_IntSet(string, "AdminLevel", Player[playerid][AdminLevel]);
        dini_FloatSet(string, "LastX", Player[playerid][LastX]);
        dini_FloatSet(string, "LastY", Player[playerid][LastY]);
        dini_FloatSet(string, "LastZ", Player[playerid][LastZ]);
        dini_IntSet(string, "LastWorld", Player[playerid][LastWorld]);
        dini_IntSet(string, "LastInterior", Player[playerid][LastInterior]);

        if(Player[playerid][AdminDuty] == 0)
        {
            dini_IntSet(string, "LastSkin", GetPlayerSkin(playerid));
        }

        dini_IntSet(string, "VIPTime", Player[playerid][VIPTime]);
}
pawn Код:
public RegisterPlayer(playerid, password[])
{
    new string[128], Year, Month, Day, Minute, Hour, Second, Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(string, sizeof(string), "Accounts/%s.ini", Name);
    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);

    if(!fexist(string))
    {

         dini_IntSet(string, "VIPTime", Player[playerid][VIPTime]);
pawn Код:
public OnPlayerLoginAttempt(playerid, password[])
{
    new string[128], Year, Month, Day, Minute, Hour, Second, Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, sizeof(Name));
    format(string, sizeof(string), "Accounts/%s.ini", Name);

    if(Player[playerid][LoginAttempts] == 3)
    {
        new hour, minute, second, day, year, month;
        gettime(hour, minute, second);
        getdate(year, month, day);
        #pragma unused second
        new IP[21];
        GetPlayerIp(playerid, IP, sizeof(IP));
        format(string, sizeof(string), "%d/%d/%d | %d:%d | %s | %s | THREE FAILED PASSWORD ATTEMPTS | System", day, month, year, hour, minute, IP, Name);
        BanLog(string);
        SendClientMessage(playerid, ADMINORANGE, "You have used your three attempts.");
        Ban(playerid);
    }

    getdate(Year, Month, Day);
    gettime(Hour, Minute, Second);

    if(fexist(string))
    {
        if(strcmp(dini_Get(string, "Password"), password, false) == 0)
        {
         
             Player[playerid][VIPTime] = dini_Int(string, "VIPTime");
Thank You
Reply
#5

See, it checks if you have VIPTime left, BEFORE it actually loads your vip time.

pawn Код:
new timestamp = gettime();
    new VIPTimee =  Player[playerid][VIPTime];

    if(timestamp > VIPTimee)
    {
        SendClientMessage(playerid, WHITE, "Your VIP has expired if you wish you buy it again please visit the forums");
        Player[playerid][VipRank] = 0;
    }
    else
    {
        new timeleft = Player[playerid][VIPTime] - timestamp;
        new string[50];
        format(string, sizeof(string), "You have %i vip hours left", timeleft/3600);
        SendClientMessage(playerid, WHITE, string);
    }
Put that under
pawn Код:
if(strcmp(dini_Get(string, "Password"), password, false) == 0)
Reply
#6

Quote:
Originally Posted by JhnzRep
Посмотреть сообщение
See, it checks if you have VIPTime left, BEFORE it actually loads your vip time.

pawn Код:
new timestamp = gettime();
    new VIPTimee =  Player[playerid][VIPTime];

    if(timestamp > VIPTimee)
    {
        SendClientMessage(playerid, WHITE, "Your VIP has expired if you wish you buy it again please visit the forums");
        Player[playerid][VipRank] = 0;
    }
    else
    {
        new timeleft = Player[playerid][VIPTime] - timestamp;
        new string[50];
        format(string, sizeof(string), "You have %i vip hours left", timeleft/3600);
        SendClientMessage(playerid, WHITE, string);
    }
Put that under
pawn Код:
if(strcmp(dini_Get(string, "Password"), password, false) == 0)
Nope that did not work do you think it may have something to do with my timestamp not being right ?

Thank You
Reply
#7

OnPlayerConnect gets called as soon as the player connects, you haven't even loaded the file so how the hell VIPTime equal anything? It'll always be zero, unless you load the variable properly.
Reply
#8

So how would i do that

Thank You
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)