Speed-o-meter Color
#1

Hello everybody.

I have made a basic speed-o-meter by reading tutorial made by a member of SA-MP forums , I wanted to know how to change the color of the Speed-o-meter , I mean the name on the screen , I want the word "speed" to be in Red color .
Could you please tell me how? Here's the code.

pawn Код:
#include <a_samp>

new Float:svx[MAX_PLAYERS]; // Holds Velocity X
new Float:svy[MAX_PLAYERS]; // Holds Velocity Y
new Float:svz[MAX_PLAYERS]; // Holds Velocity Z
new Float:s1[MAX_PLAYERS]; // This Is What Our Forumula Outputs
new s2[MAX_PLAYERS]; // This Is The Output When The Forumula's Ouput Is Round
new s3[MAX_PLAYERS][256]; // This Is The Text That Is Displayed To The User
new Text:sdisplay[MAX_PLAYERS]; // This Holds The Textdraw's ID
new stimer[MAX_PLAYERS]; // This Holds The Timer's ID (Used To Refresh Speed)

forward speedometer(playerid); // This Forwards The Timer To Our Function

public OnFilterScriptInit() { // This Is What Is Excuted When The FilterScript Starts
    print("                                       ");
    print("  -----------------------------------  ");
    print("                                       ");
    print("  Speedometer Filterscript Has Loaded  ");
    print("                                       ");
    print("  -----------------------------------  ");
    print("                                       ");
    return 1;
}

public OnFilterScriptExit() { // This Is What Is Excuted When The FilterScript Ends
    print("                                         ");
    print("  -------------------------------------  ");
    print("                                         ");
    print("  Speedometer Filterscript Has Unloaded  ");
    print("                                         ");
    print("  -------------------------------------  ");
    print("                                         ");
    return 1;
}

public OnPlayerConnect(playerid) {
    sdisplay[playerid] = TextDrawCreate(10.0,200.0,"Speed : "); // This Creates Our Textdraw And Stores The Id In The Varible In Front
    TextDrawSetShadow(sdisplay[playerid],0); // This Removes Our Textdraw's Shadow ( Makes Easier To Read )
    TextDrawSetOutline(sdisplay[playerid],1); // This Adds A Black Outline To Our Textdraw ( Makes Easier To Read )
    TextDrawFont(sdisplay[playerid], 2); // This Changes Our Textdraw's Font ( I Think This Ones Makes It Easier To Read )
    TextDrawShowForPlayer(playerid, sdisplay[playerid]); // This Shows The User The Textdraw
    return 1;
}

public speedometer(playerid) {
    GetVehicleVelocity(GetPlayerVehicleID(playerid), svx[playerid], svy[playerid], svz[playerid]); // This Saves Our Velocitys To Our Varibles
    s1[playerid] = floatsqroot(((svx[playerid]*svx[playerid])+(svy[playerid]*svy[playerid]))+(svz[playerid]*svz[playerid]))*100; // This Is Our Forumula ( I Don't Know How It Works )
    s2[playerid] = floatround(s1[playerid],floatround_round); // This Rounds Our Output To The Nearest Whole Number
    format(s3[playerid],256,"SPEED : %i KM/H", s2[playerid]); // This Format Our Text Into What We See
    TextDrawSetString(sdisplay[playerid], s3[playerid]); // This Changes The Value Of Our Textdraw To What We Formatted
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate) { // This Is The Callback That Is Called When A Person Changes State ( ex States In_Vehicle, Dead, Passenger, Speculating... )
    KillTimer(stimer[playerid]); // This Stops Our Timer For When You Get Out Of Your Vehicle Your Speed Doesn't Keep Going
    TextDrawSetString(sdisplay[playerid], " "); // This Sets Our Textdraw To Blank And Freezes Because We Stop The Timer ^
    if(newstate == 2) stimer[playerid] = SetTimerEx("speedometer", 255, true, "i", playerid); // This Starts The Timer When The Player Changes His/Her State To Being The Driver
    else if(newstate == 3) stimer[playerid] = SetTimerEx("speedometer", 250, true, "i", playerid); // This Start The Timer When The Player Changes His/Her Start To Being The Passenger
    return 1;
}
Reply
#2

After TextDrawCreate...
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++) TextDrawColor(sdisplay[i], 0xFF0000FF);
Reply
#3

under public speedometer(playerid)
TextDrawColor(s3[playerid], 0xFFFFFFAA);
TextDrawColor(s2[playerid], 0xFFFFFFAA);
TextDrawColor(sdisplay[playerid], 0xFFFFFFAA);

The speedometer textdraw is white (choose whatever color you want)
Reply
#4

Okey thank you very much , another and last question , How to make a Damage bar like the speed bar?
Reply
#5

You mean damage of playerhealth? what do you mean?
Reply
#6

Sir , I mean the damage of the vehicle ..I got the speed-o-meter and the damage bar is left , I want it to be:

Damage : 90

Something like this .
Reply
#7

new float:health
new Text:vehhealth
new carid = GetPlayerVehicleID(playerid);

format(health, sizeof(health), "Vehicle health: %d", GetVehicleHealth(carid, health\10));
And then TextDrawCreate etc. like the speedometer (i'm from phone so its hard)
Reply
#8

Quote:

(i'm from phone so its hard)

I would like the full code of it , I will wait for a reply from other member , thank you for trying to help me .
Reply
#9

Bump
Anyone going to tell me the code? i've searched in the tutorial but i have found nothing .
Reply
#10

Quote:
Originally Posted by Axey187
Посмотреть сообщение
Bump
Anyone going to tell me the code? i've searched in the tutorial but i have found nothing .
When i will be at home i will write you the code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)