[help] for-loop is " stopping the script"
#1

hi, i got this code in " OnGameModeInit" and for some reason the for loop is stopping the code... ( its doing everything in for loop all the work that it should do... but it aint continuing the code that is found after the for loop.

Код:
	print("All Vehicles were Successfully Spawned!");
  for (new v = 1; v < MAX_VEHICLES; v++)
  {
 		VehicleInfo[v][ID] = v;
		VehicleInfo[v][modelname] = VehicleName[GetVehicleModel(v)-400][0];
		VehicleInfo[v][modelid] = GetVehicleModel(v);
		GetVehiclePos(v,VehicleInfo[v][Xaxis],VehicleInfo[v][Yaxis],VehicleInfo[v][Zaxis]);
		GetVehicleZAngle(v,VehicleInfo[v][Angle]);
    VehicleInfo[v][fuel] = maxfuel;
    format(string,sizeof(string),"Vehicle ID: %d Data had been saved.",v);
    print(string);
	}
	print("All Vehicle data had been stored.");
i got more code.... but there is no need to write it all.... from the function: " print("All Vehicle Data had been stored"); " onwards it don't work.

I was thinking that if there is a for-loop limit.... because in InGameModeInit i got other loop as well but it works for making all skins available.... which it has nothing to do with this one.

Please note when i " commented " this code ( the for loop ) it worked all fine so its something from the for loop i guess

Now i'm using Version: 0.3 RC6-2 ( As server version ) and 0.3 RC6-1 for Client.

Any help?


EDIT:

I debugged it myself and from the result i found out that the problem is from this line:
Код:
		VehicleInfo[v][modelname] = VehicleName[GetVehicleModel(v)-400][0];
anyone can tell me what's wrong with it?

here are the " Vehicle Info " and the " Vehicle name"
Код:
new VehicleName[212][0] = {
  "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", //artict1
  "Previon",
  "Coach",
  "Cabbie",
  "Stallion",
  "Rumpo",
  "RC Bandit",
  "Romero",
  "Packer",
  "Monster Truck",
  "Admiral",
  "Squalo",
  "Seasparrow",
  "Pizzaboy",
  "Tram",
  "Trailer", //artict2
  "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", //hotrina
  "Hotring Racer", //hotrinb
  "Bloodring Banger",
  "Rancher",
  "Super GT",
  "Elegant",
  "Journey",
  "Bike",
  "Mountain Bike",
  "Beagle",
  "Cropdust",
  "Stunt",
  "Tanker", //petro
  "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", //firela
  "Hustler",
  "Intruder",
  "Primo",
  "Cargobob",
  "Tampa",
  "Sunrise",
  "Merit",
  "Utility",
  "Nevada",
  "Yosemite",
  "Windsor",
  "Monster Truck", //monstera
  "Monster Truck", //monsterb
  "Uranus",
  "Jester",
  "Sultan",
  "Stratum",
  "Elegy",
  "Raindance",
  "RC Tiger",
  "Flash",
  "Tahoma",
  "Savanna",
  "Bandito",
  "Freight", //freiflat
  "Trailer", //streakc
  "Kart",
  "Mower",
  "Duneride",
  "Sweeper",
  "Broadway",
  "Tornado",
  "AT-400",
  "DFT-30",
  "Huntley",
  "Stafford",
  "BF-400",
  "Newsvan",
  "Tug",
  "Trailer", //petrotr
  "Emperor",
  "Wayfarer",
  "Euros",
  "Hotdog",
  "Club",
  "Trailer", //freibox
  "Trailer", //artict3
  "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", //bagboxa
  "Luggage Trailer", //bagboxb
  "Stair Trailer", //tugstair
  "Boxville",
  "Farm Plow", //farmtr1
  "Utility Trailer" //utiltr1
};
Код:
enum vInfo
{
	ID,
	modelname[30],
	modelid,
	Float:Xaxis,
	Float:Yaxis,
	Float:Zaxis,
	Float:Angle,
	fuel,
}
new VehicleInfo[MAX_VEHICLES][vInfo];
Reply
#2

You should use a new thing instead of MAX_VEHICLES with the actual number of vehicles you used. It cant get a vehicle model of something that isn't there. MAX_VEHICLES is 2000. So if you spawn 1000 vehicles, vehicle 1001 is going to fail as soon as you try and get any info from it.

Put at the top like.

#undef MAX_VEHICLES
#define MAX_VEHICLES changeme

Replace changeme with the number of vehicles you added. So for example, 30 vehicles, or 150 vehicles, or whatnot.
Reply
#3

ok, i'll try that. thanks
Reply
#4

Nothing to do with 0.3, my guess would be GetVehicleModel(v) returning 0 for vehicles that don't exist.

maybe change it to something like
pawn Код:
print("All Vehicles were Successfully Spawned!");
    new number;
    for (new v = 1; v < MAX_VEHICLES; v++)
    {
        if((VehicleInfo[number][modelid] = GetVehicleModel(v))) {
            VehicleInfo[number][ID] = v;
            strmid(VehicleInfo[number][modelname], VehicleName[VehicleInfo[number][modelid]-400], 0, cellmax, SIZE) // replace SIZE, compiler bug
            GetVehiclePos(number, VehicleInfo[number][Xaxis], VehicleInfo[number][Yaxis], VehicleInfo[number][Zaxis]);
            GetVehicleZAngle(number,VehicleInfo[number][Angle]);
            VehicleInfo[number][fuel] = maxfuel;
            printf("Vehicle ID: %d Data had been saved.", v);
            number++;
        }
    }
    print("Vehicle data for %i vehicles has been stored.", number);
Reply
#5

those 2 didn't work :/
Reply
#6

He's right, when VehicleName[VehicleInfo[number][modelid]-400] is used. If you use GetVehicleModel on a vehicle that doesn't exist, it will equal 0, so VehicleName[(0)-400] Isn't possible.
Reply
#7

but when i made the one you guys said.... but still didn't worked..... stil get stuck there
Reply
#8

lol a vehicle can't be connected.... and i tghuot of that and i couldn't find that function
Reply
#9

just put

pawn Код:
//for blah
if(GetVehicleModel(v) != 0)
//rest of the code
Reply
#10

ok thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)