frespawn command only respawns 1 faction
#1

pawn Код:
#define MAX_FACTIONS    5 // 0 = civilian | 1 = SASD | 2 = FBI | 3 = Trucking | 4 = SANews | 5 = Construction


enum facInfo
{
    fCars[26],
}
new FacInfo[MAX_FACTIONS][facInfo];
(Using this server to test things.)

pawn Код:
command(frespawn, playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, USAGE, "Usage: /frespawn [Faction name] (SASD, SAFD, Trucking)");
    {
        if(!strcmp(params, "sasd", true)) // This works, the rest don't...
        {
            for(new v = 0; v < FacInfo[1][fCars][24]; v++)
            {
                if(!IsPlayerInAnyVehicle(v))
                {
                    SetVehicleToRespawn(v);
                }
            }
        }
        else if(!strcmp(params, "fbi", true))
        {
            for(new v = 0; v < FacInfo[2][fCars][24]; v++)
            {
                if(!IsPlayerInAnyVehicle(v))
                {
                    SetVehicleToRespawn(v);
                }
            }
        }
        else if(!strcmp(params, "trucking", true))
        {
            for(new v = 0; v < FacInfo[3][fCars][24]; v++)
            {
                if(!IsPlayerInAnyVehicle(v))
                {
                    SetVehicleToRespawn(v);
                }
            }
        }
        else if(!strcmp(params, "sanews", true))
        {
            for(new v = 0; v < FacInfo[4][fCars][24]; v++)
            {
                if(!IsPlayerInAnyVehicle(v))
                {
                    SetVehicleToRespawn(v);
                }
            }
        }
        else if(!strcmp(params, "construction", true))
        {
            for(new v = 0; v < FacInfo[5][fCars][24]; v++)
            {
                if(!IsPlayerInAnyVehicle(v))
                {
                    SetVehicleToRespawn(v);
                }
            }
        }
    }
    return 1;
}
pawn Код:
stock LoadStaticVehicles()
{


    // Sheriff Department
    FacInfo[1][fCars][0] = CreateVehicle(427,-297.6003,1730.7551,43.1232,42.0967,0,0, -1); // SASD Enforcer
    FacInfo[1][fCars][1] = CreateVehicle(427,-291.1509,1730.7263,43.1210,44.3085,0,0, -1); // SASD Enforcer 1
    FacInfo[1][fCars][3] = CreateVehicle(601,-290.3907,1751.5988,42.4482,89.6195,0,0, -1); // SASD WaterTanker
    FacInfo[1][fCars][4] = CreateVehicle(601,-290.2049,1756.8237,42.4505,88.5505,0,0, -1); // SASD WaterTanker 1
    FacInfo[1][fCars][5] = CreateVehicle(490,-289.4469,1772.6906,42.8311,88.9679,0,0, -1); // SASD FBI RANCHER
    FacInfo[1][fCars][6] = CreateVehicle(490,-289.2797,1777.9775,42.8455,89.2843,0,0, -1); // SASD FBI RANCHER 1
    FacInfo[1][fCars][7] = CreateVehicle(598,-301.5512,1777.6387,42.5115,270.1394,0,0, -1); // SASD LVPD
    FacInfo[1][fCars][8] = CreateVehicle(598,-301.6537,1772.6714,42.5072,268.5833,0,0, -1); // SASD LVPD 1
    FacInfo[1][fCars][9] = CreateVehicle(560,-301.6548,1767.8286,41.8217,268.7976,0,0, -1); // SASD Sultan
    FacInfo[1][fCars][10] = CreateVehicle(560,-301.8418,1763.1901,41.9192,268.7052,0,0, -1); // SASD Sultan 1
    FacInfo[1][fCars][11] = CreateVehicle(563,-333.9855,1828.6938,42.9512,205.2358,0,0, -1); // SASD RainDance
    FacInfo[1][fCars][12] = CreateVehicle(497,-301.9202,1832.8826,42.4608,180.6033,0,0, -1); // SASD Police Maverick
    FacInfo[1][fCars][13] = CreateVehicle(528,-289.5522,1761.8549,42.7317,88.7211,0,0, -1); // FBI Truck
    FacInfo[1][fCars][14] = CreateVehicle(528,-289.3585,1767.3246,42.7346,88.8119,0,0, -1); // FBI Truck
    FacInfo[1][fCars][15] = CreateVehicle(541, -214.5423, 972.9083, 18.9499, 270.7892, 0, 1, -1);
    FacInfo[1][fCars][16] = CreateVehicle(490, -221.5049, 1005.1257, 19.8362, 180.0747, 0, 0, -1);
    FacInfo[1][fCars][17] = CreateVehicle(596, -211.0183, 999.5654, 19.4509, 90.2578, 0, 1, -1);
    FacInfo[1][fCars][18] = CreateVehicle(596, -211.0594, 996.1339, 19.3684, 90.3630, 0, 1, -1);
    FacInfo[1][fCars][19] = CreateVehicle(596, -210.9824, 992.5442, 19.3087, 90.9485, 0, 1, -1);
    FacInfo[1][fCars][20] = CreateVehicle(598, -226.3662, 991.2088, 19.3501, 270.8829, 0, 1, -1);
    FacInfo[1][fCars][21] = CreateVehicle(598, -226.2994, 994.1726, 19.3764, 270.5101, 0, 1, -1);
    FacInfo[1][fCars][22] = CreateVehicle(598, -226.3310, 997.1476, 19.4011, 270.4089, 0, 1, -1);
    FacInfo[1][fCars][23] = CreateVehicle(598, -226.3195, 1000.1008, 19.4257, 270.2007, 0, 1, -1);
    FacInfo[1][fCars][24] = CreateVehicle(599, -216.1484, 1004.9635, 19.7287, 180.5491, 0, 1, -1);
    //IsFactionVehicle[0] = 1;
   
    // END Sheriff Department

    // FBI
    FacInfo[2][fCars][0] = CreateVehicle(490,983.9520,1740.6132,8.7781,91.3802,0,0, -1); // FBI FBI Rancher
    FacInfo[2][fCars][1] = CreateVehicle(560,984.7666,1735.8877,8.3176,91.8256,0,0, -1); // FBI Sultan
    FacInfo[2][fCars][2] = CreateVehicle(560,984.8378,1731.4255,8.3214,89.4811,0,0, -1); // FBI Sultan 1
    FacInfo[2][fCars][3] = CreateVehicle(490,983.9550,1725.9834,8.8820,91.4448,0,0, -1); // FBI FBI Rancher 1
    FacInfo[2][fCars][4] = CreateVehicle(574,922.9164,1733.2441,8.3736,180.2189,0,0, -1); // FBI Sweeper
    FacInfo[2][fCars][5] = CreateVehicle(574,923.0256,1741.7491,8.3739,0.4885,0,0, -1); // FBI Sweeper 1
    FacInfo[2][fCars][6] = CreateVehicle(497,955.3116,1690.2172,15.9147,269.8438,0,0, -1); // FBI Maverick
    FacInfo[2][fCars][7] = CreateVehicle(563,955.7076,1673.7653,16.5485,266.7361,0,0, -1); // FBI Raindance
    FacInfo[2][fCars][8] = CreateVehicle(563,956.2639,1793.1991,16.5383,266.5507,0,0, -1); // FBI Raindance 1
    FacInfo[2][fCars][9] = CreateVehicle(497,956.4354,1775.1233,15.8899,270.3080,0,0, -1); // FBI Maverick 1
    FacInfo[2][fCars][10] = CreateVehicle(457,952.4708,1759.1654,8.2753,269.0850,0,0, -1); // FBI Caddy
    // END FBI

    // Trucking
    FacInfo[3][fCars][0] = CreateVehicle(443,613.9515,1661.8055,7.6258,65.4541,20,1, -1); // Packer
    FacInfo[3][fCars][1] = CreateVehicle(578,609.6779,1658.5822,7.4712,65.5524,20,1, -1); // DFT
    FacInfo[3][fCars][2] = CreateVehicle(455,606.3912,1654.8247,7.5288,65.3394,20,1, -1); // Barracks
    FacInfo[3][fCars][3] = CreateVehicle(499,601.6682,1651.7390,6.9763,64.4503,20,1, -1); // Benson
    FacInfo[3][fCars][4] = CreateVehicle(579,597.0332,1648.4563,6.9937,64.5170,20,1, -1); // Huntley
    FacInfo[3][fCars][5] = CreateVehicle(554,593.6783,1644.6636,7.0020,65.5592,20,1, -1); // Yosemite
    FacInfo[3][fCars][6] = CreateVehicle(426,589.7032,1641.0945,6.5961,63.8622,20,1, -1); // Premier
    FacInfo[3][fCars][7] = CreateVehicle(457,586.5037,1638.3419,6.5513,64.0913,20,1, -1); // Caddy
    FacInfo[3][fCars][8] = CreateVehicle(515,548.8106,1673.1630,8.0560,244.9677,20,1, -1); // Roadtrain
    FacInfo[3][fCars][9] = CreateVehicle(515,554.5441,1676.9772,8.0086,245.1750,20,1, -1); // Roadtrain 1
    FacInfo[3][fCars][10] = CreateVehicle(515,560.0704,1680.6150,7.9102,245.3367,20,1, -1); // Roadtrain 2
    FacInfo[3][fCars][11] = CreateVehicle(403,565.7695,1684.6665,7.5254,248.2765,20,1, -1); // Linerunner
    FacInfo[3][fCars][12] = CreateVehicle(403,570.8797,1687.7859,7.5567,248.7474,20,1, -1); // Linerunner 1
    FacInfo[3][fCars][13] = CreateVehicle(403,575.7266,1690.7865,7.5209,248.8088,20,1, -1); // Linerunner 2
    FacInfo[3][fCars][14] = CreateVehicle(530,582.1598,1692.3785,6.7624,249.4282,20,1, -1); // Forklift
    FacInfo[3][fCars][15] = CreateVehicle(525,598.3582,1707.7092,6.7959,124.3926,20,1, -1); // Towtruck
    FacInfo[3][fCars][16] = CreateVehicle(552,604.9125,1712.5072,6.6462,305.8436,20,1, -1); // Utility
    FacInfo[3][fCars][17] = CreateVehicle(514,638.6951,1675.1949,7.6526,39.8861,20,1, -1); // Tanker
    FacInfo[3][fCars][18] = CreateVehicle(554,646.6543,1687.0692,6.9897,40.7133,20,1, -1); // Yosemite
    //END Trucking

    // SANews
    FacInfo[4][fCars][0] = CreateVehicle(426,-77.5043,1077.2074,19.4149,359.7816,155,155,-1); // SANews Preimer
    FacInfo[4][fCars][1] = CreateVehicle(582,-83.9299,1077.0951,19.7965,359.3846,1,155,-1); // SANews News Van
    FacInfo[4][fCars][2] = CreateVehicle(582,-87.6237,1077.0453,19.7984,0.3029,1,155,-1); // SANews News Van 1
    // END SANews

    // Construction
    FacInfo[5][fCars][0] = CreateVehicle(573,390.6364,909.9229,21.8986,86.7604,187,187,-1); // Construction Dune
    FacInfo[5][fCars][1] = CreateVehicle(486,390.2454,904.7759,21.2175,86.9365,187,187,-1); // Construction Dozer
    FacInfo[5][fCars][2] = CreateVehicle(486,389.9466,899.5788,21.1045,87.8778,187,187,-1); // Construction Dozer 1
    FacInfo[5][fCars][3] = CreateVehicle(406,388.3332,891.0769,22.2062,83.8657,1,1,-1); // Construction Dumper
    FacInfo[5][fCars][4] = CreateVehicle(455,372.9949,873.4603,20.9433,18.5469,187,187,-1); // Construction Flatbed
    FacInfo[5][fCars][5] = CreateVehicle(455,366.4123,871.2265,20.7601,20.4848,187,187,-1); // Construction Flatbed 1
    FacInfo[5][fCars][6] = CreateVehicle(524,360.2379,869.2755,21.4075,16.9850,187,187,-1); // Construction Mixer
    FacInfo[5][fCars][7] = CreateVehicle(403,344.4289,854.6436,20.9640,19.5411,187,187,-1); // Construction Linerunner
    FacInfo[5][fCars][8] = CreateVehicle(554,313.3116,880.1965,20.4037,314.3613,187,187,-1); // Construction Yosemite
    FacInfo[5][fCars][9] = CreateVehicle(579,310.5575,883.8151,20.2063,315.2536,187,187,-1); // Construction Huntley
    // END Construction
    return 1;
}
I've looked for the problem for a couple of days now, I don't know what's wrong with it.
Reply
#2

IsPlayerInAnyVehicle has playerid as parameters. Not vehicle id.
Use this function:
pawn Код:
stock IsVehicleOccupied(vehid)
{
    for( new all = 0; all < MAX_PLAYERS; all++)
    {
        if (IsPlayerInVehicle(all, vehid))
        {
            return 1;
        }
    }
    return 0;
}
Also, try this, maybe it'll work.
pawn Код:
for(new v = 0; v < 25; v++)
{
    if(!IsVehicleOccupied(FacInfo[1][fCars][i]))
    {
        SetVehicleToRespawn(FacInfo[1][fCars][i]);
    }
}
Reply
#3

Still doing the same thing..
Reply
#4

Try this.
pawn Код:
command(frespawn, playerid, params[])
{
    if(isnull(params)) return SendClientMessage(playerid, USAGE, "Usage: /frespawn [Faction name] (SASD, SAFD, Trucking)");
    {
        if(!strcmp(params, "sasd", true)) // This works, the rest don't...
        {
            for(new v = 0; v < 25; v++)
            {
                if(IsValidVehicle(v) && (!IsVehicleOccupied(FacInfo[1][fCars][i])))
                {
                    SetVehicleToRespawn(FacInfo[1][fCars][i]);
                }
            }
        }
        else if(!strcmp(params, "fbi", true))
        {
            for(new v = 0; v < 25; v++)
            {
                if(IsValidVehicle(v) && (!IsVehicleOccupied(FacInfo[2][fCars][i])))
                {
                    SetVehicleToRespawn(FacInfo[2][fCars][i]);
                }
            }
        }
        else if(!strcmp(params, "trucking", true))
        {
            for(new v = 0; v < 25; v++)
            {
                if(IsValidVehicle(v) && (!IsVehicleOccupied(FacInfo[3][fCars][i])))
                {
                    SetVehicleToRespawn(FacInfo[3][fCars][i]);
                }
            }
        }
        else if(!strcmp(params, "sanews", true))
        {
            for(new v = 0; v < 25; v++)
            {
                if(IsValidVehicle(v) && (!IsVehicleOccupied(FacInfo[4][fCars][i])))
                {
                    SetVehicleToRespawn(FacInfo[4][fCars][i]);
                }
            }
        }
        else if(!strcmp(params, "construction", true))
        {
            for(new v = 0; v < 25; v++)
            {
                if(IsValidVehicle(v) && (!IsVehicleOccupied(FacInfo[5][fCars][i])))
                {
                    SetVehicleToRespawn(FacInfo[5][fCars][i]);
                }
            }
        }
    }
    return 1;
}
Reply
#5

pawn Код:
: error 017: undefined symbol "IsValidVehicle"
Er...?
Reply
#6

https://sampwiki.blast.hk/wiki/IsValidVehicle

Sorry, you need to add "native IsValidVehicle(vehicleid);"
Reply
#7

I love you ;_;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)