[+rep] definings - 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: [+rep] definings (
/showthread.php?tid=307911)
[+rep] definings -
PawnoQ - 01.01.2012
hi,
i made a kinda anti cheat and my questions is if i shall the float define for max players or if in this case only this would be enough:
pawn Код:
new Float:pArmourtmp;
new Float:pHealthtmp;
GetPlayerArmour(i,pArmourtmp);
GetPlayerHealth(i,pHealthtmp);
or like this?
pawn Код:
//OnGameModeInit
SetTimer("AntiCheat", 1000, true);
//Timer
forward AntiCheat();
public AntiCheat()
{
foreach(Player, i)
{
new Float:pArmourtmp[MAX_PLAYERS];
new Float:pHealthtmp[MAX_PLAYERS];
GetPlayerArmour(i,pArmourtmp[i]);
GetPlayerHealth(i,pHealthtmp[i]);
if(pHealthtmp[i] > 99)
{
//kick due health hacks
}
}
return 1;
}
Re: [+rep] definings -
PawnoQ - 01.01.2012
mhhh, i tested it, it works with both methods but does it make sense to define pArmourtmp and pHealthtmp for maxplayers here?
Would be there a difference in speed?
Re: [+rep] definings -
Gh05t_ - 01.01.2012
Optimization and efficiency may relate to the usage of less tasks to be performed. Though, there may be alternate methods of performing set task which may be faster. I recommend you to take a look at ******'
Code Optimization thread. It provides many examples and detailed instructions on coding efficiency.
Re: [+rep] definings -
PawnoQ - 01.01.2012
thx.
And this topic by ****** my friend is the NO.1 in my bookmarks
Can you also help me with the question above?
Re: [+rep] definings -
Gh05t_ - 01.01.2012
Quote:
Originally Posted by PawnoQ
Would be there a difference in speed?
|
This
pawn Код:
new Float:pArmourtmp, Float:pHealthtmp;
GetPlayerArmour(i,pArmourtmp);
GetPlayerHealth(i,pHealthtmp);
opposed to this...
pawn Код:
new Float:pArmourtmp[MAX_PLAYERS];
new Float:pHealthtmp[MAX_PLAYERS];
GetPlayerArmour(i,pArmourtmp[i]);
GetPlayerHealth(i,pHealthtmp[i]);
MAY be faster, though speed in this case shouldn't be considered a factor and is merely a minority.
Re: [+rep] definings -
PawnoQ - 01.01.2012
thx a lot.
would it make a difference in functionallity when i use this as an anti cheat in a timer with a loop(for all players)?