Array Problems?
#1

Hey, I'm having trouble with my FS . It is supposed to spawn the vehicles in the array (vehicles) with the params in the array and set the vehicle's virtual world to #1.


Here is the main function, that makes the vehicles and puts it into the vehicles into vworld #1:
Код:
public OnFilterScriptInit()
{
    for(new i=0;i<sizeof(vehicles);i++)
	{
	  AddStaticVehicle(vehicles[i][0],vehicles[i][1],vehicles[i][2],vehicles[i][3],vehicles[i][4],-1,-1);
      SetVehicleVirtualWorld(vehicles[i],1);
	}
	return 1;
}
Here is the array:
Код:
new Float:vehicles[2][5] = {
{556,388.4015,2537.7161,16.9140,179.3938},
{519,404.4426,2452.0791,17.4188,0.4300}
};
And here are the errors:
Код:
C:\Documents and Settings\Micah\Desktop\roleplay.pwn(27) : warning 213: tag mismatch
C:\Documents and Settings\Micah\Desktop\roleplay.pwn(28) : warning 213: tag mismatch
C:\Documents and Settings\Micah\Desktop\roleplay.pwn(45) : warning 213: tag mismatch
C:\Documents and Settings\Micah\Desktop\roleplay.pwn(46) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Any suggestions? Can anyone explain this error to me? I get it alot of times but never understand what it means.

Thanks,
Luciano
Reply
#2

You are using the ModelID as a float.

Код:
new Float:vehicles[2][4] = {
{388.4015,2537.7161,16.9140,179.3938},
{404.4426,2452.0791,17.4188,0.4300}
};
new vehiclesModel[2][1] = {
{556},
{519}
};
public OnFilterScriptInit()
{
	for(new i=0;i<sizeof(vehicles);i++)
	{
	  new Temp;
		CreateVehicle(vehiclesModel[i][0],vehicles[i][0],vehicles[i][1],vehicles[i][2],vehicles[i][3],-1,-1,5000);
		SetVehicleVirtualWorld(Temp,1);// also using the array number, would make vehicleid 0 the car you are changing the world of, but maybe cars have been created before?
	}
	return 1;
}
Reply
#3

woohoo thanks man!
Reply
#4

Ooops, I did it wrong.
Код:
		new Temp;
		Temp=CreateVehicle(vehiclesModel[i][0],vehicles[i][0],vehicles[i][1],vehicles[i][2],vehicles[i][3],-1,-1,5000);
		SetVehicleVirtualWorld(Temp,1);// also using the array number, would make vehicleid 0 the car you are changing the world of, but maybe cars have been created before?
Reply
#5

You could also use enumerations to make your code look better/more organised.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)