php GetVehicleName
#1

I know this isn't pawn related, but I've been trying for an Hour and I get get this function right...
PHP код:
$vehiclenames = array(400 =>'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',
    
'Berkleys 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 Maverick',
    
'Rancher',
    
'FBI Rancher',
    
'Virgo',
    
'Greenwood',
    
'Jetmax',
    
'Hotring-Racer A',
    
'Sandking',
    
'Blista',
    
'Police Maverick',
    
'Boxville',
    
'Benson',
    
'Mesa',
    
'RC Goblin',
    
'Hotring-Racer B',
    
'Hotring-Racer C',
    
'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 Truck A',
    
'Monster Truck 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',
    
'RC Cam',
    
'Launch',
    
'Police Car',
    
'Police Car',
    
'Police Car',
    
'Police Ranger',
    
'Picador',
    
'S.W.A.T. Van',
    
'Alpha',
    
'Phoenix',
    
'Broken Glendale',
    
'Broken Sadler',
    
'Luggage Trailer',
    
'Luggage Trailer',
    
'Stair Trailer',
    
'Boxville',
    
'Farm Plow',
    
'Utility Trailer'); 
PHP код:
function GetVehicleName($id) {
        if(!empty(
$id)) {
            return 
$vehiclenames[$id];
        }
        return 
false;
    } 
ATM I am getting: Notice: Undefined variable: vehiclenames
Reply
#2

try
pawn Код:
new vehiclenames = array(400 =>'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',
    'Berkleys 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 Maverick',
    'Rancher',
    'FBI Rancher',
    'Virgo',
    'Greenwood',
    'Jetmax',
    'Hotring-Racer A',
    'Sandking',
    'Blista',
    'Police Maverick',
    'Boxville',
    'Benson',
    'Mesa',
    'RC Goblin',
    'Hotring-Racer B',
    'Hotring-Racer C',
    '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 Truck A',
    'Monster Truck 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',
    'RC Cam',
    'Launch',
    'Police Car',
    'Police Car',
    'Police Car',
    'Police Ranger',
    'Picador',
    'S.W.A.T. Van',
    'Alpha',
    'Phoenix',
    'Broken Glendale',
    'Broken Sadler',
    'Luggage Trailer',
    'Luggage Trailer',
    'Stair Trailer',
    'Boxville',
    'Farm Plow',
    'Utility Trailer');
Reply
#3

i don't know much about php but it seems that the variable scope on PHP is not same like PAWN as stated here: http://php.net/manual/en/language.variables.scope.php

you can try either use 'global' on the array or move the variable array into the function scope as local (the example is on the page link above).

hope that can helps.
Reply
#4

I moved the array into the function scope and it worked, figured it out on my own but thank you Robo.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)