Why does my variable turn out like this..
#1

Well im making a VIP system and when you get VIP it stays there for 30 days and it disappears after a certain amount of time.. Im using unix timestamps.. ( I think ) and when it saves the time in a variable it shows like this

pawn Код:
VipExpiredTime=1343821147
And it should not ... This is what the code looks like

pawn Код:
command(changeviplevel, playerid, params[])
{
    new level, id, string[128], string2[128];
    if(sscanf(params, "ud", id, level))
    {
        if(Player[playerid][AdminLevel] >= 5)
        {
            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;
                Player[id][VipExpiredTime] = gettime() + 60;

                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(id, YELLOW);
                    }
                    if(level == 0)
                    {
                        SendClientMessage(i, YELLOW, string2);
                        SetPlayerColor(id, WHITE);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, WHITE, "That player is not connected or isn't logged in.");
            }
        }
    }
    return 1;
}
The time plus 60 seconds should no where be as big as that...

And this is when the player trys and logs in..

pawn Код:
if(gettime() > Player[playerid][VipExpiredTime] && Player[playerid][VipRank] != 0)
            {
                Player[playerid][VipExpiredTime] = 1;
            }

            if(Player[playerid][VipExpiredTime] == 1)
            {
                SendClientMessage(playerid, RED, "Your VIP has expired to by it again go to www.DBullet-Gaming.tk");
                Player[playerid][VipRank] = 0;
                Player[playerid][VipExpiredTime] = 0;
            }
Please help

Thanks
Reply
#2

Player[id][VipExpiredTime] = gettime() + 60;
because gettime by default show value as seconds
Reply
#3

Quote:
Originally Posted by Euan Hughes
Посмотреть сообщение
pawn Код:
VipExpiredTime=1343821147
The unix timestamp (always in seconds) goes from 1970, so lets calculate the years from the seconds

1343821147 / 60 ~ 22397019 minutes
22397019 / 60 ~ 373284 hours
373284 / 24 ~ 15553 days
15553 / 7 ~ 2222 weeks
2222 / 52 ~ 42,7 years

1970 + 42,7 = 2012,7 (not fully accurate)

pawn Код:
//
            if(gettime() > Player[playerid][VipExpiredTime] && Player[playerid][VipRank] != 0)
            {
                SendClientMessage(playerid, RED, "Your VIP has expired to by it again go to www.DBullet-Gaming.tk");
                Player[playerid][VipRank] = Player[playerid][VipExpiredTime] = 0;
            }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)