Multiple vehicles in 1 variable -
sim_sima - 07.04.2011
Hi guys.
Is it possible to make multiple vehicles in 1 variable?
i did like this, but it doesnt work:
pawn Код:
new truck = {
AddStaticVehicle(403,1697.2108,1057.6760,11.4450,180.6527,25,1), // Truck1
AddStaticVehicle(514,1692.2650,1056.6304,11.4086,180.6328,36,1), // Truck2
AddStaticVehicle(514,1687.1963,1056.7150,11.4078,179.3409,113,1), // Truck3
AddStaticVehicle(403,1671.1423,1085.4607,11.4273,180.2388,30,1), // Truck4
AddStaticVehicle(514,1665.7838,1084.3821,11.4078,180.4213,25,1), // Truck5
AddStaticVehicle(515,1659.8749,1084.6716,11.8436,179.6213,54,77), // Truck6
AddStaticVehicle(403,1631.0760,1057.6670,11.4274,269.9039,36,1), // Truck7
AddStaticVehicle(515,1631.3705,1051.0710,11.8374,270.0173,11,76), // Truck8
AddStaticVehicle(515,1631.9513,1025.4581,11.8431,268.3826,13,76) // Truck9
};
Hope someone can help me. Thanks.
Re : Multiple vehicles in 1 variable -
Vukilore - 07.04.2011
use Array
Re: Multiple vehicles in 1 variable -
Stigg - 07.04.2011
Quote:
Originally Posted by sim_sima
Hi guys.
Is it possible to make multiple vehicles in 1 variable?
i did like this, but it doesnt work:
pawn Код:
new truck = { AddStaticVehicle(403,1697.2108,1057.6760,11.4450,180.6527,25,1), // Truck1 AddStaticVehicle(514,1692.2650,1056.6304,11.4086,180.6328,36,1), // Truck2 AddStaticVehicle(514,1687.1963,1056.7150,11.4078,179.3409,113,1), // Truck3 AddStaticVehicle(403,1671.1423,1085.4607,11.4273,180.2388,30,1), // Truck4 AddStaticVehicle(514,1665.7838,1084.3821,11.4078,180.4213,25,1), // Truck5 AddStaticVehicle(515,1659.8749,1084.6716,11.8436,179.6213,54,77), // Truck6 AddStaticVehicle(403,1631.0760,1057.6670,11.4274,269.9039,36,1), // Truck7 AddStaticVehicle(515,1631.3705,1051.0710,11.8374,270.0173,11,76), // Truck8 AddStaticVehicle(515,1631.9513,1025.4581,11.8431,268.3826,13,76) // Truck9 };
Hope someone can help me. Thanks.
|
pawn Код:
new Vehicle[10];
Vehicle[0] = AddStaticVehicle(whatever you wish);
Vehicle[1] = AddStaticVehicle(whatever you wish);
Vehicle[2] = AddStaticVehicle(whatever you wish);
//Ect...
Re: Multiple vehicles in 1 variable -
Calgon - 07.04.2011
Quote:
Originally Posted by Stigg
pawn Код:
new Vehicle[10]
Vehicle[0] = AddStaticVehicle(whatever you wish); Vehicle[1] = AddStaticVehicle(whatever you wish); Vehicle[2] = AddStaticVehicle(whatever you wish); //Ect...
|
A semi-colon is required after 'Vehicle[10]', so:
Note, you can change 10 to the amount of vehicles you plan to create.
Re: Multiple vehicles in 1 variable -
sim_sima - 07.04.2011
Thank you. But if i want, lets say, 15 vehicles in the same variable, then i have to make array 15 cells big?
like "new truck[15];"??
Re: Multiple vehicles in 1 variable -
marinov - 07.04.2011
Quote:
Originally Posted by sim_sima
Thank you. But if i want, lets say, 15 vehicles in the same variable, then i have to make array 15 cells big?
like "new truck[15];"??
|
yeah
Re: Multiple vehicles in 1 variable -
sim_sima - 07.04.2011
Ok. Now i did that. But when im doing like this:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(pJob[playerid][trucker] == 0)
{
if(vehicleid == truck)
{
SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) Only Truckers can use this vehicle!");
RemovePlayerFromVehicle(playerid);
}
}
return 1;
}
it gives me this error:
Код:
C:\Users\Simon\Desktop\Untitled.pwn(129) : error 017: undefined symbol "truck"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Re: Multiple vehicles in 1 variable -
sim_sima - 07.04.2011
How do i refer to all of them in the "if(vehicleid == truck)"??
Re: Multiple vehicles in 1 variable - [L3th4l] - 07.04.2011
Make a loop:
pawn Код:
for(new i = 0; i < sizeof(truck); ++i)
{
if(vehicleid == i)
{
// Code
}
}
Re: Multiple vehicles in 1 variable -
marinov - 07.04.2011
Quote:
Originally Posted by [L3th4l]
Make a loop:
pawn Код:
for(new i = 0; i < sizeof(truck); ++i) { if(vehicleid == i) { // Code } }
|
yeah that would be the best way to do it