SA-MP Forums Archive
Help with speedometer - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with speedometer (/showthread.php?tid=247654)



Help with speedometer - ajwar - 10.04.2011

Hi, i am about to make a simple speedometer, but the problem is that it show's correctly just for the first player (id:0) who connect's first, while another player's(id:1) speedometer is freezed and didn't show any speed. I use a simple timer every 200ms:
pawn Код:
public Speed()
{
    foreach (Player, i)
    {
        new
        vehicleid = GetPlayerVehicleID(i);
        if(GetVehicleModel(GetPlayerVehicleID(i))==510||GetVehicleModel(GetPlayerVehicleID(i))==509||GetVehicleModel(GetPlayerVehicleID(i))==481) return 1;
        if((IsPlayerConnected(i))&&(IsPlayerInAnyVehicle(i)))
        {
            new speed[MAX_PLAYERS][18],fuel[14],Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,final_speed_int;

            GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
            final_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*200.0; // 250.666667 = kmph  
            final_speed_int = floatround(final_speed,floatround_round);

            format(fuel[i],sizeof(fuel),"Fuel: %i l", VehicleFuel[vehicleid]);
            format(speed[i],sizeof(speed),"Speed: %d km/h", final_speed_int);


            TextDrawSetString(textdraws[Textdraw0][i],speed[i]);
            TextDrawSetString(textdraws[Textdraw2][i],fuel[i]);
            return 1;
        }
        else
        {
                TextDrawSetString(textdraws[Textdraw0][i],"");
                TextDrawSetString(textdraws[Textdraw2][i],"");
        }
    }
    return 1;
}
Anyone who see the problem?


Re: Help with speedometer - sansko - 10.04.2011

you must define the playerid in "public speed()" and "forward Speed();" and in the called function


Re: Help with speedometer - ajwar - 10.04.2011

Still not working, it's shows just for the first connected player.


Re: Help with speedometer - LiamM - 10.04.2011

Quote:
Originally Posted by ajwar
Посмотреть сообщение
Still not working, it's shows just for the first connected player.
I am having problems with the /engine command for my script too, it only works for the first connected player


Re: Help with speedometer - ajwar - 10.04.2011

Anyone who can help?