[NEED HELP] vehicle names
#1

i got a small script
can you see what is wrong with it
the script should show the car name when the player enters the car
BUT
its showing Landstalker on entering any vehicle

pawn Код:
new VehicleNames[][] =
{
  "Landstalker", "Bravura", "Buffalo", "Linerunner", "Perrenial", "Sentinel", "Dumper", "Firetruck", "Trashmaster",
  "Stretch", "Manana", "Infernus", "Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam",
  "Esperanto", "Taxi", "Washington", "Bobcat", "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",
  "Boxvillde", "Benson", "Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher",
  "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropduster", "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", "Monster",
  "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito",
  "Freight Flat", "Streak Carriage", "Kart", "Mower", "Dune", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30",
  "Huntley", "Stafford", "BF-400", "News Van", "Tug", "Trailer", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club",
  "Freight Box", "Trailer", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car", "Police Car", "Police Car",
  "Police Ranger", "Picador", "S.W.A.T", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage", "Luggage", "Stairs",
  "Boxville", "Tiller", "Utility Trailer"
};

new curPlayerVehM[MAX_PLAYERS];
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new string[50];
    for(new i = 0; i < MAX_PLAYERS; i++)
  format(string, sizeof(string), "%s", VehicleNames[GetVehicleModel(GetPlayerVehicleID(i))-400]);
  GameTextForPlayer(playerid, string, 17500, 1);
   
    return 1;
}
any ideas on whats wrong?
Reply
#2

why your using a loop, remove the loop and replace i with playerid.
Reply
#3

Yeah get rid of the loop and change this:

Код:
VehicleNames[GetVehicleModel(GetPlayerVehicleID(i)) - 400]
to this:

Код:
VehicleNames[GetVehicleModel(vehicleid) - 400]
That won't make it work but it makes it a whole lot clearer and you don't have that pointless loop there.

Also shouldn't -400 be -399?? Because if you have a vehicle with modelid 401 then 401 - 400 refers to the 1st name in VehicleNames...which is the "LandStalker". But I'm not sure.
Reply
#4

no use this:

pawn Код:
VehicleNames[GetVehicleModel(GetPlayerVehicleID(playerid))-400]
instead of

pawn Код:
VehicleNames[GetVehicleModel(GetPlayerVehicleID(i))-400]
Reply
#5

Код:
GetVehicleModel(GetPlayerVehicleID(playerid))
GetPlayerVehicleID(playerid) here will just return the same value as vehicleid in the OnPlayerEnterVehicle callback...
So GetVehicleModel(vehicleid) will give the same result as this, it's just prettier.
Reply
#6

Quote:
Originally Posted by lol2112
Код:
GetVehicleModel(GetPlayerVehicleID(playerid))
GetPlayerVehicleID(playerid) here will just return the same value as vehicleid in the OnPlayerEnterVehicle callback...
So GetVehicleModel(vehicleid) will give the same result as this, it's just prettier.
The player is not in a vehicle when he enter a vehicle and yes you must use VehicleNames[GetVehicleModel(vehicleid)-400].
Reply
#7

True but if you look at the parameters of the callback:

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
You can use the parameter vehicleid and it will still return the id of the vehicle the player is trying to get into, even they don't manage it. It's a bad idea to make this script using this callback because it'll display the gametext before you're in the vehicle. Use OnPlayerStateChange instead.
Reply
#8

Quote:
Originally Posted by lol2112
True but if you look at the parameters of the callback:

Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
You can use the parameter vehicleid and it will still return the id of the vehicle the player is trying to get into, even they don't manage it. It's a bad idea to make this script using this callback because it'll display the gametext before you're in the vehicle. Use OnPlayerStateChange instead.
+1!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)