[DUDA] Como definir una velocidad maxima a X vehiculos
#1

Buenas, busco el codigo para definirle a las faggio la velocidad maxima de 50 y a las bicicletas tambien, busque esto https://sampwiki.blast.hk/wiki/SetVehicleVelocity pero no se si serб ese
Reply
#2

el SetVehicleVelocity te permite aplicarle una velocidad al vehiculo en la direcciуn que desees, de acuerdo con el ejemplo de https://sampwiki.blast.hk/wiki/SetVehicleVelocity
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/carjump", cmdtext))
    {
    if(IsPlayerInAnyVehicle(playerid))
        SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.0, 0.2);
    return 1;
    }
}
aumentaras la coordenada "Z" 0.2, creando un salto
Reply
#3

Un FS que acabo de probar, nose si sera algo asi lo que quieras

pawn Код:
#include <a_samp>
#define VEL_MAX 60 //Cambiar el '60' por la velocidad maxima.
new TVelocidad[MAX_PLAYERS];

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        TVelocidad[playerid] = SetTimerEx("Velocidad",1000,1,"i",playerid);
    }
    if(oldstate == PLAYER_STATE_DRIVER)
    {
        KillTimer(TVelocidad[playerid]);
    }
    return 1;
}


forward Velocidad(playerid);
public Velocidad(playerid)
{
    new
        Float:Vel[3]
    ;
    if(SacarV(playerid) >= VEL_MAX)
    {
        GetPlayerVelocity(playerid, Vel[0], Vel[1], Vel[2]);
        SetVehicleVelocity(GetPlayerVehicleID(playerid), Vel[0], Vel[1], Vel[2]);
    }
}

SacarV(playerid)
{
    new Float:ST[4];
    if(IsPlayerInAnyVehicle(playerid))
    GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
    else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
    ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 180.3;
    return floatround(ST[3]);
}
Reply
#4

їPero en que lugar tendria que poner la ID del vehнculo que quiero que solo alcanze maximo esa velocidad y la velocidad que quiero poner?
Reply
#5

Quote:
Originally Posted by rubensm
Посмотреть сообщение
їPero en que lugar tendria que poner la ID del vehнculo que quiero que solo alcanze maximo esa velocidad y la velocidad que quiero poner?
Cambia "IsPlayerInAnyVehicle", por "IsPlayerInVehicle"
Reply
#6

Cambia este if

pawn Код:
if(SacarV(playerid) >= VEL_MAX)
por:

pawn Код:
if(SacarV(playerid) >= VEL_MAX && EsMonociclo(GetPlayerVehicleID(playerid)))
y agrega esto abajo de todo...

pawn Код:
EsMonociclo(id)
{
    new idd = GetVehicleModel(id);
    if(idd == 462 || idd == 509 || idd == 481 || idd == 510) return 1;
    return 0;
}
Reply
#7

bueno de acuerdo al scrip de GROVE, le aplique para bloquear ciertos vehiculos
pawn Код:
#include <a_samp>

#define VEL_MAX 60 //Cambiar el '60' por la velocidad maxima.
new VehiculosBloqueados[] = {425, 432, 447, 520}; // aqui pon los vehiculos que no quierees que se limite la velocidad
new TVelocidad[MAX_PLAYERS];

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER && validarvehiculo(playerid,GetPlayerVehicleID(playerid)))
    {
        TVelocidad[playerid] = SetTimerEx("Velocidad",1000,1,"i",playerid);
    }
    if(oldstate == PLAYER_STATE_DRIVER)
    {
        KillTimer(TVelocidad[playerid]);
    }
    return 1;
}


forward Velocidad(playerid);
public Velocidad(playerid)
{
    new
        Float:Vel[3]
    ;
    if(SacarV(playerid) >= VEL_MAX)
    {
        GetPlayerVelocity(playerid, Vel[0], Vel[1], Vel[2]);
        SetVehicleVelocity(GetPlayerVehicleID(playerid), Vel[0], Vel[1], Vel[2]);
    }
}

SacarV(playerid)
{
    new Float:ST[4];
    if(IsPlayerInAnyVehicle(playerid))
    GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
    else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
    ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 180.3;
    return floatround(ST[3]);
}
forward validarvehiculo(playerid,model);
validarvehiculo (playerid,model)
{
    for(new v = 0, m = sizeof VehiculosBloqueados; v < m; v++)
   {
      if(model == VehiculosBloqueados[v]) return false;
    }
    return true;

}
Reply
#8

Usa SpeedCap de Slice
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)