SA-MP Forums Archive
/car command again!!!! - 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: /car command again!!!! (/showthread.php?tid=353614)



/car command again!!!! - Swyft™ - 23.06.2012

ALL FIXED I FIGURED IT OUT!!!!!

THANKS FOR THE POSTS, THIS CAN BE DELETED OR LOCKED!


Re: /car command again!!!! - phillip875 - 23.06.2012

Firstly, you would need to make static name so here is an example:

pawn Код:
CMD:car(playerid,params[])
{
    if(DMZone[playerid] == 0)
    {
        new Float:x,Float:y,Float:z,Float:q,string[70];
        static buffalo[12],input[12];
        format(buffalo,sizeof(buffalo),"buffalo");
        if(sscanf(params,"s",input)) return SendClientMessage(playerid,-1,"Usage: /car [name]");
        GetPlayerPos(playerid,x,y,z);
        if(strcmp(buffalo,input,true) == 0)
        {
            CreateVehicle(402, x,y,z,q, 0, 0, 30);
            format(string,sizeof(string),"Car id = 402 - Color = 0 - color2 = 0");
            SendClientMessage(playerid,-1,string);
        }
    }
    return 1;
}



Re: /car command again!!!! - FUNExtreme - 23.06.2012

Use the search function please! The forum is full of this and it is fairly easy to find


Re: /car command again!!!! - Swyft™ - 23.06.2012

Well I am having no luck, mind helping me out


Re: /car command again!!!! - phillip875 - 23.06.2012

Like I showed above, you would need to compare the input using strcmp.

So you would format a option such as buffalo.

pawn Код:
static buffalo[12],input[12];
format(buffalo,sizeof(buffalo),"buffalo");
if(strcmp(buffalo,input,true) == 0)
{
    // action here..
}



Re: /car command again!!!! - Swyft™ - 23.06.2012

I want it to work for all vehicles.. ur making no sense to me dude i dont want to keep making 10 lines for 1 vehicle


Re: /car command again!!!! - Swyft™ - 24.06.2012

I need someone to help me please!!!!


Re: /car command again!!!! - milanosie - 24.06.2012

Imma help you tomorrow on one promise:

STOP bumping topics every 2 hours,


Re: /car command again!!!! - Dubya - 24.06.2012

pawn Код:
static const VehicleName[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 Racer","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","Cropduster","Stuntplane","Tanker","Road Train","Nebula","Majestic",
    "Buccaneer","Shamal","Hydra","FCR-900","NRG-500","HPV-1000","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","Emperor","Wayfarer",
    "Euros","Hotdog","Club","Trailer","Trailer","Andromada","Dodo","RCCam","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"
};

CMD:carname(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 1) // Edit this out if you like.
    {
        SendClientMessage(playerid, COLOR_YELLOW, "--------------------------------------------------------------------------------------------------------------------------------");
        SendClientMessage(playerid, COLOR_WHITE, "Vehicle Search:");
        new string[128];
        if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "No keyword specified.");
        if(!params[2]) return SendClientMessage(playerid, COLOR_GREY, "Search keyword too short.");
        for(new v; v < sizeof(VehicleName); v++)
        {
            if(strfind(VehicleName[v], params, true) != -1)
            {
                if(isnull(string)) format(string, sizeof(string), "%s (ID: %d)", VehicleName[v], v+400);
                else format(string, sizeof(string), "%s | %s (ID: %d)", string, VehicleName[v], v+400); // Show's the car's ID and Name.
            }
        }
        if(!string[0]) SendClientMessage(playerid, COLOR_GREY, "No results found.");
        else if(string[127]) SendClientMessage(playerid, COLOR_GREY, "Too many results found.");
        else SendClientMessage(playerid, COLOR_WHITE, string);

        SendClientMessage(playerid, COLOR_YELLOW, "--------------------------------------------------------------------------------------------------------------------------------");
    }
    return 1;
}
// Then Your Command:
CMD:car(playerid,params[])
{
    if(DMZone[playerid] == 0)
    {
        new Float:x,Float:y,Float:z,Float:q,string[70];
        static buffalo[12],input[12];
        format(buffalo,sizeof(buffalo),"buffalo");
        if(sscanf(params,"s",input)) return SendClientMessage(playerid,-1,"Usage: /car [name]");
        GetPlayerPos(playerid,x,y,z);
        if(strcmp(buffalo,input,true) == 0)
        {
            CreateVehicle(402, x,y,z,q, 0, 0, 30);
            format(string,sizeof(string),"Car id = 402 - Color = 0 - color2 = 0");
            SendClientMessage(playerid,-1,string);
        }
    }
    return 1;
}



Re: /car command again!!!! - Swyft™ - 24.06.2012

I actually managed to get it to work.. the only issue is, when I spawn /car infernus it spawns an infernus but on some cars like /car elegy it spawns a Windsor... I did delete some vehicles in the list i have.... but they were armed vehicles or planes and etc... And if I add them in then everyone gets access to those vehicles and can dm the shit outa my stunt server