SA-MP Forums Archive
[FilterScript] kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) (/showthread.php?tid=358810)

Pages: 1 2


kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Karagon - 11.07.2012

kSpeedo
Karagon's Speedometer System - Version 1.0


Features:
-4 Part Speedometer Filterscript
-Displays Vehicle name, fuel level, damage level, and speed (KM/H)
-Fuel Level and damage level changes colors in relation to the level of that value. (Green -> Yellow -> Red)
-Changeable settings found at the top of the script (Some are recommended not to be changed, but you can change them at your own risk)

How to install:
1) Download the package at the end of this post.
2) Change the definition of MAX_PLAYERS at the top of the script. The default I have set is 200. If you require more players in your server, change it. If you require less, change it.
3) Compile the script.
4) Put it in your Filterscripts directory in your server directory.
5) Add it to server.cfg as "filterscripts kSpeedo" if you want it loaded when the server starts, or, load it via RCON commands in the game (/rcon login first, then /rcon loadfs kSpeedo)
6) Enter a vehicle and enjoy.

Definition Explanation
The following defines are in the script for your use:
Код:
//This is stuff that you can change.
#define DEF_GAS             	(100) //Default gas level for the vehicles in the server when the filterscript is loaded. (DEFAULT: 100)
#define DISTANCE            	(250) //Distance in which FUEL_INCREMENT will be removed from the fuel (DEFAULT: 250)
#define FUEL_INCREMENT      	(1) //The value that will be removed from the fuel when DISTANCE is met. (DEFAULT: 1)
#define TEXT_DRAW_FONT      	(2) //Font for the text draw. It's recomended that you not change this. (DEFAULT: 2)
#define TEXT_DRAW_X_FACTOR  	(0.4) // Font size X factor (DEFAULT: 0.4) (RECOMENDED NOT TO CHANGE)
#define TEXT_DRAW_Y_FACTOR  	(0.8) // Font size Y factor (DEFAULT: 0.8) (RECOMENDED NOT TO CHANGE)
#define EXIT_VEHICLE_ON_NO_GAS  (true) // If the player should exit the vehicle when the fuel is 0, set this true.
#define WARNING                 (20) // Number at which to send a warning to the player. (DEFAULT: 20)
#define WARNING_LIMIT           (10000) // Time to wait before sending another message about low fuel. (DEFAULT: 10000)
-DEF_GAS is the default gas for each vehicle you have in your server when the Filter script loads.
-DISTANCE is the distance in which the FUEL_INCREMENT will be subtracted from the car's fuel level.
-TEXT_DRAW_FONT is the font for the text draw. It's not recommended to change this unless you want to redo the TEXT_DRAW_X_FACTOR and TEXT_DRAW_Y_FACTOR
-EXIT_VEHICLE_ON_NO_GAS is the definition that controls if the player will be forced out of the vehicle when the fuel level is at 0 or less than 0. True if you want it to, false if not. You can edit the part of the script when this is used.
-WARNING is the gas level in which a warning will be given to the player.
-WARNING_LIMIT determines how often a message will be sent to the user. I find 10,000 to be decent, non-spammy.

Notes
-This uses OnPlayerUpdate for the speedometer. I know some people do not like it to be used this way, but wish such a small amount of code, I've decided to use this. But, if you experience some lag issues, change it to a 1 to a 1.5 (maybe 2 second) timer for the server. I won't help with this, as this is how I am releasing it. How I release it is how I'll leave it. Don't contact me to help you change any thing to the script.
-The stock functions, and public functions, if changed, I am not responsible for it. It's your mistake if you mess it up, so make sure you know what you're doing when you mess with it.
-It is recommended that you load this into your main GM, IF you have an admin command for players to spawn vehicles, or vehicles spawn in the GM. (If you don't, the fuel will be 0 for all vehicles that spawn)
-Leave the command text in the script. This is for credits. Don't remove them if you use the script. (Thanks )
-Feel free to play with the display, but leave the credits.
-YOU make the gas stations.

Credits:
-Karagon for the script.

Disclaimer
This is an original idea. You may see similar speedometers in the SA-MP world, and this is a 100% original work by me. I originally made it for a server I was creating, but after a few things, I've decided not to open that server, so I'm releasing a few things I made for it. (This may be the only one for right now related to this script). Work on this started about a week ago.

Pictures:
One
Two
Three
Four
Five



Downloads
Dropbox Link
*Note: By Downloading, you agree to keep my name in the credits, and not to re-upload it, and that you will not consider it yours in any way.
No mirrors, please.


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - 'seraphin - 11.07.2012

Good wOrk


Respuesta: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Gamer_007 - 15.07.2012

gud work but if u make car health and fuel in 3dlabel iw will be more nice

btw nice fs


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Robert West - 15.07.2012

Good , but the speed is always 0 ?


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - shayan122 - 15.07.2012

seems nice


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Karagon - 17.07.2012

Quote:
Originally Posted by Robert West
Посмотреть сообщение
Good , but the speed is always 0 ?

I tested this exact code and it never shows speed always 0. If that's the case, then you may have not used it right, and/or put it into a script without putting all of it in.

There's one thing you can check for, though.

This one variable here:
Код:
new Float:PlayerPos[3][MAX_PLAYERS]; //Holds the player's last posistion.
Is the magic in all of this.

Make sure of the following:

OnPlayerUpdate:

Код:
	    new Float:x, Float:y, Float:z;
	    GetPlayerPos(playerid, x, y, z);
	    format(string, sizeof(string), "Gas: ~%s~%d \%", FuelColor(vid), CarFuel[vid]);
	    TextDrawSetString(speedo4[playerid], string);
	    new distance = GetDistance(x, y, z, PlayerPos[0][playerid], PlayerPos[1][playerid], PlayerPos[2][playerid]);
	    PlayerPos[0][playerid] = x;
	    PlayerPos[1][playerid] = y;
	    PlayerPos[2][playerid] = z;
Make sure you are setting the variables.


And, OnPlayerStateChange, when the player enters a vehicle:
Код:
		new Float:x, Float:y, Float:z;
		GetPlayerPos(playerid, x, y, z);
		PlayerPos[0][playerid] = x;
		PlayerPos[1][playerid] = y;
		PlayerPos[2][playerid] = z;
Make sure that is used to prevent a large jump from (0,0,0)

3D text labels weren't done because I feel that a Text Draw for a speedometer is a better idea than the 3D text label, even connected to a vehicle. You're free to do it that way for your personal use, but I'm not going to do it.

And, as a note, I'm going to use this Speedo in my next GM - a San Fierro "Light Role Play".


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Koske - 17.07.2012

Can you send us a pic what it looks like?


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Karagon - 19.07.2012

Quote:
Originally Posted by Koske
Посмотреть сообщение
Can you send us a pic what it looks like?

They are already in the topic - I posted it with them.


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Robert West - 19.07.2012

Nice work


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Igi_Guduric - 19.07.2012

Good work.


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Plovix - 19.07.2012

Awesome filterscript,nice work


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - $$inSane - 19.07.2012

its good but a box textdraw, it will look more good


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - jimbo8 - 23.07.2012

Works perfectly, but how do i refuel?


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Cypress - 23.07.2012

Since when cars are using gas?


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Plovix - 23.07.2012

Nice work man


Respuesta: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - [Nikolay] - 26.07.2012

Pics please!


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - xxXSniperShotXxx - 24.12.2012

How do we make gas stations?


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Xlithan - 13.01.2013

How can I convert this to MPH?


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - DLR - 11.02.2013

Anybody using this FilterScript, add this...

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    //Hide all the text draws for the player
    TextDrawHideForPlayer(playerid, speedo1[playerid]);
    TextDrawHideForPlayer(playerid, speedo2[playerid]);
    TextDrawHideForPlayer(playerid, speedo3[playerid]);
    return 1;
}
It will clear the speedo if a player dies whilst inside a vehicle. I've made it so that passengers don't see the speedo, so if your passengers can see the speedo, you'll need to add a similar script, to check if the player was ejected from the vehicle, or teleported away.


Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED) - Spawe - 09.10.2018

Resume the link pls