SA-MP Forums Archive
Limiting speedometer for cars - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Limiting speedometer for cars (/showthread.php?tid=310401)



Limiting speedometer for cars - Abreezy - 12.01.2012

How can I limit the speed it says for certain cars?

Like I don't want a BMX bike saying it goes 55 mph. and Maybe i'd like to make max speed like 180 or so. Is this possible? Thanks in advance. Yes I have a speedometer, and if some of the code is needed, feel free to say so.


Re: Limiting speedometer for cars - Steven82 - 12.01.2012

Well get the vehicle model id's and then make the speedometer not show for them. Like OnPlayerStateChange when they get on the bike, just have it not show.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new
        vehicleid = GetPlayerVehicleID(playerid),
        modelid = GetPlayerVehicleModel(vehicleid);
    //
    if(modelid == /* bike id */ || /* another bike id*/ || /* and so fourth */)
        return TextDrawHideForPlayer(playerid, SpeedoTD[playerid]);
    /*
    The rest of your Speedo and OnPlayerStateChange code here. Hopefully you know what i
    mean.
    */

    return 1;
}
I know this isn't your exact coding but i hope it helps.


Re: Limiting speedometer for cars - Abreezy - 12.01.2012

Alright thanks for that, for other question though, how can you limit speed on a vehicle? Like i want it to not pass 120 for like stratum or so.


Re: Limiting speedometer for cars - Gamer_Z - 12.01.2012

http://*******/Vh4Nu

first result...

https://sampforum.blast.hk/showthread.php?tid=179089


Re: Limiting speedometer for cars - Abreezy - 12.01.2012

I didn't ask for limiting speed literally, I want the number showing on the speedometer limited..


Re: Limiting speedometer for cars - Gamer_Z - 12.01.2012

Quote:
Originally Posted by Abreezy
Посмотреть сообщение
I didn't ask for limiting speed literally, I want the number showing on the speedometer limited..
if(speed > 500.0)TextDrawSetString(td,"Your speed is 500");
else
TextDrawSetString(td,"Your speed is <GetPlayerSpeed>...");


Re: Limiting speedometer for cars - Abreezy - 12.01.2012

Still not really want i wanted lol, Sorry If what i'm saying it complicated or not understandable.

Let's say i'm driving a sultan. I don't want the speedo to say anything faster then like 160 for it. Let's say I'm driving an infernus, I don't want it to say anything faster then like 185. If i'm driving a bobcat, I wouldn't want it to say anything faster then like 80, understand now?


Re: Limiting speedometer for cars - Gamer_Z - 12.01.2012

pawn Код:
#include <a_samp>

enum Speedo_Veh
{
    Speedo_vehicleName[32],
    Float:Speedo_MaxSpeed
};

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

public OnFilterScriptInit()
{
    new vehiclemodelid = 411;
    printf("The vehicle %s has a speed limit of %f",GetVehicleName(vehiclemodelid),GetVehicleMaxSpeed(vehiclemodelid));
    //TD update code
    new Float:CurrentVehicleSpeed = 55.0;
    new TDstring[32];
    new Text:SpeedoTD = Text:INVALID_TEXT_DRAW;
    //get the speed etc blablabla
    if(GetVehicleMaxSpeed(vehiclemodelid) > CurrentVehicleSpeed)
    {
        format(TDstring,32,"Vehicle Speed: %.f",GetVehicleMaxSpeed(vehiclemodelid));
    }
    else
    {
        format(TDstring,32,"Vehicle Speed: %.f",CurrentVehicleSpeed);
    }
    TextDrawSetString(SpeedoTD,TDstring);
    return 1;
}

stock GetVehicleName(modelid)
{
    return Speedo_aVehicleNS[modelid-400][Speedo_vehicleName];
}

forward Float:GetVehicleMaxSpeed(modelid);
stock Float:GetVehicleMaxSpeed(modelid)
{
    return Speedo_aVehicleNS[modelid-400][Speedo_MaxSpeed];
}
should do the trick.