SA-MP Forums Archive
[Tutorial] Speedo with Timer - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Speedo with Timer (/showthread.php?tid=167814)

Pages: 1 2 3


Re: Speedo with Timer - pmk1 - 20.09.2010

thanks


Re: Speedo with Timer - WillyP - 21.09.2010

okay, so maybe a possible abuse part of this

when your driving and your car explodes, the textdraw doesnt disappear

so i quickly thought of a really easy fix

such as

onplayerexitvehicle
{
textdrawhideforplayer lalalala
lalala

and then

onplayerdeath

textdrawhidefor player

lalalala


even if you die in foot, hiding the textdraw thats already hidden wont make you crash or whatever

p.s

if someones already said this, my bad, i just couldnt be bothered to flick through about 11 pages


Re: Speedo with Timer - pmk1 - 21.09.2010

yea good, but is it really useful? xD you die then respawn in less than 2 secs and same when you leave vehicle, but w/e i'll maybe add it :P


Re: Speedo with Timer - Basicz - 21.09.2010

Nice tutorial.


Re: Speedo with Timer - pmk1 - 24.09.2010

Thanks!


Re: Speedo with Timer - pmk1 - 26.11.2010

Added Health'o'Meter to the tutorial :P


Re: Speedo with Timer - Abreezy - 07.01.2012

How can you control the speed shown per car? For example, a stratum doesn't go 180. How can i modify that?


Re: Speedo with Timer - pmk1 - 10.01.2012

you can't modify a vehicle's speed the script just show it's current one. But do you mean that the script shows 180 but it isn't it's real speed?


Re: Speedo with Timer - Universal - 14.01.2012

Quote:
Originally Posted by [FU]Victious
View Post
okay, so maybe a possible abuse part of this

when your driving and your car explodes, the textdraw doesnt disappear

so i quickly thought of a really easy fix

such as

onplayerexitvehicle
{
textdrawhideforplayer lalalala
lalala

and then

onplayerdeath

textdrawhidefor player

lalalala


even if you die in foot, hiding the textdraw thats already hidden wont make you crash or whatever

p.s

if someones already said this, my bad, i just couldnt be bothered to flick through about 11 pages
You'd better use OnPlayerStateChange to hide/delete the textdraw.


Re: Speedo with Timer - §с†¶e®РµРe - 14.01.2012

Nice tutorial.


Re: Speedo with Timer - pmk1 - 14.01.2012

thanks :P i'll maybe add more features on this tutorial when i have the time & @universal you're right it woud be better


Re: Speedo with Timer - dogman - 12.07.2012

You can also create the textdraws in a loop ( in ongamemodeinit) like:
pawn Code:
new i = 0;
    while (i < (sizeof (SPEEDOS) + 1) && (sizeof (HEALTH) +1))
    {
        SPEEDOS[i] = TextDrawCreate(208.000000, 434.000000, " "), TextDrawBackgroundColor(SPEEDOS[i], 255), TextDrawFont(SPEEDOS[i], 1), TextDrawLetterSize(SPEEDOS[i], 0.500000, 1.000000), TextDrawColor(SPEEDOS[i], -1), TextDrawSetOutline(SPEEDOS[i], 0), TextDrawSetProportional(SPEEDOS[i], 1), TextDrawSetShadow(SPEEDOS[i], 1);
        HEALTH[i] = TextDrawCreate(347.000000, 434.000000, " "), TextDrawBackgroundColor(HEALTH[i], 255), TextDrawFont(HEALTH[i], 1), TextDrawLetterSize(HEALTH[i], 0.500000, 1.000000), TextDrawColor(HEALTH[i], -1), TextDrawSetOutline(HEALTH[i], 0), TextDrawSetProportional(HEALTH[i], 1), TextDrawSetShadow(HEALTH[i], 1);
        i++;
        if(i == sizeof (SPEEDOS) && sizeof (HEALTH)) {
            printf("[SERVER] [CONSOLE]: Created: %d Speedo/Health meters.", i);
        }
    }
So you only have to call:
pawn Code:
TextDrawShowForPlayer(playerid,HEALTH[playerid]);
    TextDrawShowForPlayer(playerid,SPEEDOS[playerid]);
In onplayerconnect


Re: Speedo with Timer - dogman - 12.07.2012

an if you change the code of: public Speedometer(playerid) like:
pawn Code:
public Speedometer(playerid)
{
    new vehicleid,Float:speed_x,Float:speed_y,Float:speed_z,Float:final_speed,speed_string[256],final_speed_int;
    vehicleid = GetPlayerVehicleID(playerid);
    new Float:vehicle_health,final_vehicle_health,health_string[256];
    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))*250.666667; // 250.666667 = kmph  // 199,4166672= mph
        final_speed_int = floatround(final_speed,floatround_round);
        format(speed_string,256,"Speed: %i",final_speed_int);
        TextDrawSetString(SPEEDOS[playerid], speed_string);
        GetVehicleHealth(vehicleid,vehicle_health);
        final_vehicle_health = floatround(floatround(vehicle_health - 250)/ 7.5); //This will make the health show at 100 when the vehicle is not damaged and at 0 when it is in fire.
        if(final_vehicle_health < 1) {
            format(health_string,256,"Health: 0");
        } else {
            format(health_string,256,"Health: %i", final_vehicle_health);
        }
        TextDrawSetString(HEALTH[playerid], health_string);
    }
    else
    {
        TextDrawSetString(SPEEDOS[playerid], " ");
        TextDrawSetString(HEALTH[playerid], " ");
    }
    return 1;
}
Then will the healt meter dont go below 0 if you explode i always get something like -30 when i explode...


Re: Speedo with Timer - Coder_ - 12.07.2012

This is cool and useful tut! Thanks


Re: Speedo with Timer - Coder_ - 15.07.2012

Quote:
Originally Posted by Coder_
View Post
This is cool and useful tut! Thanks
My server crash when i try join :/ nEED HELP


Re: Speedo with Timer - Karl[NDZ] - 22.07.2012

No pictures?


Re: Speedo with Timer - AndreiWow - 02.01.2017

it only works for one player, why?