27.05.2014, 17:14
I got a drivers license system. But how can I make it if the person rides harder then 80 miles per hour he gets failed.
And if he crashed the car a little.
And if he crashed the car a little.
#define MPH_KMH 1.609344
stock GetVehicleSpeed( vehicleid )
{
new
Float:x,
Float:y,
Float:z,
vel;
GetVehicleVelocity( vehicleid, x, y, z );
vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 ); // KM/H
// vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 / MPH_KMH ); // Mph
return vel;
}
it depends to your script
stock failed(playerid){ reset player stats ( remove from vehicule,change x,y,z postions ) }
on your timer or variable what's you use
example
new iffailed[MAX_PLAYERS];
in your cmd /license for start the exame
iffailed[playerid] = 0;
and set a timer yourtimer as true
public yourtimer(playerid){
if(iffailed[playerid] ==0){
if(GetVehicleSpeed( vehicleid ) >= 80) { failed(playerid); return true; }
when a player pass the exam reset the timer
DestroyTimer
this is a simple exmaple
public Speedometer(playerid)
{
new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
vehicleid = GetPlayerVehicleID(playerid);
new Float:vehicle_health,final_vehicle_health,health_string[256];
if(vehicleid != 0)
{
GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*199.4166672; // 250.666667 = kmph // 199,4166672= mph
final_speed_int = floatround(final_speed,floatround_round);
format(speed_string,256,"Speed: %i",final_speed_int);
TextDrawSetString(SPEEDOS[playerid], speed_string);
GetVehicleHealth(vehicleid,vehicle_health);
final_vehicle_health = floatround(floatround(vehicle_health - 250)/ 7.5); //This will make the health show at 100 when the vehicle is not damaged and at 0 when it is in fire.
format(health_string,256,"Health %i", final_vehicle_health);
TextDrawSetString(HEALTH[playerid], health_string);
}
else
{
TextDrawSetString(SPEEDOS[playerid], " ");
TextDrawSetString(HEALTH[playerid], " ");
}
return 1;
}
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*199.4166672; // 250.666667 = kmph // 199,4166672= mph