Gettime
#1

I don't understand this code, anyone can help me?
PHP Code:
if((gettime() - DrugInfo[i][dTime]) > (3600 48)) 
PHP Code:
if(DrugInfo[slot][dTime] < 604800
Reply
#2

'if(DrugInfo[slot][dTime] < 604800) ' if the druginfo of 'slot' (mostly it's a loop of all the drug stuff I think? you can try posting the whole code if possible) is bigger than 604800 (milliseconds normally) = 10 minutes, so if the drug time of that 'slot' is 10 minutes it does something. (not sure that's pretty weird doe)

For the other one, I don't actually get the '3600*48' part.

Hope this helps.
Reply
#3

gettime returns the number of seconds (not milliseconds) that have elapsed since the epoch on 1/1/1970. The first code checks if 48 hours have passed (3600 seconds in an hour, times 4.

The second piece of code doesn't make much sense if it's from the same script. Would need more context for that.
Reply
#4

Quote:
Originally Posted by Vince
View Post
gettime returns the number of seconds (not milliseconds) that have elapsed since the epoch on 1/1/1970. The first code checks if 48 hours have passed (3600 seconds in an hour, times 4.

The second piece of code doesn't make much sense if it's from the same script. Would need more context for that.
PHP Code:
stock GatherDrug(playerid,slot)
{
    if(
DrugInfo[slot][dTime] < 604800)
    {
        switch(
DrugInfo[slot][dType])
        {
            case 
DRUG_WEED:
            {
                new 
amount = (random(9) + 1);
                if(
CanHaveItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_WEED,amount))
                {
                    new 
rec GiveItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_WEED,amount);
                    if(
rec)
                    {
                        
DrugInfo[slot][dTime] = 0;
                        
DrugInfo[slot][dType] = 0;
                        
F_DestroyObject(DrugInfo[slot][dObject]);
                        
ApplyAnimation(playerid"BOMBER""BOM_Plant"4.000000);
                    }
                }
                else
                {
                    
SendClientMessage(playerid,COLOR_LIGHTRED,"You cannot carry anything else!");
                }
            }
            case 
DRUG_HEROIN:
            {
                new 
amount = (random(4) + 1);
                if(
CanHaveItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_HEROIN,amount))
                {
                    new 
rec GiveItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_HEROIN,amount);
                    if(
rec)
                    {
                        
DrugInfo[slot][dTime] = 0;
                        
DrugInfo[slot][dType] = 0;
                        
F_DestroyObject(DrugInfo[slot][dObject]);
                        
ApplyAnimation(playerid"BOMBER""BOM_Plant"4.000000);
                    }
                }
                else
                {
                    
SendClientMessage(playerid,COLOR_LIGHTRED,"You cannot carry anything else!");
                }
            }
            case 
DRUG_COKE:
            {
                new 
amount = (random(4) + 1);
                if(
CanHaveItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_COKE,amount))
                {
                    new 
rec GiveItem(INVENTORY_TYPE_PLAYER,playerid,INVENTORY_COKE,amount);
                    if(
rec)
                    {
                        
DrugInfo[slot][dTime] = 0;
                        
DrugInfo[slot][dType] = 0;
                        
F_DestroyObject(DrugInfo[slot][dObject]);
                        
ApplyAnimation(playerid"BOMBER""BOM_Plant"4.000000);
                    }
                }
                else
                {
                    
SendClientMessage(playerid,COLOR_LIGHTRED,"You cannot carry anything else!");
                }
            }
        }
    }
    else
    {
        
DrugInfo[slot][dTime] = 0;
        
DrugInfo[slot][dType] = 0;
        
F_DestroyObject(DrugInfo[slot][dObject]);
        
SendClientMessage(playerid,COLOR_YELLOW2,"Questa pianta и vecchia e inutilizzabile.");
        
SendEmote(playerid,"inizia a rimuovere la pianta da terra.");
    }

Reply
#5

Boom
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)