MySQL Timer question - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL Timer question (
/showthread.php?tid=662525)
MySQL Timer question -
SkyFlare - 04.01.2019
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;
}
Re: MySQL Timer question -
SkyFlare - 04.01.2019
Quote:
Originally Posted by ******
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?
Re: MySQL Timer question -
SkyFlare - 04.01.2019
Quote:
Originally Posted by ******
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