19.05.2011, 17:49
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
public OnPlayerCommandText(playerid, cmdtext[])
{
if (!strcmp("/carjump", cmdtext))
{
if(IsPlayerInAnyVehicle(playerid))
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.0, 0.2);
return 1;
}
}
#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]);
}
if(SacarV(playerid) >= VEL_MAX)
if(SacarV(playerid) >= VEL_MAX && EsMonociclo(GetPlayerVehicleID(playerid)))
EsMonociclo(id)
{
new idd = GetVehicleModel(id);
if(idd == 462 || idd == 509 || idd == 481 || idd == 510) return 1;
return 0;
}
#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;
}