PDA

View Full Version : [+rep] definings


PawnoQ
01/01/2012, 04:18 PM
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:

new Float:pArmourtmp;
new Float:pHealthtmp;
GetPlayerArmour(i,pArmourtmp);
GetPlayerHealth(i,pHealthtmp);


or like this?

//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;
}

PawnoQ
01/01/2012, 05:34 PM
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?

Gh05t_
01/01/2012, 05:46 PM
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 (http://forum.sa-mp.com/showthread.php?t=57018)thread. It provides many examples and detailed instructions on coding efficiency.

PawnoQ
01/01/2012, 05:53 PM
thx.

And this topic by ****** my friend is the NO.1 in my bookmarks ;)

Can you also help me with the question above? :)

Gh05t_
01/01/2012, 05:59 PM
Would be there a difference in speed?

This

new Float:pArmourtmp, Float:pHealthtmp;
GetPlayerArmour(i,pArmourtmp);
GetPlayerHealth(i,pHealthtmp);


opposed to this...

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.

PawnoQ
01/01/2012, 06:04 PM
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)?

Gh05t_
01/01/2012, 06:15 PM
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)?

You've already done so in your previous post, though I may have misunderstood what you have said.