Please Explain "Team Vehicles"
#1

Okay, I am currently using Raven's RP 2.6, just so you know. I am having some trouble with them "Team Vehicles", they way it works doesn't make any sense to me. Now, I have talked to a friend and he says that for every "AddStaticVehicleEx(...)" you have, it counts as 1 car. So, when your doing:

pawn Код:
public IsAnFbiCar(carid)
{
    if((carid >= 42) && (carid <= 43) || (carid >= 1173) && (carid <= 1182) || (carid >= 1154) && (carid <= 1156))
    {
        return 1;
    }
    return 0;
}
42 would be the 43rd line of "AddStaticVehicleEx(...)" from the beginning of your script, to the end? 1173 would be the 1137th line of "AddStaticVehicleEx(...)", etc... If I am correct, is there an easier way to do that? If I am wrong, how does it work?
Reply
#2

i think u might have to use carname = addstaticvehicleex(); etc so like

pawn Код:
public IsAnFbiCar(carid)
{
    if(carid == carname)
    {
        return 1;
    }
    return 0;
}
Reply
#3

Quote:
Originally Posted by Kar
Посмотреть сообщение
i think u might have to use carname = addstaticvehicleex(); etc so like

pawn Код:
public IsAnFbiCar(carid)
{
    if(carid == carname)
    {
        return 1;
    }
    return 0;
}
Well, I think you CAN do it that way, but the way I have it now works... I just don't want to attempt adding more cars and have a huge major problem, ESPECIALLY since I don't know how it works. If I were making a mini-script, the way you mentioned would work, but I don't think doing it that way would be good for 1000+ cars...
Reply
#4

whoa lol 1000+ gratz on making your way work:d mine was just an alternative
Reply
#5

Quote:
Originally Posted by Kar
Посмотреть сообщение
whoa lol 1000+ gratz on making your way work:d mine was just an alternative
Yeah, thanks. I appreciate the suggestion though, maybe I will use that on my RP testing server...
Reply
#6

The numbers are the vehicle IDs, and let's say this function is called when a player enter a vehicle, it checks the car id, and if it's that car id, then you can do whatever you want.

BTW do not plan on getting big with Raven's Roleplay because literally everyone on SAMP uses that. It's the new GF.
Reply
#7

no his addstaticvehicles are defined as 1 = addstaticvehicle 2 = addstatic etc.

i believe it is so because u cant do if (carid >= 1173) && (carid <= 1182)? theres no such vehicle id
Reply
#8

It seems you may be a bit confused... Below is what my "AddStaticVehicleEx(...)'s" look like.

pawn Код:
AddStaticVehicleEx(598,2779.3843,-2434.2644,13.3568,88.5203,99,1,30000); // Army police 1
    AddStaticVehicleEx(598,2779.4299,-2439.7708,13.3572,88.1692,99,1,30000); // Army police 2
    AddStaticVehicleEx(598,2779.1882,-2471.9214,13.3576,86.6550,99,1,30000); // Army police 3
    AddStaticVehicleEx(598,2779.1497,-2477.8547,13.3590,86.9500,99,1,30000); // Army police 4
    AddStaticVehicleEx(432,2791.3584,-2494.2971,13.6588,89.3376,43,0,30000); // Army tank 5
    AddStaticVehicleEx(470,2792.0173,-2455.8245,14.0688,90,43,0,30000); // Army patriot 6
    AddStaticVehicleEx(470,2793.1680,-2418.1855,13.6259,88.3914,-1, -1, 30000); // Patriot 7
    AddStaticVehicleEx(470,2785.0979,-2417.6987,13.6273,87.4559, -1, -1, 30000); //Patriot 8
    AddStaticVehicleEx(433,2781.4146,-2455.5208,14.0714,90,43,0,30000); // Army truck 9
    AddStaticVehicleEx(430,2698.8132,-2311.0671,-0.2161,87.3657,-1, -1, 30000); // Army boat 10
    AddStaticVehicleEx(430,2722.9766,-2311.2756,-0.3360,89.2799,-1, -1, 30000); // Army boat 11
    //-------------------------------------------------------------------------------------------
    AddStaticVehicleEx(405,1406.93,-1790.2,13.3,90, 0, 0, 30000); // Mayor security 12
    AddStaticVehicleEx(405,1406.9,-1793.8,13.3,90, 0, 0, 30000); // Mayor security 13
    AddStaticVehicleEx(405,1406.7,-1782.16,13.3,90, 0, 0, 30000); // Mayor security 14
    AddStaticVehicleEx(409,1405.87,-1785.96,13.3,90,1,1,30000); // Mayor stretch 15
    //-------------------------------------------------------------------------------------------
    AddStaticVehicleEx(599,616.1244,-601.7048,17.4214,271.5325, -1, -1, 30000); // Cop cruiser (Dillimore) 16
    AddStaticVehicleEx(426,158.4755,-1751.1315,4.6460,1.3559,0,0, 30000); // La Vice Premier 17
    AddStaticVehicleEx(426,158.3176,-1758.2914,4.4283,356.8665,0,0, 30000); // La Vice Premier 18
    AddStaticVehicleEx(596,1574.4703,-1710.9795,5.6115,0.4220, -1, -1, 30000); // Cop cruiser 19
    AddStaticVehicleEx(596,1587.4816,-1710.3594,5.6104,358.9421,-1, -1, 30000); // Cop cruiser 20
    AddStaticVehicleEx(596,1595.6578,-1710.9442,5.6119,359.6335,0,1,30000); // Cop cruiser 21
    AddStaticVehicleEx(596,1545.7845,-1684.4004,5.6342,271.1593,0,1,30000); // Cop cruiser 22
    AddStaticVehicleEx(596,1558.7819,-1710.9503,5.6119,1.1862,0,1,30000); // Cop cruiser 23
    AddStaticVehicleEx(596,1601.8564,-1704.1805,5.6110,88.9959,-1,-1,30000); // Cop cruiser 24
    AddStaticVehicleEx(596,1600.9231,-1691.9321,5.6113,91.6221,-1,-1,30000); // Cop cruiser 25
    AddStaticVehicleEx(596,1600.4153,-1687.9385,5.6118,90.7431,-1,-1,30000); // Cop cruiser 26
    AddStaticVehicleEx(596,1529.6339,-1683.7720,5.6124,270.5692, -1, -1, 30000); // Cop cruiser 27
    AddStaticVehicleEx(596,1529.5374,-1688.0181,5.6114,270.0886, -1, -1, 30000); // Cop cruiser 28
    AddStaticVehicleEx(523,1557.9637,-1694.5964,5.4673,226.4766,-1,-1,30000); // Police moto 29
    AddStaticVehicleEx(523,1557.9060,-1697.4153,5.4689,220.9842,-1,-1,30000); // Police moto 30
    AddStaticVehicleEx(523,1558.1632,-1691.8335,5.4596,224.7542,-1,-1,30000); // Police moto 31
    AddStaticVehicleEx(599,1584.6510,-1671.4448,6.0541,271.5708,0,1,30000); // Police ranger 32
    AddStaticVehicleEx(599,1584.7875,-1667.6138,6.0592,272.0818,0,1,30000); // Police ranger 33
    AddStaticVehicleEx(599,1545.3936,-1667.7957,6.0809,87.7152,-1,-1,30000); // Police ranger 34
    AddStaticVehicleEx(599,1545.0044,-1671.9329,6.0791,91.5492,-1,-1,30000); // Police ranger 35
    AddStaticVehicleEx(427,1544.2870,-1659.3522,5.6119,88.5025,0,125,30000);// Police SWAT enforcer 36
    AddStaticVehicleEx(601,1544.6962,-1663.2948,6.0225,88.9357,-1,-1,30000); // Police SWAT APC 37
    AddStaticVehicleEx(497,1566.6628,-1653.8688,28.5752,91.9445,0,1,30000);// Police maverick 38
    //-------------------------------------------------------------------------------------------
    AddStaticVehicleEx(490,1514.1959,-1478.1108,9.6270,270.0, 125, 0, 30000); // FBI rancher 39
    AddStaticVehicleEx(490,1514.1621,-1474.2642,9.6278,270,125,0,30000); // FBI rancher 40
    AddStaticVehicleEx(426,1525.4424,-1461.3640,9.2431,0,125,0,30000); // FBI elegant 41
    AddStaticVehicleEx(426,1520.8752,-1461.1650,9.2430,0,0,0,30000); // FBI elegant 42
    AddStaticVehicleEx(426,1516.1973,-1461.1393,9.2430,0,0,0,30000); // FBI elegant 43
    //-------------------------------------------------------------------------------------------
    AddStaticVehicleEx(426,153.8499,-1758.2358,4.5786,358.2814,0,0, 30000); // La Vice Premier 44
    AddStaticVehicleEx(572,2558.3201,2653.9070,10.5473,193.3834,0,0, 30000); // None 45
    AddStaticVehicleEx(572,2564.2375,2649.3052,10.5265,207.0189,0,0, 30000); // None 46
    AddStaticVehicleEx(572,2574.2048,2649.4514,10.5474,219.5219,0,0, 30000); // None 47
    AddStaticVehicleEx(572,2578.7847,2655.4546,10.5912,233.9002,0,0, 30000); // None 48
    AddStaticVehicleEx(572,2584.6228,2660.0879,10.5919,76.5837,0,0, 30000); // None 49
    AddStaticVehicleEx(572,2584.1938,2665.9053,10.5510,109.2745,0,0, 30000); // None 50
    AddStaticVehicleEx(572,2562.7419,2664.0110,10.6135,139.6290,0,0, 30000); // None 51
Reply
#9

The reason these roleplay modes are scripting like that, are because, simply there not meant to be edited, so there just extremely static.

Try this, it's basic array work

More information: https://sampwiki.blast.hk/wiki/Scripting_Basics#Arrays

Put this below your includes, outside of any callback.

pawn Код:
new
    Vehicle[MAX_VEHICLES] = {-1,...};
That makes a new array 'Vehicle' with the size of the constant define 'MAX_VEHICLES' (2000) and sets every cell to -1.

Now, it depends on how you're planning it to work, you will have to assign a vehicle to every cell, for example:

pawn Код:
Vehicle[0] = CreateVehicle(411, 0.0, 0.0, 0.0, 0.0, -1, -1, -1);
Vehicle[1] = CreateVehicle(411, 0.0, 0.0, 0.0, 0.0, -1, -1, -1);
Vehicle[2] = CreateVehicle(411, 0.0, 0.0, 0.0, 0.0, -1, -1, -1);
Vehicle[3] = CreateVehicle(411, 0.0, 0.0, 0.0, 0.0, -1, -1, -1);
But that's going to be alot for lots of vehicles, I prefer using files and sscanf2, due to sscanf2 being able to read deliminators.

But you can use it like that if you wish .

for destroying only them vehicles you created with the array, you just use:

pawn Код:
for(new a = 0; a < sizeof(Vehicle); a++)
{
    if(Vehicle[a] == -1) continue;
   
    DestroyVehicle(Vehicle[a]);
}
That loops through all cells of 'Vehicle' (2000 iterations, so you may want to change the value of Vehicle)
Checks if that cell is -1, if it is, it will skip that iteration, if it's not, it will destroy the vehicle, and carry on with the loop.

If you want to check if a cetin vehicle is one of them vehicles you created with the Array, you use:

pawn Код:
for(new a = 0; a < sizeof(Vehicle); a++)
{
    if(vehicleid == Vehicle[a])
    {
        //Do something if the vehicle IS one of them vehicle created using the Array.
       
        RemovePlayerFromVehicle(playerid);
    }
}
That loops through all cells of Vehicle (again, that's 2000 iterations, should change the size of Vehicle to something smaller), checks if the vehicleid the player is driving is one of them vehicles, if it is, it removes them from the vehicle, otherwise it just keeps going through all vehicles until the if statement returns true, or there's not match.

You should make the size of Vehicle to the amount of vehicles You're planning on making +1, but I'd make it a phew over what I'd make, to make sure If I forget, it won't cause problems.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)