Multiple SetVehicleVelocity?
#1

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);
}
Reply
#2

What happens though? Does the vehicle not move, does it crash the command?
Reply
#3

The vehicle moves once
Reply
#4

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.
Reply
#5

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
Reply
#6

Im not saying they have to be in control, i'm just saying that spamming the function won't do anything
Reply
#7

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);
}
Reply
#8

SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 10*0.2, 0.0);
Reply
#9

DJDhan's method would work, but remember to put under velocity(playerid):
pawn Код:
limiton[playerid]=0;
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)