SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 11/07/2012, 08:13 PM   #1
Karagon
Big Clucker
 
Karagon's Avatar
 
Join Date: Feb 2011
Location: United States
Posts: 85
Reputation: 51
Default kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED)

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:
Code:
//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.
__________________
Karagon is offline   Reply With Quote
Old 11/07/2012, 08:26 PM   #2
'seraphin
Huge Clucker
 
'seraphin's Avatar
 
Join Date: May 2012
Location: Pawn je me perds Reputation : 3876
Posts: 220
Reputation: 7
Default Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED)

Good wOrk
'seraphin is offline   Reply With Quote
Old 15/07/2012, 09:06 AM   #3
Gamer_007
Gangsta
 
Gamer_007's Avatar
 
Join Date: Dec 2011
Location: Connecting...
Posts: 672
Reputation: 11
Default Respuesta: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED)

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

btw nice fs
Gamer_007 is offline   Reply With Quote
Old 15/07/2012, 09:17 AM   #4
Robert West
Banned
 
Join Date: Apr 2012
Location: Tunisia
Posts: 222
Reputation: 15
Default Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED)

Good , but the speed is always 0 ?
Robert West is offline   Reply With Quote
Old 15/07/2012, 04:12 PM   #5
shayan122
Big Clucker
 
shayan122's Avatar
 
Join Date: May 2011
Location: Iran
Posts: 175
Reputation: 16
Default Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED)

seems nice
shayan122 is offline   Reply With Quote
Old 17/07/2012, 04:43 PM   #6
Karagon
Big Clucker
 
Karagon's Avatar
 
Join Date: Feb 2011
Location: United States
Posts: 85
Reputation: 51
Default Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED)

Quote:
Originally Posted by Robert West View Post
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:
Code:
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:

Code:
	    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:
Code:
		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".
__________________
Karagon is offline   Reply With Quote
Old 17/07/2012, 07:51 PM   #7
Koske
Big Clucker
 
Join Date: Jul 2012
Posts: 71
Reputation: 7
Default Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED)

Can you send us a pic what it looks like?
Koske is offline   Reply With Quote
Old 19/07/2012, 02:33 AM   #8
Karagon
Big Clucker
 
Karagon's Avatar
 
Join Date: Feb 2011
Location: United States
Posts: 85
Reputation: 51
Default Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED)

Quote:
Originally Posted by Koske View Post
Can you send us a pic what it looks like?


They are already in the topic - I posted it with them.
__________________
Karagon is offline   Reply With Quote
Old 19/07/2012, 06:28 AM   #9
Robert West
Banned
 
Join Date: Apr 2012
Location: Tunisia
Posts: 222
Reputation: 15
Default Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED)

Nice work
Robert West is offline   Reply With Quote
Old 19/07/2012, 06:52 AM   #10
Igi_Guduric
Big Clucker
 
Igi_Guduric's Avatar
 
Join Date: Jul 2012
Posts: 101
Reputation: 10
Default Re: kSpeedo - Speedometer with Health, Fuel, and Vehicle Name (COLOR CODED)

Good work.
Igi_Guduric is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Vehicle System (Name, Speed, Fuel, Health)! Luka P. Filterscripts 90 14/07/2014 07:30 PM
[FilterScript] kSpeedo [Simple Speedometer] v1.0 Kammer Filterscripts 5 18/07/2011 07:27 PM
Vehicle|Speed|Health|Fuel Kyle Help Archive 8 14/12/2010 08:02 PM
[FilterScript] [FS] Backwards's Vehicle System - Speedometer and Vehicle Health- Backwardsman97 Filterscripts 34 07/08/2009 01:37 PM
[FilterScript] [FS] Backwards's Vehicle System - Speedometer and Vehicle Health- Backwardsman97 Filterscripts 7 06/08/2009 10:52 AM


All times are GMT. The time now is 03:37 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.