SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 27/03/2014, 11:38 PM   #1
Carxi
Little Clucker
 
Carxi's Avatar
 
Join Date: Mar 2014
Posts: 48
Reputation: 1
Default Gettime

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
Carxi is offline   Reply With Quote
Old 27/03/2014, 11:49 PM   #2
MattTucker
Huge Clucker
 
Join Date: Oct 2013
Location: nowhere:c
Posts: 202
Reputation: 28
Default Re: Gettime

'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.
MattTucker is offline   Reply With Quote
Old 28/03/2014, 12:04 AM   #3
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,067
Reputation: 2660
Default Re: Gettime

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.
__________________
Vince is offline   Reply With Quote
Old 28/03/2014, 12:05 AM   #4
Carxi
Little Clucker
 
Carxi's Avatar
 
Join Date: Mar 2014
Posts: 48
Reputation: 1
Default Re: Gettime

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.");

    }


Carxi is offline   Reply With Quote
Old 28/03/2014, 10:58 AM   #5
Carxi
Little Clucker
 
Carxi's Avatar
 
Join Date: Mar 2014
Posts: 48
Reputation: 1
Default Re: Gettime

Boom
Carxi is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GetTime feartonyb Scripting Help 6 17/11/2013 09:45 AM
[Ajuda] Gettime Ban .ThePro Português/Portuguese 3 20/05/2013 08:28 PM
[Ajuda] GetTime Gleisson_. Português/Portuguese 5 26/04/2013 04:57 PM
[Ajuda] GetTime s4kuL Português/Portuguese 1 30/08/2012 02:43 AM
gettime bug? SomebodyAndMe Scripting Help 14 28/05/2012 07:10 PM


All times are GMT. The time now is 05:52 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.