SA-MP Forums Archive
Speedmeter is only showing for ID 0[++rep] - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Speedmeter is only showing for ID 0[++rep] (/showthread.php?tid=542755)



Speedmeter is only showing for ID 0[++rep] - lulo356 - 22.10.2014

The textdraw is only showing for ID 0 How to fix that

pawn Код:
forward Speedo(playerid);
public Speedo(playerid) {

    new vehicleid,
        Float:speed_x,
        Float:speed_y,
        Float:speed_z,
        Float:final_speed,
        speed_string[256],
        final_speed_int;

foreach(Player, i)
    {
        vehicleid = GetPlayerVehicleID(i);

        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))*125;
            final_speed_int = floatround(final_speed,floatround_round);
            format(speed_string,256,"Speed: %i Km/H",final_speed_int);
            PlayerTextDrawSetString(i,Speedoo[i], speed_string);
            PlayerTextDrawShow(playerid, Speedoo [ playerid ] );
            PlayerTextDrawShow(playerid, carhealth [ playerid ] );
            PlayerTextDrawShow(playerid, dashboard [ playerid ] );

        } else {

            PlayerTextDrawSetString(i,Speedoo[i], "Speed: 0 Km/H ");
            PlayerTextDrawSetString(i,carhealth[i], "Health: 1000");
            PlayerTextDrawHide(playerid,Speedoo[playerid]);
            PlayerTextDrawHide(playerid, carhealth [playerid] );
            PlayerTextDrawHide(playerid, dashboard [ playerid ] );

        }


    }
    return 1;
}



Re: Speedmeter is only showing for ID 0[++rep] - DeStunter - 22.10.2014

So why are sending the playerid when you are checking all players anyway? Replace playerid with i and don't send it as its not need.


Re: Speedmeter is only showing for ID 0[++rep] - lulo356 - 22.10.2014

Quote:
Originally Posted by DeStunter
Посмотреть сообщение
So why are sending the playerid when you are checking all players anyway? Replace playerid with i and don't send it as its not need.
Thanks Bro It works <3 +rep for you