30.03.2010, 12:50
This is VERY inefficient. I wouldn't recommend using this. It can loop over 2000 times per second, per player. It has a 200 iteration loop inside OnPlayerUpdate, which can get called up 10x a second per player.
If your server had only 10 players connected, it could loop up 20,000 times a second. Considering how slow pawn is your server would be unplayable. Not to mention the calculations in place to check if a player is in range of the spikes.
I released a spike strip about a year ago. I'm going to be rewriting part of it and releasing it shortly. It will be much faster and efficient than this.
Some other problems I've just noticed:
Although I doubt this function is in anyway inefficient, it's a useless check. There obviously has to be a connected player for it to call OnPlayerUpdate.
Why are you calculating if the player is in range of the strip before even knowing if the strip exists or not?
Why are you returning 0 here, which would result in the player being de synced if they're hovering over the spike strip?
If your server had only 10 players connected, it could loop up 20,000 times a second. Considering how slow pawn is your server would be unplayable. Not to mention the calculations in place to check if a player is in range of the spikes.
I released a spike strip about a year ago. I'm going to be rewriting part of it and releasing it shortly. It will be much faster and efficient than this.
Some other problems I've just noticed:
Quote:
|
Originally Posted by OnPlayerUpdate
if(!IsPlayerConnected(playerid)) return 0;
|
Quote:
|
Originally Posted by OnPlayerUpdate loop
if(IsPlayerInRangeOfPoint(playerid, 3.0, SpikeInfo[i][sX], SpikeInfo[i][sY], SpikeInfo[i][sZ]))
{ if(SpikeInfo[i][sCreated] == 1) |
Quote:
|
Originally Posted by OnPlayerUpdate: tyre popping
UpdateVehicleDamageStatus(carid, panels, doors, lights, tires);
return 0; |

