Small Quest. - 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: Small Quest. (
/showthread.php?tid=73511)
Small Quest. -
BioFreeze - 15.04.2009
After a long time doing nothing related to the scripting scene , I decided to do some little stuff again. And a after a while something bugged me.
For example , you want to add a 10 vehicles , assigned to a team or whatever.
Код:
new teamcars[10]; // at start
Код:
teamcar[1] = AddStaticVehicleEx // at ongamemode init
teamcar[2] = AddStaticVehicleEx
etc
etc
Afterwards you only want a certain team to enter these cars.
Код:
if(vehicleid == teamcar[1] || vehicleid == teamcar[1] ) // at public OnPlayerEnterVehicle
{
// check team here
else
{
// kick wrong out
}
}
This goes all without any problems.
Now the question is how would I be able to check teamcar[1] till teamcar[10] , without calling them separtely each time ( like vehicleid == teamcar[1] || vehicleid == teamcar[2] || etc )
Maybe the answer is simple , but I never tried something like this , I just want to simplify code.
Doing this with carids is rather simple ;
Код:
if((carid >= 61) && (carid <= 63)
Doing this with my code is something different.
Re: Small Quest. -
Sandra18[NL] - 15.04.2009
Код:
for(new i=0; i<10; i++)
{
if(vehicleid == teamcars[i])
{
//The vehicle is a teamcar
//rest of code
break; //This stops the loop
}
}
Re: Small Quest. -
BoRg4LiFe - 21.04.2009
sandra can you please give an example of
for(new i=0; i<2; i++)
{
if(vehicleid == teamcars[i])
{
//The vehicle is a teamcar
//rest of code
break; //This stops the loop
}
}
Thanks
Re: Small Quest. -
BioFreeze - 09.05.2009
Код:
public IsAPoliceCar(vehicleid)
{
for(new i=0; i<35; i++)
{
if(vehicleid == copv[i])
{
break;
}
}
return 1;
}
This code should see copv[1] etc etc till copv[34] as a copcar. Instead of that , it sees all cars as a copcar. Where does it go wrong ?