problem onplayerentervehicle
#1

pawn Код:
NoobVehicle = CreateVehicle(462,1721.9529,1511.4315,10.4106,164.7907,57,0,9999999999); // S.Faggio1
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1720.3893,1503.2946,10.4110,345.9825,57,0,9999999999); // S.Faggio2
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1719.7360,1500.5607,10.4138,164.3369,57,0,9999999999); // S.Faggio3
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1717.3511,1491.9044,10.4172,343.0242,57,0,9999999999); // S.Faggio4
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1716.5875,1489.1969,10.4138,158.4056,57,0,9999999999); // S.Faggio5
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1714.1150,1481.0281,10.4111,339.1361,57,0,9999999999); // S.Faggio6
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1713.2162,1478.3274,10.4185,160.3177,57,0,9999999999); // S.Faggio7
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1709.9103,1468.5326,10.4187,343.3939,57,0,9999999999); // S.Faggio8
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1709.0266,1465.8184,10.4120,158.6395,57,0,9999999999); // S.Faggio9
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1702.9109,1445.6056,10.4179,347.2465,57,0,9999999999); // S.Faggio10
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1702.7789,1442.8165,10.4166,178.2944,57,0,9999999999); // S.Faggio11
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1702.4158,1431.1669,10.2642,357.7253,57,0,9999999999); // S.Faggio12
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1702.4651,1428.3623,10.2394,186.1544,57,0,9999999999); // S.Faggio13
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1703.1547,1418.7538,10.2453,7.9907,57,0,9999999999); // S.Faggio14
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1703.6289,1415.9854,10.2399,191.2389,57,0,9999999999); // S.Faggio15
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1705.2295,1406.1152,10.2398,12.9132,57,0,9999999999); // S.Faggio16
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1706.0365,1403.3656,10.2396,196.6373,57,0,9999999999); // S.Faggio17
    SetVehicleNumberPlate(NoobVehicle,"Noob");
    NoobVehicle = CreateVehicle(462,1708.4735,1393.7400,10.2425,17.8774,57,0,9999999999); // S.Faggio18
    SetVehicleNumberPlate(NoobVehicle,"Noob");
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(vehicleid == NoobVehicle[1]){SetPlayerPos(playerid,0,0,0);}
    return 1;
}
ERROR:
pawn Код:
C:\Users\Lirbo\Desktop\IRP\gamemodes\BBRP.pwn(321) : error 028: invalid subscript (not an array or too many subscripts): "NoobVehicle"
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
The problem is because the [1] after the NoobVehicle in the public OnPlayerEnterVehicle...
but if I'm not putting it so its won't work (the SetPlayerPos(playerid,0,0,0);)
Reply
#2

You should've used an array to store the vehicleid of each noob vehicle and assuming you want to check if the player is about to enter one of those vehicles:
pawn Код:
// global:
new NoobVehicle[18];

// creating the vehicles:
NoobVehicle[0] = CreateVehicle(462,1721.9529,1511.4315,10.4106,164.7907,57,0,9999999999); // S.Faggio1
SetVehicleNumberPlate(NoobVehicle[0],"Noob");
NoobVehicle[1] = CreateVehicle(462,1720.3893,1503.2946,10.4110,345.9825,57,0,9999999999); // S.Faggio2
SetVehicleNumberPlate(NoobVehicle[1],"Noob");
NoobVehicle[2] = CreateVehicle(462,1719.7360,1500.5607,10.4138,164.3369,57,0,9999999999); // S.Faggio3
SetVehicleNumberPlate(NoobVehicle[2],"Noob");
NoobVehicle[3] = CreateVehicle(462,1717.3511,1491.9044,10.4172,343.0242,57,0,9999999999); // S.Faggio4
SetVehicleNumberPlate(NoobVehicle[3],"Noob");
NoobVehicle[4] = CreateVehicle(462,1716.5875,1489.1969,10.4138,158.4056,57,0,9999999999); // S.Faggio5
SetVehicleNumberPlate(NoobVehicle[4],"Noob");
NoobVehicle[5] = CreateVehicle(462,1714.1150,1481.0281,10.4111,339.1361,57,0,9999999999); // S.Faggio6
SetVehicleNumberPlate(NoobVehicle[5],"Noob");
NoobVehicle[6] = CreateVehicle(462,1713.2162,1478.3274,10.4185,160.3177,57,0,9999999999); // S.Faggio7
SetVehicleNumberPlate(NoobVehicle[6],"Noob");
NoobVehicle[7] = CreateVehicle(462,1709.9103,1468.5326,10.4187,343.3939,57,0,9999999999); // S.Faggio8
SetVehicleNumberPlate(NoobVehicle[7],"Noob");
NoobVehicle[8] = CreateVehicle(462,1709.0266,1465.8184,10.4120,158.6395,57,0,9999999999); // S.Faggio9
SetVehicleNumberPlate(NoobVehicle[8],"Noob");
NoobVehicle[9] = CreateVehicle(462,1702.9109,1445.6056,10.4179,347.2465,57,0,9999999999); // S.Faggio10
SetVehicleNumberPlate(NoobVehicle[9],"Noob");
NoobVehicle[10] = CreateVehicle(462,1702.7789,1442.8165,10.4166,178.2944,57,0,9999999999); // S.Faggio11
SetVehicleNumberPlate(NoobVehicle[10],"Noob");
NoobVehicle[11] = CreateVehicle(462,1702.4158,1431.1669,10.2642,357.7253,57,0,9999999999); // S.Faggio12
SetVehicleNumberPlate(NoobVehicle[11],"Noob");
NoobVehicle[12] = CreateVehicle(462,1702.4651,1428.3623,10.2394,186.1544,57,0,9999999999); // S.Faggio13
SetVehicleNumberPlate(NoobVehicle[12],"Noob");
NoobVehicle[13] = CreateVehicle(462,1703.1547,1418.7538,10.2453,7.9907,57,0,9999999999); // S.Faggio14
SetVehicleNumberPlate(NoobVehicle[13],"Noob");
NoobVehicle[14] = CreateVehicle(462,1703.6289,1415.9854,10.2399,191.2389,57,0,9999999999); // S.Faggio15
SetVehicleNumberPlate(NoobVehicle[14],"Noob");
NoobVehicle[15] = CreateVehicle(462,1705.2295,1406.1152,10.2398,12.9132,57,0,9999999999); // S.Faggio16
SetVehicleNumberPlate(NoobVehicle[15],"Noob");
NoobVehicle[16] = CreateVehicle(462,1706.0365,1403.3656,10.2396,196.6373,57,0,9999999999); // S.Faggio17
SetVehicleNumberPlate(NoobVehicle[16],"Noob");
NoobVehicle[17] = CreateVehicle(462,1708.4735,1393.7400,10.2425,17.8774,57,0,9999999999); // S.Faggio18
SetVehicleNumberPlate(NoobVehicle[17],"Noob");

// if you want in which vehicle is going to enter, use OnPlayerEnterVehicle callback
// else if you want which vehicle entered, use OnPlayerStateChange and check if newstate is PLAYER_STATE_DRIVER
if (IsNoobVehicle(vehicleid))
{
    // the vehicle is one of those you created above.
}

// function:
IsNoobVehicle(vehicleid)
{
    for (new i; i != sizeof (NoobVehicle); ++i)
    {
        if (vehicleid == NoobVehicle[i]) return 1;
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)