Speedo freaks.
#1

My speedo freaks when more than one player are driving a vehicle. It starts showing all players speed, and that's bad.
I use GameTextForPlayer, to show the speed.

pawn Код:
new Float: VehicleSpeed[MAX_VEHICLES];
pawn Код:
forward UpSpeed();
public UpSpeed()
{
    new Float:pX,Float:pY,Float:pZ;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i))
        {
        if(IsPlayerInAnyVehicle(i))
            {

            GetPlayerPos(i,Float:pX,Float:pY,Float:pZ);

            VehicleSpeed[GetPlayerVehicleID(i)] = floatsqroot(floatpower(floatabs(floatsub(pX,PlayerData[i][OSX])),2)+floatpower(floatabs(floatsub(pY,PlayerData[i][OSY])),2)+floatpower(floatabs(floatsub(pZ,PlayerData[i][OSZ])),2));
           
            VehicleSpeed[GetPlayerVehicleID(i)] = floatround(VehicleSpeed[GetPlayerVehicleID(i)] * 5000 / 1000);
           
            }
        }
    GetPlayerPos(i,Float:pX,Float:pY,Float:pZ);
    PlayerData[i][OSX]=floatround(pX);
    PlayerData[i][OSY]=floatround(pY);
    PlayerData[i][OSZ]=floatround(pZ);
    }
    return 1;
}
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2 && newstate != 3)
    {
    upspeedt = SetTimerEx("UpSpeed",1000,1,"i",playerid);
    VehicleSpeed[GetPlayerVehicleID(playerid)]=0;
    }
}
What is wrong here?
Reply


Messages In This Thread
Speedo freaks. - by RaFsTar - 13.09.2009, 15:17
Re: Speedo freaks. - by RaFsTar - 13.09.2009, 15:46
Re: Speedo freaks. - by Backwardsman97 - 13.09.2009, 16:08

Forum Jump:


Users browsing this thread: 1 Guest(s)