GetVehicleVelocity
#2

I've created my function a while back and it's quite accurate. Have a look
pawn Код:
if (strcmp(cmd, "/speed", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new giveplayerid;
            tmp = strtok(cmdtext, idx);
            new string[256];
            new Float:pos[4],Float:speed[2], final[2]; //Where [0] == MPH and [1] == KPH
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "[ERROR]USAGE: /speed [playerid/PartOfName]");
                return 1;
            }
            //giveplayerid = strval(tmp);
            giveplayerid = ReturnUser(tmp);
            if(IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    if(IsPlayerInAnyVehicle(giveplayerid))GetVehicleVelocity(GetPlayerVehicleID(giveplayerid),pos[1],pos[2],pos[3]);
                    else GetPlayerVelocity(giveplayerid,pos[1],pos[2],pos[3]);
                    speed[0] = floatmul(floatsqroot(floatpower(pos[1],2)+floatpower(pos[2],2)+floatpower([pos[3],2)),125); //MPH
                    speed[1] = floatmul(floatsqroot(floatpower(pos[1],2)+floatpower(pos[2],2)+floatpower(pos[3],2)),200); //KPH
                    final[0] = floatround(speed[0]);
                    final[1] = floatround(speed[1]);
                    format(string, sizeof(string), " AdmCmd: %s has a speed of %d MPH and %d KPH", GetPlayerNameEx(giveplayerid), final[0], final[1]);
                    SendClientMessage(playerid, COLOR_YELLOW, string);

                }
                else SendClientMessage(playerid, COLOR_WHITE, "[ERROR]No Such Player");
            }
            else SendClientMessage(playerid, COLOR_WHITE, "[ERROR]Player Not Connected");
        }
        return 1;
    }
I have multiplying the float by 200 == KPH
Reply


Messages In This Thread
GetVehicleVelocity - by pantelimonfl - 17.12.2010, 12:23
Re: GetVehicleVelocity - by Kaylux - 17.12.2010, 13:08
Re: GetVehicleVelocity - by pantelimonfl - 17.12.2010, 13:18

Forum Jump:


Users browsing this thread: 3 Guest(s)