[Help Count]AddStaticVehicle
#1

How Would I count Private vehicles I have one Ideal but it only counts up to Five Vehicles and makes them private but any more over Private Vehicles u Can Enter and Drive off

If I change it to For(new PV=0; PV != 15 PV++)
Still only counts 5 Or 6 Any more over there not private..

pawn Код:
new TaxiVehicleLS[14];
Under OnGameModeInit
pawn Код:
public OnGameModeInit()
{
    TaxiVehicleLS[1] = AddStaticVehicleEx(437,1779.7747,-1909.4396,13.5150,270.6893,-1, -1, -1); // taxibus 1
    TaxiVehicleLS[2] = AddStaticVehicleEx(437,1779.9159,-1905.5310,13.5226,270.6135,-1, -1, -1); // taxibus 2
    TaxiVehicleLS[3] = AddStaticVehicleEx(431,1780.0096,-1913.6144,13.4936,271.8171,-1, -1, -1); // taxibus 3
    TaxiVehicleLS[4] = AddStaticVehicleEx(431,1780.6726,-1918.0997,13.4908,271.9992,-1, -1, -1); // taxibus 4
    TaxiVehicleLS[5] = AddStaticVehicleEx(420,1805.4719,-1900.7300,13.1805,0.3763,-1, -1, -1); // taxicar 1
    TaxiVehicleLS[6] = AddStaticVehicleEx(420,1805.4923,-1907.5823,13.1766,0.0030,-1, -1, -1); // taxicar 2
    TaxiVehicleLS[7] = AddStaticVehicleEx(420,1805.5555,-1914.0067,13.1747,0.5064,-1, -1, -1); // taxicar 3
    TaxiVehicleLS[8] = AddStaticVehicleEx(420,1805.6178,-1920.7666,13.1712,359.7094,-1, -1, -1); // taxicar 4
    TaxiVehicleLS[9] = AddStaticVehicleEx(420,1805.5529,-1927.7074,13.1670,359.8926,-1, -1, -1); // taxicar 5
    TaxiVehicleLS[10] = AddStaticVehicleEx(420,1802.5177,-1933.4368,13.1809,301.5674,-1, -1, -1); // taxicar 6
    TaxiVehicleLS[11] = AddStaticVehicleEx(420,1795.1158,-1934.3496,13.2183,271.0070,-1, -1, -1); // taxicar 7
    TaxiVehicleLS[12] = AddStaticVehicleEx(438,1783.0457,-1934.3837,13.4554,270.3791,-1, -1, -1); // taxicar 8
    TaxiVehicleLS[13] = AddStaticVehicleEx(438,1776.6875,-1934.2457,13.4331,270.3553,-1, -1, -1); // taxicar 9

    new count,vplate[10];
    for(new PV=0; PV < MAX_VEHICLES; PV++)
    {
        if(TaxiVehicleLS[PV] == INVALID_VEHICLE_ID)
        {
            format(vplate,sizeof(vplate),"LSTV");
            SetVehicleNumberPlate(TaxiVehicleLS[PV], vplate);
            SetVehicleToRespawn(TaxiVehicleLS[PV]);
            count ++;
        }
           return count;  
      }
      return 1;
}
under OnPlayerStateChange
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
         new count;
    new Vehicle = GetPlayerVehicleID(playerid);
    if(newstate == PLAYER_STATE_DRIVER)
    {
        for(new PV=0; PV < MAX_VEHICLES; PV++)
        {
        else if( Vehicle == TaxiVehicleLS[PV])
            {
                if(UserInfo[playerid][uTaxiTeam] != 1)
                {
                    SendClientMessage(playerid, 0x33AA33AA, "You Are Not A Taxi Driver");
                    RemovePlayerFromVehicle(playerid);
                }
                else
                {
                    format(string2, sizeof(string2), "You Entered A %s, Owned By LSTX", VehicleNames[GetVehicleModel(Vehicle) -400]);
                    SendClientMessage(playerid, GREEN, string2);
                    SendClientMessage(playerid, ORANGE,"You Enter A Taxi Default price $50 To Change type /fare <price>");
                }
            }
               count ++;
        }
        return count;
    }
    return 1;
}
Reply
#2

Firstly, arrays always start at 0, not 1.

You are ending the loop with a return so it won't be able to continue, I don't see why you're using 'count' anyway...


pawn Код:
new TaxiVehicleLS[13];

public OnGameModeInit()
{
    TaxiVehicleLS[0] = AddStaticVehicleEx(437,1779.7747,-1909.4396,13.5150,270.6893,-1, -1, -1); // taxibus 1
    TaxiVehicleLS[1] = AddStaticVehicleEx(437,1779.9159,-1905.5310,13.5226,270.6135,-1, -1, -1); // taxibus 2
    TaxiVehicleLS[2] = AddStaticVehicleEx(431,1780.0096,-1913.6144,13.4936,271.8171,-1, -1, -1); // taxibus 3
    TaxiVehicleLS[3] = AddStaticVehicleEx(431,1780.6726,-1918.0997,13.4908,271.9992,-1, -1, -1); // taxibus 4
    TaxiVehicleLS[4] = AddStaticVehicleEx(420,1805.4719,-1900.7300,13.1805,0.3763,-1, -1, -1); // taxicar 1
    TaxiVehicleLS[5] = AddStaticVehicleEx(420,1805.4923,-1907.5823,13.1766,0.0030,-1, -1, -1); // taxicar 2
    TaxiVehicleLS[6] = AddStaticVehicleEx(420,1805.5555,-1914.0067,13.1747,0.5064,-1, -1, -1); // taxicar 3
    TaxiVehicleLS[7] = AddStaticVehicleEx(420,1805.6178,-1920.7666,13.1712,359.7094,-1, -1, -1); // taxicar 4
    TaxiVehicleLS[8] = AddStaticVehicleEx(420,1805.5529,-1927.7074,13.1670,359.8926,-1, -1, -1); // taxicar 5
    TaxiVehicleLS[9] = AddStaticVehicleEx(420,1802.5177,-1933.4368,13.1809,301.5674,-1, -1, -1); // taxicar 6
    TaxiVehicleLS[10] = AddStaticVehicleEx(420,1795.1158,-1934.3496,13.2183,271.0070,-1, -1, -1); // taxicar 7
    TaxiVehicleLS[11] = AddStaticVehicleEx(438,1783.0457,-1934.3837,13.4554,270.3791,-1, -1, -1); // taxicar 8
    TaxiVehicleLS[12] = AddStaticVehicleEx(438,1776.6875,-1934.2457,13.4331,270.3553,-1, -1, -1); // taxicar 9

    for(new PV = 0; PV < sizeof(TaxiVehicleLS); PV++)
    {
        if(TaxiVehicleLS[PV] != INVALID_VEHICLE_ID)
        {
            SetVehicleNumberPlate(TaxiVehicleLS[PV], "LSTV");
            SetVehicleToRespawn(TaxiVehicleLS[PV]);
        }
    }
    return 1;
}

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new Vehicle = GetPlayerVehicleID(playerid);
        for(new PV = 0; PV < sizeof(TaxiVehicleLS); PV++)
        {
            if(Vehicle == TaxiVehicleLS[PV])
            {
                if(UserInfo[playerid][uTaxiTeam] != 1)
                {
                    SendClientMessage(playerid, 0x33AA33AA, "You Are Not A Taxi Driver");
                    RemovePlayerFromVehicle(playerid);
                }
                else
                {
                    new string2[150];
                    format(string2, sizeof(string2), "You Entered A %s, Owned By LSTV", VehicleNames[GetVehicleModel(Vehicle) - 400]);
                    SendClientMessage(playerid, GREEN, string2);
                    SendClientMessage(playerid, ORANGE,"You Enter A Taxi Default price $50 To Change type /fare <price>");
                }
            }
        }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by BenzoAMG
Посмотреть сообщение
Firstly, arrays always start at 0, not 1.

You are ending the loop with a return so it won't be able to continue, I don't see why you're using 'count' anyway...


pawn Код:
new TaxiVehicleLS[13];

public OnGameModeInit()
{
    TaxiVehicleLS[0] = AddStaticVehicleEx(437,1779.7747,-1909.4396,13.5150,270.6893,-1, -1, -1); // taxibus 1
    TaxiVehicleLS[1] = AddStaticVehicleEx(437,1779.9159,-1905.5310,13.5226,270.6135,-1, -1, -1); // taxibus 2
    TaxiVehicleLS[2] = AddStaticVehicleEx(431,1780.0096,-1913.6144,13.4936,271.8171,-1, -1, -1); // taxibus 3
    TaxiVehicleLS[3] = AddStaticVehicleEx(431,1780.6726,-1918.0997,13.4908,271.9992,-1, -1, -1); // taxibus 4
    TaxiVehicleLS[4] = AddStaticVehicleEx(420,1805.4719,-1900.7300,13.1805,0.3763,-1, -1, -1); // taxicar 1
    TaxiVehicleLS[5] = AddStaticVehicleEx(420,1805.4923,-1907.5823,13.1766,0.0030,-1, -1, -1); // taxicar 2
    TaxiVehicleLS[6] = AddStaticVehicleEx(420,1805.5555,-1914.0067,13.1747,0.5064,-1, -1, -1); // taxicar 3
    TaxiVehicleLS[7] = AddStaticVehicleEx(420,1805.6178,-1920.7666,13.1712,359.7094,-1, -1, -1); // taxicar 4
    TaxiVehicleLS[8] = AddStaticVehicleEx(420,1805.5529,-1927.7074,13.1670,359.8926,-1, -1, -1); // taxicar 5
    TaxiVehicleLS[9] = AddStaticVehicleEx(420,1802.5177,-1933.4368,13.1809,301.5674,-1, -1, -1); // taxicar 6
    TaxiVehicleLS[10] = AddStaticVehicleEx(420,1795.1158,-1934.3496,13.2183,271.0070,-1, -1, -1); // taxicar 7
    TaxiVehicleLS[11] = AddStaticVehicleEx(438,1783.0457,-1934.3837,13.4554,270.3791,-1, -1, -1); // taxicar 8
    TaxiVehicleLS[12] = AddStaticVehicleEx(438,1776.6875,-1934.2457,13.4331,270.3553,-1, -1, -1); // taxicar 9

    for(new PV = 0; PV < sizeof(TaxiVehicleLS); PV++)
    {
        if(TaxiVehicleLS[PV] != INVALID_VEHICLE_ID)
        {
            SetVehicleNumberPlate(TaxiVehicleLS[PV], "LSTV");
            SetVehicleToRespawn(TaxiVehicleLS[PV]);
        }
    }
    return 1;
}

public OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new Vehicle = GetPlayerVehicleID(playerid);
        for(new PV = 0; PV < sizeof(TaxiVehicleLS); PV++)
        {
            if(Vehicle == TaxiVehicleLS[PV])
            {
                if(UserInfo[playerid][uTaxiTeam] != 1)
                {
                    SendClientMessage(playerid, 0x33AA33AA, "You Are Not A Taxi Driver");
                    RemovePlayerFromVehicle(playerid);
                }
                else
                {
                    new string2[150];
                    format(string2, sizeof(string2), "You Entered A %s, Owned By LSTV", VehicleNames[GetVehicleModel(Vehicle) - 400]);
                    SendClientMessage(playerid, GREEN, string2);
                    SendClientMessage(playerid, ORANGE,"You Enter A Taxi Default price $50 To Change type /fare <price>");
                }
            }
        }
    }
    return 1;
}
E:\Server\gamemodes\TLRP.pwn(11497) : error 020: invalid symbol name ""
E:\Server\gamemodes\TLRP.pwn(11497) : error 029: invalid expression, assumed zero
E:\Server\gamemodes\TLRP.pwn(11497) : warning 215: expression has no effect
E:\Server\gamemodes\TLRP.pwn(11497) : error 017: undefined symbol "PV"
E:\Server\gamemodes\TLRP.pwn(11497) : fatal error 107: too many error messages on one line

So I changed for(new PV = 0; PV < sizeof(TaxiVehicleLS); PV++)
To
for(new PV = 0; PV < MAX_VEHICLES; PV++)

ANd it compiled but Still only counting 5 vehicles i removed the Count from it Any other ideals

I just dont have Taxi i have other private vehicles aswell ..
Reply
#4

The sizeof operator should work. If you use MAX_VEHICLES then you'll go out of bounds which will just make things worse. Invalid symbol name really only pops up if you try to use a reserved word or a function name as the name of a variable. Doing something like "new static" would trigger this error.
Reply
#5

Okay well you see the code.. So why it saying

E:\Server\gamemodes\TLRP.pwn(11497) : error 020: invalid symbol name ""
E:\Server\gamemodes\TLRP.pwn(11497) : error 029: invalid expression, assumed zero
E:\Server\gamemodes\TLRP.pwn(11497) : warning 215: expression has no effect
E:\Server\gamemodes\TLRP.pwn(11497) : error 017: undefined symbol "PV"
E:\Server\gamemodes\TLRP.pwn(11497) : fatal error 107: too many error messages on one line
Reply
#6

I have no clue. If I paste your code into a blank file it works flawlessly.
Reply
#7

Hmm let me try that then...

So if i have different private vehicles using PV as vehicle Size.. Would it still work

Yeah thats what is was ur code work thanks For the help Vince..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)