Speed limiter
#1

Hello.

I am a speed limiter.

I declare these variables:
Код:
new limiteur[MAX_PLAYERS];
new limiteurReload[MAX_PLAYERS];
new Float:limiteurSpeed[MAX_PLAYERS][3];
When the limiter is activated (limit = = maximum speed input) :
Код:
limiteurReload[playerid] = 1;
limiteur[playerid] = vitesse;
In OnPlayerUpdate :
Код:
GetVehicleVelocity(GetPlayerVehicleID(playerid), fPos[0], fPos[1], fPos[2]);

		fSpeed = floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) +
		 floatpower(fPos[2], 2)) * 150;
		 
		new Float:alpha = 320 - fSpeed;

	    if(limiteurReload[playerid] == 1) {
		    if(limiteur[playerid] == fSpeed) {
				for(new i = 0; i < 3; i++) {
					limiteurSpeed[playerid][i] = fPos[i];
					printf("%d - %f - %f",i,fPos[i],limiteurSpeed[playerid][i]);
				}
				limiteurReload[playerid] = 0;
		    }
		}
		if(limiteur[playerid] != 0) {
	    	if(fSpeed > limiteur[playerid]) {
	    	    SetVehicleVelocity(GetPlayerVehicleID(playerid), limiteurSpeed[playerid][0], limiteurSpeed[playerid][1], limiteurSpeed[playerid][2]);
			}
		}
Basically, I get the velocity of the vehicle when it is waiting limit.

If the above, we commend its velocity parameters recovered.

The problem is that with this script, if you exceed the speed limit, it returns to 0km / h (as if the settings were left at 0 ...)

How to solve it? Thank you!
Reply
#2

I've resolve this bug.

The problem is in this code :

Код:
if(limiteur[playerid] != 0) {
	    	if(fSpeed > limiteur[playerid]) {
	    	    SetVehicleVelocity(GetPlayerVehicleID(playerid), limiteurSpeed[playerid][0], limiteurSpeed[playerid][1], limiteurSpeed[playerid][2]);
			}
			for(new i = 0; i < 3; i++) {
				limiteurSpeed[playerid][i] = fPos[i];
			}
		}
When I go up or down a slope, I have two fly wheels. When I drove into a hazard, my car forward and caught fire. Can not drifter.

How to solve it ? Thanks.
Reply
#3

Quote:
Originally Posted by Urefeu
Посмотреть сообщение
Hello.

I am a speed limiter.
Are you?

Anyways, you should use those arrays to get the vehicle's velocity... I didn't see you to use them anywhere.
pawn Код:
limiteurSpeed[playerid][0], limiteurSpeed[playerid][1], limiteurSpeed[playerid][2]
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)