SA-MP Forums Archive
formula - 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: formula (/showthread.php?tid=512927)



formula - rumen98 - 13.05.2014

Hello, can I have some help so
RLTnfo [playerid] [Scavenge] it is a skill every level down 3% from the time of the search (which is 3 minutes (180 seconds)) how do I make the formula to calculate how long to cut the whole time searching for example if the level of my skill is 5 which is 15%.
How can I make my example, decreased time of 180 seconds - 15% of the time??


Re: formula - RajatPawar - 13.05.2014

Wait, what? I have no idea what you're saying, but I am going to have a go -

pawn Code:
GetPlayerSearchTime(playerid)
{
      new pLevel = RLTnfo[playerid][Scavenge],
             percent = ( pLevel * 3 ),
               totalTime = floatround((180 - ( (percent * 180) / 100 )));
     
      printf("Level: %d || Percent: %d%% || Searchtime (reduced): %d seconds", pLevel, percent, totalTime);

      return totalTime;
}



Re: formula - rumen98 - 13.05.2014

Quote:
Originally Posted by RajatPawar
View Post
Wait, what? I have no idea what you're saying, but I am going to have a go -

pawn Code:
GetPlayerSearchTime(playerid)
{
      new pLevel = RLTnfo[playerid][Scavenge],
             percent = ( pLevel * 3 ),
               totalTime = floatround((180 - ( (percent * 180) / 100 )));
     
      printf("Level: %d || Percent: %d%% || Searchtime (reduced): %d seconds", pLevel, percent, totalTime);

      return totalTime;
}
How can I use this code in addition to my timer?
PHP Code:
SetTimer("StartScavenging"180*1000false); 



Re: formula - Madd92 - 13.05.2014

Quote:
Originally Posted by rumen98
View Post
How can I use this code in addition to my timer?
PHP Code:
SetTimer("StartScavenging"180*1000false); 
And I guess that's the part where we don't know anymore what you want to do xD
At least for me it is. Please try to be a bit more explainatory


Re: formula - rumen98 - 13.05.2014

How can I add code to the timer means by level of RLTnfo [playerid] [Scavenge] + entire formula to reduce the timer according to the result?


AW: formula - Nero_3D - 13.05.2014

Well just do
pawn Code:
SetTimer("StartScavenging", GetPlayerSearchTime(playerid) * 1000, false);



Re: formula - rumen98 - 13.05.2014

thanks


Re: formula - Madd92 - 13.05.2014

Quote:
Originally Posted by rumen98
View Post
How can I add code to the timer means by level of RLTnfo [playerid] [Scavenge] + entire formula to reduce the timer according to the result?
If you wanted to reduce the timer you'd have to kill the existant one an set a new timer. For that you have to save the return value of SetTimer in order to being able to kill it later on. But I don't think that's what you want. The question is, what does the timer do? It executes the search? Then just use the function by RajatPawar:
pawn Code:
SetTimer("StartScavenging", GetPlayerSearchTime(playerid)*1000, false);
when setting the timer in general.
Of course you should use SetTimerEx then as you are going to have more than one person searching right?


Re: formula - rumen98 - 13.05.2014

Timer is individual for each player is not mass