GetPlayerSpeed
#1

This is what i currently have

pawn Код:
stock GetPlayerSpeed(playerid,bool:kmh)
{
    new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
    if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
    rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
    return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
}
What i want:
1: It should calculate in kmh, currently it's mph
2: It should count all numbers, for example 1 kmh, 2 kmh, 3 kmh etc (Currently if i press W it instantly shows 15kmh)

I will give +rep (4points) to the one who helps me!
Reply
#2

pawn Код:
public OnPlayerUpdate(playerid) // You could use something better
{
    GetPlayerSpeed(playerid, true);
    return 1;
}
Reply
#3

Quote:
Originally Posted by iTorran
Посмотреть сообщение
pawn Код:
public OnPlayerUpdate(playerid) // You could use something better
{
    GetPlayerSpeed(playerid, true);
    return 1;
}
It's still the same
Reply
#4

pawn Код:
new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
    vehicleid = GetPlayerVehicleID(playerid);
    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))*143.666667;
        final_speed_int = floatround(final_speed,floatround_round);
        format(speed_string,256,"Speed: %i Km/h",final_speed_int);
        TextDrawSetString(SPEEDOS[playerid], speed_string);
    }
}
Reply
#5

Quote:
Originally Posted by milanosie
Посмотреть сообщение
pawn Код:
new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
    vehicleid = GetPlayerVehicleID(playerid);
    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))*143.666667;
        final_speed_int = floatround(final_speed,floatround_round);
        format(speed_string,256,"Speed: %i Km/h",final_speed_int);
        TextDrawSetString(SPEEDOS[playerid], speed_string);
    }
}
Your code is totally different
Reply
#6

Quote:
Originally Posted by Dripac
Посмотреть сообщение
This is what i currently have

pawn Код:
stock GetPlayerSpeed(playerid,bool:kmh)
{
    new Float:Vx,Float:Vy,Float:Vz,Float:rtn;
    if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz);
    rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2)));
    return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100);
}
What i want:
1: It should calculate in kmh, currently it's mph
2: It should count all numbers, for example 1 kmh, 2 kmh, 3 kmh etc (Currently if i press W it instantly shows 15kmh)

I will give +rep (4points) to the one who helps me!
I am not that good at Maths. To Convert it from kph to mph. I hope you get it converted soon.
But i would like to use this function for my game mode? Can i? Will keep your credits?

Can you give me the correct usage for this function as well
Reply
#7

pawn Код:
new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
    vehicleid = GetPlayerVehicleID(playerid);
    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))*143.666667;
        final_speed_int = floatround(final_speed,floatround_round);
        format(speed_string,256,"Speed: %i Km/h",final_speed_int);
        TextDrawSetString(SPEEDOS[playerid], speed_string);
    }
}
Reply
#8

Quote:
Originally Posted by milanosie
Посмотреть сообщение
pawn Код:
new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
    vehicleid = GetPlayerVehicleID(playerid);
    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))*143.666667;
        final_speed_int = floatround(final_speed,floatround_round);
        format(speed_string,256,"Speed: %i Km/h",final_speed_int);
        TextDrawSetString(SPEEDOS[playerid], speed_string);
    }
}
This is what the author of this thread said when you first pasted this here as a reply mate:
Quote:
Originally Posted by Dripac
Посмотреть сообщение
Your code is totally different
Reply
#9

Quote:
Originally Posted by Ballu Miaa
Посмотреть сообщение
This is what the author of this thread said when you first pasted this here as a reply mate:
Didnt mean to double post,
Reply
#10

Paste it on top of the script:

pawn Код:
stock Float:GetPlayerSpeed(playerid, bool:KMH)
{
    new Float:Speed, Float:vX, Float:vY, Float:vZ;
    if(!IsPlayerInAnyVehicle(playerid)) GetPlayerVelocity(playerid, vX, vY, vZ);
    else GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
    Speed = floatsqroot(((vX*vX)+(vY*vY))+(vZ*vZ));
    return KMH ? (Speed*100.0) : (Speed*62.1371);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)