SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 31/05/2018, 09:23 AM   #1
GTLS
Gangsta
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 817
Reputation: 91
Default Simple Speedo

Simple Speedo


Whats This now?
Its a simple textdraw based Speedo Meter which shows your speed of your vehicle, its model information and server vehicle id.

Why did I do this?
I know, I know people are thinking there are already many speedo available on forums, why another one? Well, This has nothing special To be honest but, I was getting bored and I thought what is it that I could script this fast? I thought of Speedo so I did this. Took me around 30 mins including making textdraws.

Screens:



Here is the Source:
PHP Code:
/*======================[Simple Speedo by GTLS]=====================================*/

#include <a_samp>
#include <zcmd>

//Forwards
forward ShowPlayerSpeedo(playerid);
forward HidePlayerSpeedo(playerid);
forward SpeedoUpdate(playerid);

//TextDraw
new PlayerText:SpeedoTextDraws[7];

new 
SpeedoTimer[MAX_PLAYERS];

public 
OnFilterScriptInit()
{
    print(
"\nSpeed-o-Meter Loaded.");
    return 
1;
}

public 
OnFilterScriptExit()
{
    
printf("\nSpeed-o-Meter Unloaded.");
    return 
1;
}
new 
VehicleNames[212][] = {
   
"Landstalker",  "Bravura",  "Buffalo""Linerunner""Perennial""Sentinel",
   
"Dumper",  "Firetruck" ,  "Trashmaster" ,  "Stretch",  "Manana",  "Infernus",
   
"Voodoo""Pony",  "Mule""Cheetah""Ambulance",  "Leviathan",  "Moonbeam",
   
"Esperanto""Taxi",  "Washington",  "Bobcat",  "Mr Whoopee""BF Injection",
   
"Hunter""Premier",  "Enforcer",  "Securicar""Banshee""Predator""Bus",
   
"Rhino",  "Barracks",  "Hotknife",  "Trailer",  "Previon""Coach""Cabbie",
   
"Stallion""Rumpo""RC Bandit",  "Romero""Packer""Monster",  "Admiral",
   
"Squalo""Seasparrow""Pizzaboy""Tram""Trailer",  "Turismo""Speeder",
   
"Reefer""Tropic""Flatbed","Yankee""Caddy""Solair","Berkley's RC Van",
   
"Skimmer""PCJ-600""Faggio""Freeway""RC Baron","RC Raider","Glendale",
   
"Oceanic""Sanchez""Sparrow",  "Patriot""Quad",  "Coastguard""Dinghy",
   
"Hermes""Sabre""Rustler""ZR-350""Walton",  "Regina",  "Comet""BMX",
   
"Burrito""Camper""Marquis""Baggage""Dozer","Maverick","News Chopper",
   
"Rancher""FBI Rancher""Virgo""Greenwood","Jetmax","Hotring","Sandking",
   
"Blista Compact""Police Maverick""Boxville""Benson","Mesa","RC Goblin",
   
"Hotring Racer""Hotring Racer""Bloodring Banger""Rancher",  "Super GT",
   
"Elegant""Journey""Bike""Mountain Bike""Beagle""Cropdust""Stunt",
   
"Tanker""RoadTrain""Nebula""Majestic""Buccaneer""Shamal",  "Hydra",
   
"FCR-900","NRG-500","HPV1000","Cement Truck","Tow Truck","Fortune","Cadrona",
   
"FBI Truck""Willard""Forklift","Tractor","Combine","Feltzer","Remington",
   
"Slamvan""Blade""Freight""Streak","Vortex","Vincent","Bullet","Clover",
   
"Sadler",  "Firetruck""Hustler""Intruder""Primo""Cargobob",  "Tampa",
   
"Sunrise""Merit",  "Utility Truck",  "Nevada""Yosemite""Windsor",  "Monster",
   
"Monster","Uranus","Jester","Sultan","Stratum","Elegy","Raindance","RCTiger",
   
"Flash","Tahoma","Savanna""Bandito""Freight""Trailer""Kart""Mower",
   
"Dune""Sweeper""Broadway""Tornado""AT-400",  "DFT-30""Huntley",
   
"Stafford""BF-400""Newsvan","Tug","Trailer","Emperor","Wayfarer","Euros",
   
"Hotdog""Club""Trailer""Trailer","Andromada","Dodo","RC Cam""Launch",
   
"Police Car (LSPD)""Police Car (SFPD)","Police Car (LVPD)","Police Ranger",
   
"Picador",   "S.W.A.T. Van",  "Alpha",   "Phoenix",   "Glendale",   "Sadler",
   
"Luggage Trailer","Luggage Trailer","Stair Trailer""Boxville""Farm Plow",
   
"Utility Trailer"
};

stock GetVehicleName(vehicleid//Thanks to Tee
{
    new 
String[25];
    
format(String,sizeof(String),"%s",VehicleNames[GetVehicleModel(vehicleid) - 400]);
    return 
String;
}

LoadSpeedoTextDraws(playerid//Loading TextDraws
{
    
SpeedoTextDraws[0] = CreatePlayerTextDraw(playerid541.250000358.583343"box");
    
PlayerTextDrawLetterSize(playeridSpeedoTextDraws[0], 0.0000001.562500);
    
PlayerTextDrawTextSize(playeridSpeedoTextDraws[0], 540.0000000.000000);
    
PlayerTextDrawAlignment(playeridSpeedoTextDraws[0], 1);
    
PlayerTextDrawColor(playeridSpeedoTextDraws[0], -1);
    
PlayerTextDrawUseBox(playeridSpeedoTextDraws[0], 1);
    
PlayerTextDrawBoxColor(playeridSpeedoTextDraws[0], 8388863);
    
PlayerTextDrawSetShadow(playeridSpeedoTextDraws[0], 0);
    
PlayerTextDrawBackgroundColor(playeridSpeedoTextDraws[0], 255);
    
PlayerTextDrawFont(playeridSpeedoTextDraws[0], 1);
    
PlayerTextDrawSetProportional(playeridSpeedoTextDraws[0], 1);

    
SpeedoTextDraws[1] = CreatePlayerTextDraw(playerid545.000000375.499969"box");
    
PlayerTextDrawLetterSize(playeridSpeedoTextDraws[1], 0.000000, -0.250000);
    
PlayerTextDrawTextSize(playeridSpeedoTextDraws[1], 630.0000000.000000);
    
PlayerTextDrawAlignment(playeridSpeedoTextDraws[1], 1);
    
PlayerTextDrawColor(playeridSpeedoTextDraws[1], -1);
    
PlayerTextDrawUseBox(playeridSpeedoTextDraws[1], 1);
    
PlayerTextDrawBoxColor(playeridSpeedoTextDraws[1], 8388863);
    
PlayerTextDrawSetShadow(playeridSpeedoTextDraws[1], 0);
    
PlayerTextDrawBackgroundColor(playeridSpeedoTextDraws[1], 255);
    
PlayerTextDrawFont(playeridSpeedoTextDraws[1], 1);
    
PlayerTextDrawSetProportional(playeridSpeedoTextDraws[1], 1);

    
SpeedoTextDraws[2] = CreatePlayerTextDraw(playerid540.000000378.416687"box");
    
PlayerTextDrawLetterSize(playeridSpeedoTextDraws[2], 0.0000003.875000);
    
PlayerTextDrawTextSize(playeridSpeedoTextDraws[2], 632.0000000.000000);
    
PlayerTextDrawAlignment(playeridSpeedoTextDraws[2], 1);
    
PlayerTextDrawColor(playeridSpeedoTextDraws[2], -1);
    
PlayerTextDrawUseBox(playeridSpeedoTextDraws[2], 1);
    
PlayerTextDrawBoxColor(playeridSpeedoTextDraws[2], -252645251);
    
PlayerTextDrawSetShadow(playeridSpeedoTextDraws[2], 0);
    
PlayerTextDrawBackgroundColor(playeridSpeedoTextDraws[2], 255);
    
PlayerTextDrawFont(playeridSpeedoTextDraws[2], 1);
    
PlayerTextDrawSetProportional(playeridSpeedoTextDraws[2], 1);

    
SpeedoTextDraws[3] = CreatePlayerTextDraw(playerid538.750000376.083343"");
    
PlayerTextDrawTextSize(playeridSpeedoTextDraws[3], 43.00000036.000000);
    
PlayerTextDrawAlignment(playeridSpeedoTextDraws[3], 1);
    
PlayerTextDrawColor(playeridSpeedoTextDraws[3], -1);
    
PlayerTextDrawSetShadow(playeridSpeedoTextDraws[3], 0);
    
PlayerTextDrawBackgroundColor(playeridSpeedoTextDraws[3], -252645246);
    
PlayerTextDrawFont(playeridSpeedoTextDraws[3], 5);
    
PlayerTextDrawSetProportional(playeridSpeedoTextDraws[3], 0);
    
PlayerTextDrawSetPreviewModel(playeridSpeedoTextDraws[3], 411);
    
PlayerTextDrawSetPreviewRot(playeridSpeedoTextDraws[3], 0.0000000.00000060.0000001.000000);
    
PlayerTextDrawSetPreviewVehCol(playeridSpeedoTextDraws[3], 31);

    
SpeedoTextDraws[4] = CreatePlayerTextDraw(playerid591.250000376.666625"Infernus");
    
PlayerTextDrawLetterSize(playeridSpeedoTextDraws[4], 0.2343741.074999);
    
PlayerTextDrawTextSize(playeridSpeedoTextDraws[4], -44.0000000.000000);
    
PlayerTextDrawAlignment(playeridSpeedoTextDraws[4], 1);
    
PlayerTextDrawColor(playeridSpeedoTextDraws[4], -16776961);
    
PlayerTextDrawSetShadow(playeridSpeedoTextDraws[4], 0);
    
PlayerTextDrawBackgroundColor(playeridSpeedoTextDraws[4], 255);
    
PlayerTextDrawFont(playeridSpeedoTextDraws[4], 1);
    
PlayerTextDrawSetProportional(playeridSpeedoTextDraws[4], 1);

    
SpeedoTextDraws[5] = CreatePlayerTextDraw(playerid603.125000393.583435"65");
    
PlayerTextDrawLetterSize(playeridSpeedoTextDraws[5], 0.2587491.104165);
    
PlayerTextDrawAlignment(playeridSpeedoTextDraws[5], 1);
    
PlayerTextDrawColor(playeridSpeedoTextDraws[5], 41215);
    
PlayerTextDrawSetShadow(playeridSpeedoTextDraws[5], 0);
    
PlayerTextDrawBackgroundColor(playeridSpeedoTextDraws[5], 255);
    
PlayerTextDrawFont(playeridSpeedoTextDraws[5], 1);
    
PlayerTextDrawSetProportional(playeridSpeedoTextDraws[5], 1);

    
SpeedoTextDraws[6] = CreatePlayerTextDraw(playerid560.000000358.583343"0 Mph");
    
PlayerTextDrawLetterSize(playeridSpeedoTextDraws[6], 0.3793751.401666);
    
PlayerTextDrawTextSize(playeridSpeedoTextDraws[6], 655.0000000.000000);
    
PlayerTextDrawAlignment(playeridSpeedoTextDraws[6], 1);
    
PlayerTextDrawColor(playeridSpeedoTextDraws[6], -65281);
    
PlayerTextDrawSetShadow(playeridSpeedoTextDraws[6], 0);
    
PlayerTextDrawBackgroundColor(playeridSpeedoTextDraws[6], 255);
    
PlayerTextDrawFont(playeridSpeedoTextDraws[6], 2);
    
PlayerTextDrawSetProportional(playeridSpeedoTextDraws[6], 1);

}
public 
OnPlayerConnect(playerid)
{
    
SetPVarInt(playerid"SpeedoON"1);
    
SendClientMessage(playerid0xFF00AAFF,"Speedo Enabled. You can use /togspeedo to disable/re-enable it.");
    
LoadSpeedoTextDraws(playerid);
    return 
1;
}

public 
ShowPlayerSpeedo(playerid)
{
    new 
vehname[16],vehid GetPlayerVehicleID(playerid), idstr[4], vehmodel GetVehicleModel(vehid);
    
    
SpeedoTimer[playerid] = SetTimerEx("SpeedoUpdate",1000,1,"i",playerid); //Timer for Updating Speed.

    
    
PlayerTextDrawSetPreviewModel(playeridSpeedoTextDraws[3], vehmodel); //Setting the PreviewModel
    
format(vehnamesizeof(vehname), "%s"GetVehicleName(vehid));
    
format(idstrsizeof(idstr), "%d"vehid);
    
PlayerTextDrawSetString(playeridSpeedoTextDraws[4], vehname); //Setting Vehicle Name
    
PlayerTextDrawSetString(playeridSpeedoTextDraws[5], idstr); //Setting Vehicle ID

    
PlayerTextDrawShow(playeridSpeedoTextDraws[0]);
    
PlayerTextDrawShow(playeridSpeedoTextDraws[1]);
    
PlayerTextDrawShow(playeridSpeedoTextDraws[2]);
    
PlayerTextDrawShow(playeridSpeedoTextDraws[3]);
    
PlayerTextDrawShow(playeridSpeedoTextDraws[4]);
    
PlayerTextDrawShow(playeridSpeedoTextDraws[5]);
    
PlayerTextDrawShow(playeridSpeedoTextDraws[6]);
    return 
1;
}

public 
HidePlayerSpeedo(playerid)
{
    
KillTimer(SpeedoTimer[playerid]); //Killing of Timer
    
    
PlayerTextDrawHide(playeridSpeedoTextDraws[0]);
    
PlayerTextDrawHide(playeridSpeedoTextDraws[1]);
    
PlayerTextDrawHide(playeridSpeedoTextDraws[2]);
    
PlayerTextDrawHide(playeridSpeedoTextDraws[3]);
    
PlayerTextDrawHide(playeridSpeedoTextDraws[4]);
    
PlayerTextDrawHide(playeridSpeedoTextDraws[5]);
    
PlayerTextDrawHide(playeridSpeedoTextDraws[6]);
    return 
1;
}


stock GetVehicleSpeed(vehicleid//Credits someone on SAMP Forums forgot the name
{
    new 
Float:xFloat:yFloat:zvel;

    
GetVehicleVelocity(vehicleidxyz);

    
//vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 );            // KM/H
    
vel floatroundfloatsqrootx*y*z*) * 180 1.60934); // MPH (Comment this line if you want speed in KM

    
return vel;
}

public 
SpeedoUpdate(playerid)
{
    new 
pSpeed[8], vehid GetPlayerVehicleID(playerid);
    
format(pSpeedsizeof(pSpeed), "%i MPH",GetVehicleSpeed(vehid)); //Mph
//    format(pSpeed, sizeof(pSpeed), "%i KMpH",GetVehicleSpeed(vehid)); //KmpH
    
PlayerTextDrawSetString(playeridSpeedoTextDraws[6], pSpeed);
    return 
1;
}

public 
OnPlayerDisconnect(playeridreason)
{
    
KillTimer(SpeedoTimer[playerid]); //Just a Precaution, not needed.
    
return 1;
}

CMD:togspeedo(playeridparams[])
{
    if(
GetPVarInt(playerid"SpeedoON") == 0)
    {
        
SendClientMessage(playerid, -1"You have enabled the Speedo.");
        
SetPVarInt(playerid"SpeedoON"1);
         if(
IsPlayerInAnyVehicle(playerid)) ShowPlayerSpeedo(playerid);
     }
     else
     {
        
SendClientMessage(playerid, -1"You have disabled the Speedo.");
        
SetPVarInt(playerid"SpeedoON"0);
        
HidePlayerSpeedo(playerid);
     }

    return 
1;
}
public 
OnPlayerEnterVehicle(playeridvehicleidispassenger)
{
    if(
GetPVarInt(playerid"SpeedoON") == 0SendClientMessage(playerid, -1"You have disabled Speedo. Use /togspeedo to tog back in.");
    if(
GetPVarInt(playerid"SpeedoON") == 1)
        
ShowPlayerSpeedo(playerid);
    return 
1;
}

public 
OnPlayerExitVehicle(playeridvehicleid)
{
    return 
1;
}

public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(
GetPVarInt(playerid"SpeedoON") == 1)
                
ShowPlayerSpeedo(playerid);
    }

    if(
oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER && newstate == PLAYER_STATE_ONFOOT)
    {
        
HidePlayerSpeedo(playerid);
    }
    return 
1;

GitHub: https://github.com/JimmyKudo-GTLS/SimpleSpeedo

How to Use?
Well, Here are the steps if you dont know how to start.
  1. Copy this code into a blank .pwn file.
  2. You will need zcmd include to compile this. If you use something else, you can modify the command.
  3. Now, this shows Speed in MpH and Kmph what ever you want. If you want to show speed in KMph, comment the line inside GetVehicleSpeed Function and Uncomment a line inside ShowPlayerSpeedo().
  4. Once its compiled, add it to your filterscripts folder and inside your server.cfg
    Code:
    filterscripts Speedo
    .
  5. Thats it! Enter a Vehicle you want and Speedo will work automatically.

Note: This may or may not be 100% Accurate Speed of a vehicle.

Credits:
Kalcor - SAMP
ZCMD - Zeex
adri1 - I used his TextDraw editor.
Credits for Functions are given inside the code.

If you have any problem running this, ask me here.

EDIT: Added Github link which contains, .pwn and .amx.
__________________

I don't help for rep. I help cuz I was helped in the past.


California State Roleplay - X Update Now under beta testing phase. Stay Tuned.

Last edited by GTLS; 04/06/2018 at 10:02 AM. Reason: Added, GitHub download link
GTLS is offline   Reply With Quote
Old 31/05/2018, 09:48 AM   #2
Castiel17
Little Clucker
 
Castiel17's Avatar
 
Join Date: Jun 2017
Location: Norway
Posts: 31
Reputation: 0
Default Re: Simple Speedo

Not bad
__________________
Pawn compiler 3.2.3664 Copyright (c) 1997-2018, ITB CompuPhase
Castiel17 is offline   Reply With Quote
Old 31/05/2018, 09:59 AM   #3
GTLS
Gangsta
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 817
Reputation: 91
Default Re: Simple Speedo

Quote:
Originally Posted by Castiel17 View Post
Not bad
I know this speedo is not the "Ultimate" kind of, but thanks for compliments. Always accepted criticism too.
__________________

I don't help for rep. I help cuz I was helped in the past.


California State Roleplay - X Update Now under beta testing phase. Stay Tuned.
GTLS is offline   Reply With Quote
Old 31/05/2018, 10:10 AM   #4
GeorgeMcReary
Big Clucker
 
Join Date: May 2015
Posts: 161
Reputation: 9
Default Re: Simple Speedo

Oh Nice. Simple and Elegant. +rep. Thanks For Sharing.
__________________
GeorgeMcReary is offline   Reply With Quote
Old 31/05/2018, 10:11 AM   #5
GTLS
Gangsta
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 817
Reputation: 91
Default Re: Simple Speedo

Quote:
Originally Posted by GeorgeMcReary View Post
Oh Nice. Simple and Elegant. +rep. Thanks For Sharing.
Thanks Buddy.
__________________

I don't help for rep. I help cuz I was helped in the past.


California State Roleplay - X Update Now under beta testing phase. Stay Tuned.
GTLS is offline   Reply With Quote
Old 31/05/2018, 10:34 AM   #6
XXpro
Little Clucker
 
Join Date: May 2018
Posts: 20
Reputation: 0
Default Re: Simple Speedo

Nice Nice keep it up
XXpro is offline   Reply With Quote
Old 31/05/2018, 10:52 AM   #7
SkmDanny
Little Clucker
 
SkmDanny's Avatar
 
Join Date: Nov 2017
Location: Romania
Posts: 32
Reputation: 0
Default Re: Simple Speedo

Nice. Is simple.
__________________
[Tool/Web/Other] User Control Panel - Live Demo
SkmDanny is offline   Reply With Quote
Old 31/05/2018, 04:37 PM   #8
GTLS
Gangsta
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 817
Reputation: 91
Default Re: Simple Speedo

Thanks to everyone.
__________________

I don't help for rep. I help cuz I was helped in the past.


California State Roleplay - X Update Now under beta testing phase. Stay Tuned.
GTLS is offline   Reply With Quote
Old 01/06/2018, 04:54 AM   #9
GeorgeMcReary
Big Clucker
 
Join Date: May 2015
Posts: 161
Reputation: 9
Default Re: Simple Speedo

Umm okay, Can we use this not as a fs but part of gm?
__________________
GeorgeMcReary is offline   Reply With Quote
Old 01/06/2018, 05:10 AM   #10
GTLS
Gangsta
 
GTLS's Avatar
 
Join Date: Aug 2014
Location: India
Posts: 817
Reputation: 91
Default Re: Simple Speedo

Quote:
Originally Posted by GeorgeMcReary View Post
Umm okay, Can we use this not as a fs but part of gm?
Yeah sure you can. You will just have to adjust your variables and all.
__________________

I don't help for rep. I help cuz I was helped in the past.


California State Roleplay - X Update Now under beta testing phase. Stay Tuned.
GTLS 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] Simple Speedo + Fuel System sabretur Filterscripts 24 01/03/2013 02:19 PM
[FilterScript] Simple fixed speedo oscar7610 Filterscripts 2 02/05/2012 11:17 PM
Simple Speedo/Fuel System Ash. Help Archive 2 27/07/2010 07:17 AM
Trying to script a simple speedo Jake Canfield Help Archive 2 29/09/2009 05:06 AM
[FilterScript] [FS] Simple Speedo - Coded by Kaleem Klid Filterscripts 20 19/09/2009 01:23 PM


All times are GMT. The time now is 02:40 PM.


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