Team vehicles
#1

Hello!
im trying to make team vehicles, but i cant get it work, there is no errors/warnings at all!
The thing is that you can enter all team vehicles even if you not belong to that team, why?
Is there some wrong with the code? or do i missing some important code to make it take affect?
Need help!


pawn Код:
new Team1Car[21], Team2Car[21], Team3Car[21], Team4Car[22];

public OnGameModeInit()
{
    Team1Car[0]=CreateVehicle(476,419.9781,2441.7148,17.2157,90.9542,3,1,3000); // New player
    Team1Car[1]=CreateVehicle(476,419.7993,2453.4229,17.2155,89.1848,3,1,3000); // New player
    Team1Car[2]=CreateVehicle(476,420.0335,2466.9705,17.2098,88.6598,3,1,3000); // New player
    Team1Car[3]=CreateVehicle(476,389.5863,2439.7012,17.2138,273.9613,3,1,3000); // New player
    Team1Car[4]=CreateVehicle(476,389.2481,2452.0327,17.2109,271.2024,3,1,3000); // New player
    Team1Car[5]=CreateVehicle(476,389.3371,2466.8743,17.2080,269.3279,3,1,3000); // New player
    Team1Car[6]=CreateVehicle(476,369.9770,2471.4199,17.1923,1.0170,3,1,3000); // New player
    Team1Car[7]=CreateVehicle(476,355.2772,2471.4446,17.1924,0.1990,3,1,3000); // New player
    Team1Car[8]=CreateVehicle(476,341.0659,2471.6011,17.1892,359.4792,3,1,3000); // New player
    Team1Car[9]=CreateVehicle(476,289.9539,2536.9458,17.5328,182.0488,3,1,3000); // New player
    Team1Car[10]=CreateVehicle(476,324.9881,2537.0947,17.5249,180.0883,3,1,3000); // New player
    Team1Car[11]=CreateVehicle(476,342.7910,2537.0664,17.4873,180.8570,3,1,3000); // New player
    Team1Car[12]=CreateVehicle(476,382.3123,2537.2183,17.2524,180.4406,3,1,3000); // New player
    Team1Car[13]=CreateVehicle(548,364.2266,2536.7107,16.7929,175.6206,3,1,3000); // New player Cargobob
    Team1Car[14]=CreateVehicle(432,330.9751,2547.3921,16.8178,1.1064,0,0,3000); // New Player Rhino
    Team1Car[15]=CreateVehicle(432,320.8236,2548.0957,16.8227,359.7192,0,0,3000); // New Player Rhino
    Team1Car[16]=CreateVehicle(432,296.3745,2548.3577,16.8338,358.0152,0,0,3000); // New Player Rhino
    Team1Car[17]=CreateVehicle(432,284.9641,2548.6011,16.8317,359.1052,0,0,3000); //New Player Rhino
    Team1Car[18]=CreateVehicle(425,311.9832,2466.6350,17.0458,1.7575,0,0,3000); // hunter newplayer
    Team1Car[19]=CreateVehicle(425,296.9786,2468.4695,17.0488,5.5592,0,0,3000); // hunter newplayer
    Team1Car[20]=CreateVehicle(425,283.6572,2467.3645,17.0476,6.3777,0,0,3000); // hunter newplayer

    //TEAM_3 Airwolves
    Team2Car[0]=CreateVehicle(476,1581.9852,1162.1902,11.5066,0.8701,0,1,3000); // Airwolves
    Team2Car[1]=CreateVehicle(476,1570.1849,1162.0282,11.5137,1.1687,0,1,3000); // Airwolves
    Team2Car[2]=CreateVehicle(476,1558.3748,1161.9513,11.5302,359.4196,0,1,3000); // Airwolves
    Team2Car[3]=CreateVehicle(476,1595.0438,1181.5055,11.5254,359.7671,0,1,3000); // Airwolves
    Team2Car[4]=CreateVehicle(476,1606.4656,1188.0414,11.5129,359.9229,0,1,3000); // Airwolves
    Team2Car[5]=CreateVehicle(476,1582.0078,1173.1418,11.5260,0.0395,0,1,3000); // Airwolves
    Team2Car[6]=CreateVehicle(476,1569.7256,1172.8888,11.5189,2.2377,0,1,3000); // Airwolves
    Team2Car[7]=CreateVehicle(476,1558.2279,1172.7627,11.5180,358.3973,0,1,3000); //Airwolves
    Team2Car[8]=CreateVehicle(476,1582.1110,1182.9968,11.5135,0.9782,0,1,3000); // Airwolves
    Team2Car[9]=CreateVehicle(476,1570.1838,1182.8129,11.5197,1.4127,0,1,3000); // Airwolves
    Team2Car[10]=CreateVehicle(476,1558.6588,1182.8693,11.5206,358.3985,0,1,3000); // Airwolves
    Team2Car[11]=CreateVehicle(476,1558.8196,1192.9263,11.5295,359.2359,0,1,3000); // Airwolves
    Team2Car[12]=CreateVehicle(476,1570.2063,1192.8105,11.5265,0.3085,0,1,3000); // Airwolves
    Team2Car[13]=CreateVehicle(548,1602.0354,1281.8556,15.0148,102.5360,0,0,3000); // Airwolves Cargobob
    Team2Car[14]=CreateVehicle(432,1281.8174,1317.7827,10.8330,269.8667,0,0,3000); // Airwolves Rhino
    Team2Car[15]=CreateVehicle(432,1281.3157,1329.9841,10.8332,270.0224,0,0,3000); // Airwolves Rhino
    Team2Car[16]=CreateVehicle(432,1281.8860,1354.4025,10.8330,270.5049,0,0,3000); // Airwolves Rhino
    Team2Car[17]=CreateVehicle(432,1281.9857,1368.0791,10.8330,270.8093,0,0,3000); // Airwolves Rhino
    Team2Car[18]=CreateVehicle(425,1429.6877,1324.8799,11.4066,273.0157,0,0,3000); // hunter Airwolves
    Team2Car[19]=CreateVehicle(425,1428.8368,1310.5518,11.3923,268.1280,0,0,3000); // hunter Airwolves
    Team2Car[20]=CreateVehicle(425,1429.4142,1338.4646,11.3934,268.7853,0,0,3000); // hunter Airwolves

    //TEAM_1 Bluefoxes
    Team3Car[0]=CreateVehicle(476,1978.6555,-2396.0037,14.2643,89.5653,2,1,3000); // Bluefoxes
    Team3Car[1]=CreateVehicle(476,1978.7040,-2383.6899,14.2553,90.1082,2,1,3000); // Bluefoxes
    Team3Car[2]=CreateVehicle(476,1978.8127,-2370.9258,14.2562,89.6564,2,1,3000); // Bluefoxes
    Team3Car[3]=CreateVehicle(476,1978.7545,-2358.6887,14.2611,90.8094,2,1,3000); // Bluefoxes
    Team3Car[4]=CreateVehicle(476,1978.7524,-2346.6282,14.2542,90.3923,2,1,3000); // Bluefoxes
    Team3Car[5]=CreateVehicle(476,1978.7271,-2334.2107,14.2586,89.8635,2,1,3000); // Bluefoxes
    Team3Car[6]=CreateVehicle(476,1967.9773,-2334.0098,14.2537,89.2006,2,1,3000); // Bluefoxes
    Team3Car[7]=CreateVehicle(476,1968.0304,-2346.7659,14.2564,89.5600,2,1,3000); // Bluefoxes
    Team3Car[8]=CreateVehicle(476,1968.0143,-2359.2332,14.2567,89.3761,2,1,3000); // Bluefoxes
    Team3Car[9]=CreateVehicle(476,1967.8055,-2372.2275,14.2629,89.7649,2,1,3000); // Bluefoxes
    Team3Car[10]=CreateVehicle(476,1967.7516,-2384.9595,14.2562,89.7772,2,1,3000); // Bluefoxes
    Team3Car[11]=CreateVehicle(476,1967.9479,-2396.9973,14.2661,90.1868,2,1,3000); // Bluefoxes
    Team3Car[12]=CreateVehicle(476,1978.8635,-2409.2715,14.2563,89.8173,2,1,3000); // Bluefoxes
    Team3Car[13]=CreateVehicle(548,1997.4635,-2430.8811,17.1481,94.3798,2,1,3000); // Bluefoxes Cargobob
    Team3Car[14]=CreateVehicle(432,1978.8031,-2322.4282,13.5596,89.2325,2,1,3000); // Bluefoxes Rhino
    Team3Car[15]=CreateVehicle(432,1978.6914,-2314.6343,13.5596,89.3591,2,1,3000); // Bluefoxes Rhino
    Team3Car[16]=CreateVehicle(432,1978.3168,-2306.7822,13.5596,88.8411,2,1,3000); // Bluefoxes Rhino
    Team3Car[17]=CreateVehicle(432,1978.5193,-2299.1052,13.5598,88.8872,2,1,3000); // Bluefoxes Rhino
    Team3Car[18]=CreateVehicle(425,1947.4424,-2259.8452,14.1190,182.5776,2,1,3000); // hunter bluefoxes
    Team3Car[19]=CreateVehicle(425,1931.5741,-2259.7698,14.1187,189.0221,2,1,3000); // hunter bluefoxes
    Team3Car[20]=CreateVehicle(425,1917.5420,-2262.0669,14.1189,188.7777,2,1,3000); // hunter bluefoxes

    //TEAM_2 Thunderbirds
    Team4Car[0]=CreateVehicle(476,-1511.3623,-164.6398,14.8441,11.8009,6,1,3000); // Thunderbird plane
    Team4Car[1]=CreateVehicle(476,-1491.9832,-145.5590,14.8648,11.7777,6,1,3000); //Thunderbird
    Team4Car[2]=CreateVehicle(476,-1501.6255,-155.3166,14.8596,8.5552,6,1,3000); // Thunderbird
    Team4Car[3]=CreateVehicle(476,-1481.5931,-135.6380,14.8579,7.9517,6,1,3000); // Thunderbird
    Team4Car[4]=CreateVehicle(476,-1471.6337,-125.5648,14.8578,8.5159,6,1,3000); // Thunderbird
    Team4Car[5]=CreateVehicle(476,-1461.9418,-116.3714,14.8641,4.4572,6,1,3000); // Thunderbird
    Team4Car[6]=CreateVehicle(476,-1451.6680,-105.8881,14.8565,5.1509,6,1,3000); // Thunderbird
    Team4Car[7]=CreateVehicle(476,-1440.7518,-95.2124,14.8536,3.1080,6,1,3000); // Thunderbird
    Team4Car[8]=CreateVehicle(476,-1430.0154,-84.5389,14.8576,3.0299,6,1,3000); // Thunderbird
    Team4Car[9]=CreateVehicle(476,-1418.5612,-73.0776,14.8428,4.4553,6,1,3000); // Thunderbird
    Team4Car[10]=CreateVehicle(476,-1407.5093,-61.9155,14.8408,5.2833,6,1,3000); // Thunderbird
    Team4Car[11]=CreateVehicle(476,-1396.1097,-50.7228,14.8596,2.7714,6,1,3000); // Thunderbird
    Team4Car[12]=CreateVehicle(476,-1385.4530,-39.9416,14.8657,3.3986,6,1,3000); // Thunderbird
    Team4Car[13]=CreateVehicle(476,-1385.4337,-39.9457,14.8662,3.9818,6,1,3000); // Thunderbird
    Team4Car[14]=CreateVehicle(548,-1500.4371,-224.0978,18.0048,1.0643,0,0,3000);// Thunderbird Cargobob
    Team4Car[15]=CreateVehicle(432,-1458.5845,-181.6641,14.1613,76.4453,2,2,3000); // Thunderbird Rhino
    Team4Car[16]=CreateVehicle(432,-1456.9139,-174.5814,14.1613,75.6198,2,2,3000); // Thunderbird Rhino
    Team4Car[17]=CreateVehicle(432,-1460.0137,-189.2424,14.1610,77.0195,2,2,3000); // Thunderbird Rhino
    Team4Car[18]=CreateVehicle(432,-1454.8531,-166.4090,14.1613,76.0108,2,2,3000); // Thunderbird Rhino
    Team4Car[19]=CreateVehicle(425,-1536.9520,-233.1755,14.7374,10.6363,2,2,3000); // Hunter
    Team4Car[20]=CreateVehicle(425,-1550.1385,-237.2429,14.7205,13.8028,2,2,3000); // Hunter
    Team4Car[21]=CreateVehicle(425,-1564.4420,-242.6652,14.7159,5.1001,2,2,3000); // Hunter
    //-------------END ADD VEHICLES


public OnPlayerEnterVehicle(playerid, vehicleid)
{
    for(new var; var < 18; var++)
    {
        if(vehicleid == Team1Car[var])
        {
        if(PlayerBase[playerid][pMedlem] != 0 || PlayerBase[playerid][pLedare] != 0) RemovePlayerFromVehicle(playerid);
        }
        if(vehicleid == Team2Car[var])
        {
        if(PlayerBase[playerid][pMedlem] != 3 || PlayerBase[playerid][pLedare] != 3) RemovePlayerFromVehicle(playerid);
        }
        if(vehicleid == Team3Car[var])
        {
        if(PlayerBase[playerid][pMedlem] != 1 || PlayerBase[playerid][pLedare] != 1) RemovePlayerFromVehicle(playerid);
        }
        if(vehicleid == Team4Car[var])
        {
        if(PlayerBase[playerid][pMedlem] != 2 || PlayerBase[playerid][pLedare] != 2) RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
Reply
#2

Change the
pawn Код:
||
for
pawn Код:
&&
Reply
#3

Umm Try using OnPlayerStateChange, this is one i got from my vip
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid == vipv && PlayerData[playerid][vip] == 0)/* so here if the player is not vip it will kick them out and show this, so if you wanna make team. make it like*/ if(vid == teamcar && != 1) /* that is the first team cause i have 1*/
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid,0xFF0000FF, "You are not an vip, Go to http://www.extreme-stuntage.x10.mx to donate for VIP!");
        }
    }
Reply
#4

Quote:
Originally Posted by CyNiC
Посмотреть сообщение
Change the
pawn Код:
||
for
pawn Код:
&&
Thanks, but && did not do anything
Reply
#5

Quote:
Originally Posted by tanush
Посмотреть сообщение
Umm Try using OnPlayerStateChange, this is one i got from my vip
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
    {
        new vid = GetPlayerVehicleID(playerid);
        if(vid == vipv && PlayerData[playerid][vip] == 0)/* so here if the player is not vip it will kick them out and show this, so if you wanna make team. make it like*/ if(vid == teamcar && != 1) /* that is the first team cause i have 1*/
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid,0xFF0000FF, "You are not an vip, Go to http://www.extreme-stuntage.x10.mx to donate for VIP!");
        }
    }
I really don't know how to change this code to fit my script :P
Reply
#6

Here is my tutorial, it is slightly different than what you have done but you could have a read and try make yours look similar and see if it works? Or maybe just simply do it the way I did that tutorial.
https://sampforum.blast.hk/showthread.php?tid=220546
Reply
#7

Quote:
Originally Posted by LiamM
Посмотреть сообщение
Here is my tutorial, it is slightly different than what you have done but you could have a read and try make yours look similar and see if it works? Or maybe just simply do it the way I did that tutorial.
https://sampforum.blast.hk/showthread.php?tid=220546
That will be to big for 4 teams and 74 vehicles i guess
Reply
#8

I can only refer to my last topic -> [Include] Group Macros

But if you want a solution for your code

Quote:
Originally Posted by cruising
Посмотреть сообщение
Hello!
The thing is that you can enter all team vehicles even if you not belong to that team, why?
You got 4 arrays and for your code in OnPlayerEnterVehicle they need to have all the same size
The size of the biggest one, also 22

pawn Код:
stock TeamCar[4][22]; //2d arrays, looks more clear
Now your actually problem was your loop
pawn Код:
for(new var; var < 18; var++)
which only went to 18 ? why 18, dunno, it should loop till sizeof TeamCar[] (22)

Than another problem why your code would never work
Because in OnPlayerEnterVehicle the player enters the vehicle
So he cant be removed if he isnt in it
Just move your loop in OnPlayerStateChange

Another thing you could do would be to seperate the loops so you dont need to change the size of the arrays
Reply
#9

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
I can only refer to my last topic -> [Include] Group Macros

But if you want a solution for your code



You got 4 arrays and for your code in OnPlayerEnterVehicle they need to have all the same size
The size of the biggest one, also 22

pawn Код:
stock TeamCar[4][22]; //2d arrays, looks more clear
Now your actually problem was your loop
pawn Код:
for(new var; var < 18; var++)
which only went to 18 ? why 18, dunno, it should loop till sizeof TeamCar[] (22)

Than another problem why your code would never work
Because in OnPlayerEnterVehicle the player enters the vehicle
So he cant be removed if he isnt in it
Just move your loop in OnPlayerStateChange

Another thing you could do would be to seperate the loops so you dont need to change the size of the arrays
Sorry im a crap scripter lol!

Ok, i have done like this now
pawn Код:
new Team1Car[22], Team2Car[22], Team3Car[22], Team4Car[22];
public OnPlayerEnterVehicle(playerid, vehicleid)
{
    for(new var; var < 22; var++)
    {
And if i put it in OnPlayerStateChange i get error, and even more if i define it
pawn Код:
error 017: undefined symbol "vehicleid"
And how about this stock?
pawn Код:
stock TeamCar[4][22]; //2d arrays, looks more clear
Reply
#10

pawn Код:
stock TeamCar[4][22]; //TeamCar[0], TeamCar[1], TeamCar[2], TeamCar[3]
Is only another way to write

pawn Код:
new Team1Car[22], Team2Car[22], Team3Car[22], Team4Car[22];
If you put it in OnPlayerStateChange you need to check if his state changed to driver

pawn Код:
//OnPlayerStateChange
if(newstate == PLAYER_STATE_DRIVER)
{
    for(new var; var < sizeof Team4Car; var++) //or with my 2d array sizeof TeamCar[]
    {
    }
}
Reply
#11

Hmm there is still something i do wrong, and that bc i not sure what you mean what to do in OnPlayerStateChange

i have this on top of script, hope it is right?
pawn Код:
stock TeamCar[4][22];
and on OnPlayerStateChange, i guess i made this wrong?
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
    for(new var; var < sizeof Team4Car; var++)
    {
        if(vehicleid == Team1Car[var])
        {
        if(PlayerBase[playerid][pMedlem] != 0 && PlayerBase[playerid][pLedare] != 0) RemovePlayerFromVehicle(playerid);
        }
        if(vehicleid == Team2Car[var])
        {
        if(PlayerBase[playerid][pMedlem] != 3 && PlayerBase[playerid][pLedare] != 3) RemovePlayerFromVehicle(playerid);
        }
        if(vehicleid == Team3Car[var])
        {
        if(PlayerBase[playerid][pMedlem] != 1 && PlayerBase[playerid][pLedare] != 1) RemovePlayerFromVehicle(playerid);
        }
        if(vehicleid == Team4Car[var])
        {
        if(PlayerBase[playerid][pMedlem] != 2 && PlayerBase[playerid][pLedare] != 2) RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}
And the errors
pawn Код:
C:\Users\Per\Desktop\Airstrike Battle1 - Copy\gamemodes\Fort4444.pwn(91) : error 017: undefined symbol "Team1Car"
C:\Users\Per\Desktop\Airstrike Battle1 - Copy\gamemodes\Fort4444.pwn(91) : warning 215: expression has no effect
C:\Users\Per\Desktop\Airstrike Battle1 - Copy\gamemodes\Fort4444.pwn(91) : error 001: expected token: ";", but found "]"
C:\Users\Per\Desktop\Airstrike Battle1 - Copy\gamemodes\Fort4444.pwn(91) : error 029: invalid expression, assumed zero
C:\Users\Per\Desktop\Airstrike Battle1 - Copy\gamemodes\Fort4444.pwn(91) : fatal error 107: too many error messages on one line
Reply
#12

before i was in a rush, try this
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
new vid = GetPlayerVehicleID(playerid);
if(vid == Team1Car && PlayerBase[playerid][pMedlem] != 0 || PlayerBase[playerid][pLedare] != 0)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid,0xFF0000FF,"ERROR: This vehicle belongs to the first team!");
}
}
sorry about the indention, forum has weird problems :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)