[Tutorial] Speedo with Timer
#41

thanks
Reply
#42

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
Reply
#43

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
Reply
#44

Nice tutorial.
Reply
#45

Thanks!
Reply
#46

Added Health'o'Meter to the tutorial :P
Reply
#47

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

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?
Reply
#49

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.
Reply
#50

Nice tutorial.
Reply
#51

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

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
Reply
#53

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...
Reply
#54

This is cool and useful tut! Thanks
Reply
#55

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

No pictures?
Reply
#57

it only works for one player, why?
Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)