SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 04/01/2019, 11:44 AM   #1
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default MySQL Timer question

So I have a Marijuana Database, for my marijuana plants
I have set up a timer every 3 minutes to check the plants after loading on initial server start-up

and after the 3 minutes it gives 1 more gram to the plant if its not reached its peak of 28 grams

my questions are...
is this quite hard on the server?
would it be quite a heavy load?
im just automatically assuming its not.... but I also was thinking I should be saving the MySQL Database as well
upon adding data to the Marijuana plants, ive seen people save/load etc at 5 minutes but 3 minutes, so just checking especially if theres going to be like players planting a lot of marijuana plants, like between numbers like 100 - 500 at a time might have to make a decaying plant feature to balance this out

but here is the script, just looking for thoughts and advice right now, thanks
and before you ask why ive also done the else if's I was thinking about what I could add to it, before I remove it

pawn Code:
forward SpawnedPlantsGrowthTick();
public SpawnedPlantsGrowthTick()
{
    new rows = cache_num_rows();
    for(new i = 0; i < rows && i < MAX_WEEDPLANTS; i ++)
    {
        cache_get_value_name_int(i, "id", WeedPlants[i][ID]);
        cache_get_value_name_int(i, "buds", WeedPlants[i][Buds]);
        cache_get_value_name_int(i, "spawned", WeedPlants[i][Spawned]);
        cache_get_value_name_int(i, "fullygrown", WeedPlants[i][FullyGrown]);
        if(WeedPlants[i][Exists] == 1)
        {
            if(WeedPlants[i][Spawned] == 1)
            {
                if(WeedPlants[i][FullyGrown] == 0)
                {
                    if(WeedPlants[i][Buds] <= 27)
                    {
                        WeedPlants[i][Buds] = WeedPlants[i][Buds]+1;
                        WeedPlants[i][FullyGrown] = 1;
                    }
                    else if(WeedPlants[i][Buds] == 28)
                    {
                        WeedPlants[i][FullyGrown] = 1;
                    }
                }
                else if(WeedPlants[i][FullyGrown] == 1)
                {
                }
            }
            else if(WeedPlants[i][Spawned] == 0)
            {
            }
        }
        else if(WeedPlants[i][Exists] == 0)
        {
        }
    }
    SetTimer("SpawnedPlantsGrowthTick", 180000, true); // Set a timer of 180000 miliseconds (180 seconds (3 minutes))
    return 1;
}
__________________
Purchasable Scripting Services Available, Inbox me with your Requests.
My Project Progress Tracker
My Work
Link
Information
S-Store System V2 LinkIngame Store in Dialogs
SkyFlare is offline   Reply With Quote
Old 04/01/2019, 12:10 PM   #2
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default Re: MySQL Timer question

Quote:
Originally Posted by ****** View Post
No, adding one number ever three minutes is not a heavy load.
more to the point, what about if I am changing one number to say, 300 rows or so?
__________________
Purchasable Scripting Services Available, Inbox me with your Requests.
My Project Progress Tracker
My Work
Link
Information
S-Store System V2 LinkIngame Store in Dialogs
SkyFlare is offline   Reply With Quote
Old 04/01/2019, 01:25 PM   #3
SkyFlare
Huge Clucker
 
SkyFlare's Avatar
 
Join Date: Apr 2015
Location: NZ
Posts: 221
Reputation: 43
Default Re: MySQL Timer question

Quote:
Originally Posted by ****** View Post
No. Computers can do billions of things a second. You want to do like 300 in 3 minutes. You're not even close to the same order of magnitude.
awesome, just making sure thank you
__________________
Purchasable Scripting Services Available, Inbox me with your Requests.
My Project Progress Tracker
My Work
Link
Information
S-Store System V2 LinkIngame Store in Dialogs
SkyFlare 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
Performance Question , Per Player Timer vs Timer that loops through all players BiosMarcel Scripting Help 14 12/12/2016 09:50 AM
A Question About Timer Cannary2048 Scripting Help 4 27/07/2014 10:19 PM
A little question about timer kamiliuxliuxliux Scripting Help 2 07/03/2014 06:07 PM
Question about timer! ikbenremco Scripting Help 7 02/12/2011 03:04 PM
mysql timer question iJumbo Help Archive 1 23/09/2010 10:12 AM


All times are GMT. The time now is 08:25 PM.


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