Multiple SetVehicleVelocity? -
WillyP - 26.07.2010
I thought of when doing a command, the car moves a certain length before it stops, and at a certain speed, but it doesnt work.
Heres the script i have atm:
pawn Код:
#include <a_samp>
forward velocity(playerid);
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" setvehlocity tester");
print("--------------------------------------\n");
SetTimer("velocity",25000,true);
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp("/test", cmdtext))
{
if(IsPlayerInAnyVehicle(playerid))
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.2, 0.0);
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.2, 0.0);
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.2, 0.0);
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.2, 0.0);
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.2, 0.0);
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.2, 0.0);
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.2, 0.0);
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.2, 0.0);
TogglePlayerControllable(playerid, 0);
return 1;
}
return 0;
}
public velocity(playerid)
{
TogglePlayerControllable(playerid, 1);
KillTimer(playerid);
}
Re: Multiple SetVehicleVelocity? -
Carlton - 26.07.2010
What happens though? Does the vehicle not move, does it crash the command?
Re: Multiple SetVehicleVelocity? -
WillyP - 26.07.2010
The vehicle moves once
Re: Multiple SetVehicleVelocity? -
mastasquizy - 27.07.2010
Well setting a velocity merely sets it, but toggleplayercontrollable stops the vehicle. Spamming the velocity command wouldn't do anything because its not adding velocity, but just resetting it. If you want the velocity for a longer time, you would have to have a timer manage it, because functions are carried out too quickly to see a difference. So technically it looks like the vehicle is moving 1 time, but its just doing what the code is saying.
Re: Multiple SetVehicleVelocity? -
WillyP - 27.07.2010
Quote:
Originally Posted by mastasquizy
Well setting a velocity merely sets it, but toggleplayercontrollable stops the vehicle. Spamming the velocity command wouldn't do anything because its not adding velocity, but just resetting it. If you want the velocity for a longer time, you would have to have a timer manage it, because functions are carried out too quickly to see a difference. So technically it looks like the vehicle is moving 1 time, but its just doing what the code is saying.
|
if the player is in control, then the other part of the script wont work
Re: Multiple SetVehicleVelocity? -
mastasquizy - 27.07.2010
Im not saying they have to be in control, i'm just saying that spamming the function won't do anything
Re: Multiple SetVehicleVelocity? -
DJDhan - 27.07.2010
Is this a speed limiter you are trying to code?
You need a variable that specifies whether the speed limiter is on.
Код:
limiton[MAX_PLAYERS];
Then under your "/test" command
Код:
limiton[playerid]=1;
You can use a timer but I'll show it to you
Under OnPlayerUpdate(playerid)
Код:
if(limiton[playerid]==1)
{
if(IsPlayerInAnyVehicle(playerid)) SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.2, 0.0);
}
Re: Multiple SetVehicleVelocity? -
Kar - 27.07.2010
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 10*0.2, 0.0);
Re: Multiple SetVehicleVelocity? -
mastasquizy - 27.07.2010
DJDhan's method would work, but remember to put under velocity(playerid):