Need help with /engine
#1

Hello yet again, I need some help with /engine... Here are all the vehicle names that I've got:

pawn Код:
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"
};

GetVehicleModelIDFromName(vname[])
{
    for(new i = 0; i < 211; i++)
    {
        if(strfind(VehicleNames[i], vname, true) != -1)
        return i + 400;
    }
    return 0;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new playermoney;
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new playername[MAX_PLAYER_NAME];
    new cmd[256];
    new tmp[256];
    new giveplayerid, moneys, idx;
    cmd = strtok(cmdtext, idx);

    if (strcmp("/engine", cmdtext, true, 10) == 0)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        new vehiclename = GetVehicleModelIDFromName(vname[]);
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(IsPlayerInAnyVehicle(playerid))
            {
                if(GetPlayerVehicleSeat(playerid) == 0)
                {
                    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
                    if(engine == 1)
                    {
                        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
                        SetVehicleParamsEx(vehicleid,false,lights,alarm,doors,bonnet,boot,objective);
                        format(string, sizeof(string), "%s stops the engine of the %s.", sendername,vehiclename);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        return 1;
                    }
                    else
                    SetVehicleParamsEx(vehicleid,true,lights,alarm,doors,bonnet,boot,objective);
                    format(string, sizeof(string), "%s starts the engine of the %s.", sendername,vehiclename);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                }
                else SendClientMessage(playerid, COLOR_ERROR, "Error: You are not driving the vehicle.");
                return 1;
            }
            else
            SendClientMessage(playerid, COLOR_ERROR, "Error: You are not in a vehicle.");
    }
}
When I come to compile it, the error comes up as:

Quote:

: error 017: undefined symbol "vname"

And that line is:

pawn Код:
new vehiclename = GetVehicleModelIDFromName(vname[]);
I'd appreciate any help, and I'll give a + reputation to the person who can help solve this problem.
Reply
#2

Bump... I really need this :-s.
Reply
#3

It says that the "vname" is unknown.
Have you defined "vname"?
Otherwise, try removing that "vname[]"
Reply
#4

What should I define vname as?
Reply
#5

vname is a parameter string - you need to define it! So the way you use it in a line is this:
pawn Код:
new vehicle;
vehicle = GetVehicleModelIDFromName("Infernus");
if(vehicle != 0)
{
       Use it
}
else
{
       invalid car
}
Reply
#6

I found an alternative, but thanks anyways.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)