01.10.2013, 20:29
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.
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;
}