Can someone explain this? - 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: Can someone explain this? (
/showthread.php?tid=633514)
Can someone explain this? -
Sjn - 02.05.2017
My server's max player slot is defined as 100, but I noticed this one error in the log;
Код:
[16:20:50] [debug] Accessing element at index 274 past array upper bound 99
[16:20:50] [debug] AMX backtrace:
[16:20:50] [debug] #1 00033234 in public OnPlayerGiveDamage (playerid=3, damagedid=274, Float:amount=-0.00000, weaponid=62, bodypart=6) ...
[16:20:50] [debug] Run time error 4: "Array index out of bounds"
How did id 274 get passed to the damagedid argument when the max players is defined 100? Is there some sort of hacking tool that the players are using to fake these or the callback itself returns something like this if the damagedid is paused? Because the IsPlayerPaused function also gave the same error along with this callback and I have checked if the damagedid is paused or not before executing further codes inside the callback. I will provide the code if needed.
This is very weird and I noticed this for the first time, couldn't find out the possible solution to fix this. Any help?
Re: Can someone explain this? -
Dayrion - 02.05.2017
PHP код:
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
{
if(!IsPlayerConnected(playerid) || !IsPlayerConnected(damagedid) || !IsValidWeapon(weaponid) || !IsValidBodyPart(bodypart))
return 0;
PHP код:
IsValidWeapon(weaponid)
return (0 <= weaponid <= 46) && !(19 <= weaponid <= 21) ? true : false;
IsValidBodyPart(bodypart)
return (3 <= bodypart <= 9) ? true : false;
It should solve your problem.
Re: Can someone explain this? -
Vince - 02.05.2017
The client reports the damage. It could be a hack or it could be a connection anomaly. This game uses the UDP protocol which operates on a "best effort" principle by default. There are no checks in place for anything so packets may arrive malformed, out of order, etc. This is fine for streaming where a few malformed packets won't have any noticeable impact on the perceived video or sound but it can't be used to transmit something like a Word document because that could result in garbled text. SA-MP and/or RakNet have implemented some checking on top of the UDP protocol, but I don't think it is entirely watertight.
For example 18 in binary is:
Код:
0000 0000 0001 0010
If there is an error and a 1 is transmitted instead of zero you can get
Код:
0000 0001 0001 0010
Which is 274. I'm not saying that this is definitely what happened but it could be one explanation.