Get Vehicle speed.
#1

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

https://sampwiki.blast.hk/wiki/GetVehicleVelocity
Reply
#3

No if he goes to fast then 80 it will destroy checkpoint else crashed car.
Reply
#4

Quote:
Originally Posted by Mey6155
Посмотреть сообщение
No if he goes to fast then 80 it will destroy checkpoint else crashed car.
YoungKris already provide you the function. You on;y need to code it yourself.
Reply
#5

I don't know how.
Reply
#6

https://sampforum.blast.hk/showthread.php?tid=364124&page=3
Reply
#7

PHP код:
#define MPH_KMH 1.609344
stock GetVehicleSpeedvehicleid )
{
    new
        
Float:x,
        
Float:y,
        
Float:z,
        
vel;
    
GetVehicleVelocityvehicleidxy);
    
vel floatroundfloatsqrootx*y*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 
Reply
#8

Can you explain it better and with |[PAWN]|? BEcause I really don't get a crap out of it.

This is my code for the speed:

pawn Код:
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;
}
Now how can I make it if the car goes faster then 80 the checkpoints get 0 and also TakeLic[playerid] = 0;
??
Reply
#9

...?
Reply
#10

You have the wrong values.

pawn Код:
final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*199.4166672; // 250.666667 = kmph  // 199,4166672= mph
It should be 180.0 - 181.5 for kmh those numbers that you have are out to lunch and make no sense given all the testing done.

As for your original problem you have no code checking, if they are in a driving test at all so you probably didn't even write this script so you should really ask the creator of the script for help.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)