Speed limiter - 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: Speed limiter (
/showthread.php?tid=284886)
Speed limiter -
Urefeu - 21.09.2011
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!
Re: Speed limiter -
Urefeu - 21.09.2011
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.
Re: Speed limiter -
[MWR]Blood - 21.09.2011
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]