#include <a_samp>
new Text:Textdraw0;
new Text:Textdraw1;
new Float:Velocity [3];
new Vehicles[][] ={
"Landstalker","Bravura","Buffalo","Linerunner","Pereniel","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","ZR3 50","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 A","Hotring Racer B","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","Nevada","Yosemite","Windsor","Monster A","Monster B","Uranus",
"Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight",
"Trailer","Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford",
"BF-400","Newsvan","Tug","Trailer A","Emperor","Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C",
"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 A","Luggage Trailer B",
"Stair Trailer","Boxville","Farm Plow","Utility Trailer" };
public OnFilterScriptInit()
{
print("Speedo-Meter By Littlehelper AKA iKing");
Textdraw0 = TextDrawCreate(39.000000, 134.000000, "Vehicle: Loading");
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.500000, 1.000000);
TextDrawColor(Textdraw0, 16711935);
TextDrawSetOutline(Textdraw0, 1);
TextDrawSetProportional(Textdraw0, 1);
TextDrawUseBox(Textdraw0, 1);
TextDrawBoxColor(Textdraw0, 255);
TextDrawTextSize(Textdraw0, 187.000000, 549.000000);
Textdraw1 = TextDrawCreate(39.000000, 149.000000, "Velocity: Loading");
TextDrawBackgroundColor(Textdraw1, 255);
TextDrawFont(Textdraw1, 1);
TextDrawLetterSize(Textdraw1, 0.500000, 1.000000);
TextDrawColor(Textdraw1, 16711935);
TextDrawSetOutline(Textdraw1, 1);
TextDrawSetProportional(Textdraw1, 1);
TextDrawUseBox(Textdraw1, 1);
TextDrawBoxColor(Textdraw1, -1);
TextDrawTextSize(Textdraw1, 187.000000, 272.000000);
SetTimer("Speed", 1000, true);
return 1;
}
public OnFilterScriptExit()
{
TextDrawHideForAll(Textdraw0);
TextDrawDestroy(Textdraw0);
TextDrawHideForAll(Textdraw1);
TextDrawDestroy(Textdraw1);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
Speed(playerid);
}
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
TextDrawHideForPlayer(playerid, Textdraw0);
TextDrawHideForPlayer(playerid, Textdraw1);
}
return 1;
}
forward Speed(playerid);
public Speed(playerid)
{
new MySpeed[48];
new MyCar[48];
format(MySpeed,sizeof(MySpeed),"Velocity: %d Km/h",GetSpeed(playerid));
format(MyCar,sizeof(MyCar),"Vehicle: %s",Vehicles[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
TextDrawSetString(Textdraw1, MySpeed);
TextDrawSetString(Textdraw0, MyCar);
TextDrawShowForPlayer(playerid, Textdraw0);
TextDrawShowForPlayer(playerid, Textdraw1);
return 1;
}
// Credits To SlashPT For GetsSpeed Stock.
stock
GetSpeed ( playerid , mode = 1 )
{
GetVehicleVelocity ( GetPlayerVehicleID ( playerid ) , Velocity [ 0 ] , Velocity [ 1 ] , Velocity [ 2 ] ) ;
return IsPlayerInAnyVehicle ( playerid ) ? floatround ( ( ( floatsqroot ( ( ( Velocity [ 0 ] * Velocity [ 0 ] ) + ( Velocity [ 1 ] * Velocity [ 1 ] ) + ( Velocity [ 2 ] * Velocity [ 2 ] ) ) ) * ( !mode ? 105.0 : 170.0 ) ) ) * 1 ) : 0;
}
SetTimer("Speed", 1000, true);
forward Speed(playerid);
public Speed(playerid)
{
//....
#include <a_samp>
new PlayerText:SpeedoVehicle[MAX_PLAYERS], PlayerText:SpeedoVelocity[MAX_PLAYERS];
stock const Vehicles[][] ={
"Landstalker","Bravura","Buffalo","Linerunner","Pereniel","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","ZR3 50","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 A","Hotring Racer B","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","Nevada","Yosemite","Windsor","Monster A","Monster B","Uranus",
"Jester","Sultan","Stratum","Elegy","Raindance","RC Tiger","Flash","Tahoma","Savanna","Bandito","Freight",
"Trailer","Kart","Mower","Duneride","Sweeper","Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford",
"BF-400","Newsvan","Tug","Trailer A","Emperor","Wayfarer","Euros","Hotdog","Club","Trailer B","Trailer C",
"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 A","Luggage Trailer B",
"Stair Trailer","Boxville","Farm Plow","Utility Trailer" };
public OnFilterScriptInit()
{
print("Speedo-Meter By Littlehelper AKA iKing");
SetTimer("Speed", 1000, true);
return 1;
}
public OnPlayerConnect(playerid)
{
SpeedoVehicle[playerid] = CreatePlayerTextDraw(playerid, 39.000000, 134.000000, "Vehicle: Loading");
PlayerTextDrawBackgroundColor(playerid, SpeedoVehicle[playerid], 255);
PlayerTextDrawFont(playerid, SpeedoVehicle[playerid], 1);
PlayerTextDrawLetterSize(playerid, SpeedoVehicle[playerid], 0.500000, 1.000000);
PlayerTextDrawColor(playerid, SpeedoVehicle[playerid], 16711935);
PlayerTextDrawSetOutline(playerid, SpeedoVehicle[playerid], 1);
PlayerTextDrawSetProportional(playerid, SpeedoVehicle[playerid], 1);
PlayerTextDrawUseBox(playerid, SpeedoVehicle[playerid], 1);
PlayerTextDrawBoxColor(playerid, SpeedoVehicle[playerid], 255);
PlayerTextDrawTextSize(playerid, SpeedoVehicle[playerid], 187.000000, 549.000000);
SpeedoVelocity[playerid] = CreatePlayerTextDraw(playerid, 39.000000, 149.000000, "Velocity: Loading");
PlayerTextDrawBackgroundColor(playerid, SpeedoVelocity[playerid], 255);
PlayerTextDrawFont(playerid, SpeedoVelocity[playerid], 1);
PlayerTextDrawLetterSize(playerid, SpeedoVelocity[playerid], 0.500000, 1.000000);
PlayerTextDrawColor(playerid, SpeedoVelocity[playerid], 16711935);
PlayerTextDrawSetOutline(playerid, SpeedoVelocity[playerid], 1);
PlayerTextDrawSetProportional(playerid, SpeedoVelocity[playerid], 1);
PlayerTextDrawUseBox(playerid, SpeedoVelocity[playerid], 1);
PlayerTextDrawBoxColor(playerid, SpeedoVelocity[playerid], -1);
PlayerTextDrawTextSize(playerid, SpeedoVelocity[playerid], 187.000000, 272.000000);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
PlayerTextDrawHide(playerid, SpeedoVehicle[playerid]);
PlayerTextDrawDestroy(playerid, SpeedoVehicle[playerid]);
PlayerTextDrawHide(playerid, SpeedoVelocity[playerid]);
PlayerTextDrawDestroy(playerid, SpeedoVelocity[playerid]);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
PlayerTextDrawShow(playerid, SpeedoVehicle[playerid]);
PlayerTextDrawShow(playerid, SpeedoVelocity[playerid]);
}
else if(oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
PlayerTextDrawHide(playerid, SpeedoVehicle[playerid]);
PlayerTextDrawHide(playerid, SpeedoVelocity[playerid]);
}
return 1;
}
forward Speed();
public Speed()
{
static MySpeed[48], MyCar[48], playerstate;
#if defined _FOREACH_LOCAL_VERSION
foreach(Player, playerid){
#else
for(new playerid;playerid<MAX_PLAYERS;playerid++) if(IsPlayerConnected(playerid)){
#endif
playerstate = GetPlayerState(playerid);
if(playerstate == PLAYER_STATE_DRIVER || playerstate == PLAYER_STATE_PASSENGER){
format(MySpeed,sizeof(MySpeed),"Velocity: %d Km/h",GetSpeed(playerid));
format(MyCar,sizeof(MyCar),"Vehicle: %s",Vehicles[GetVehicleModel(GetPlayerVehicleID(playerid))-400]);
PlayerTextDrawSetString(playerid, SpeedoVelocity[playerid], MySpeed);
PlayerTextDrawSetString(playerid, SpeedoVehicle[playerid], MyCar);
}
}
return 1;
}
// Credits To SlashPT For GetsSpeed Stock.
stock
GetSpeed ( playerid , mode = 1 )
{
static Float:Velocity [3];
GetVehicleVelocity ( GetPlayerVehicleID ( playerid ) , Velocity [ 0 ] , Velocity [ 1 ] , Velocity [ 2 ] ) ;
return IsPlayerInAnyVehicle ( playerid ) ? floatround ( ( ( floatsqroot ( ( ( Velocity [ 0 ] * Velocity [ 0 ] ) + ( Velocity [ 1 ] * Velocity [ 1 ] ) + ( Velocity [ 2 ] * Velocity [ 2 ] ) ) ) * ( !mode ? 105.0 : 170.0 ) ) ) * 1 ) : 0;
}
Simple and clear script, but I found some bugs.
I will explain... Look at this: pawn Код:
pawn Код:
The solution is simple, I'm gonna correct your script by myself: pawn Код:
It's obvious that you need 0.3e includes, I can make a version for previous SA-MP versions too. |