Array Problems? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Array Problems? (
/showthread.php?tid=87089)
Array Problems? -
Luciano - 18.07.2009
Hey, I'm having trouble with my FS
![Sad](images/smilies/sad.gif)
. 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
Re: Array Problems? -
Rac3r - 18.07.2009
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;
}
Re: Array Problems? -
Luciano - 18.07.2009
woohoo thanks man!
Re: Array Problems? -
Rac3r - 18.07.2009
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?
Re: Array Problems? -
Westie - 18.07.2009
You could also use enumerations to make your code look better/more organised.