Help with bus job -
LeXuZ - 27.11.2014
Hello, i've been working on making jobs for my server and made a simple bus job, but i made it so when you get to the last check point, it would end the jobs, i didn't want that, so i ask one of my friends if he know how to make it loop, so you can keep doing the job over and over, and he showed me an example, I re wrote it to fit the me, and now i am getting this one error, that i don't seem to be able to fix...
pawn Код:
new Float: BusCP [3] =
{
{1727.2363,1530.5306,10.6643},//error seems to be here
{1943.2926,1310.3976,9.1094},
{2038.1346,1025.7537,10.6719},
{2198.7781,968.7614,10.6719},
{2500.9714,1008.7056,10.6797},
{2631.6003,1279.8844,10.6719},
{2532.7778,1530.7970,10.6719},
{2511.8542,1786.0403,10.6719},
{2531.6519,2287.5186,10.6719},
{2293.9094,2417.8982,10.6830},
{1963.5425,2287.6392,10.9233}
};
and i keep getting this error
Код:
C:\Users\BLACK\Desktop\Freeroam\filterscripts\Jobs0.1.pwn(10) : error 008: must be a constant expression; assumed zero
Big thanks if you could help me out here!
Re: Help with bus job -
PowerPC603 - 27.11.2014
Try:
You're trying to put data given in a 2-D array into a 1-D array.
Re: Help with bus job -
LeXuZ - 27.11.2014
I've tried that, it gives this
Код:
C:\Users\BLACK\Desktop\Freeroam\filterscripts\Jobs0.1.pwn(98) : error 029: invalid expression, assumed zero
when i add this in
Код:
SetPlayerCheckpoint(playerid, BusCP[][0], BusCP[][1], BusCP[][2], 10);
and with out the BusCP[][0]
it gives me
Код:
C:\Users\BLACK\Desktop\Freeroam\filterscripts\Jobs0.1.pwn(98) : error 035: argument type mismatch (argument 2)
Re: Help with bus job -
PowerPC603 - 27.11.2014
You can create the array using [], pawn will automatically count the amount of indices upon compiling.
But accessing the values afterwards, you always need to supply it with both indices:
BusCP[7][0] for example.
Or for a random coordinate:
pawn Код:
new RandCoord = random(sizeof(BusCP));
new Float:x = BusCP[RandCoord][0];
new Float:y = BusCP[RandCoord][1];
new Float:z = BusCP[RandCoord][2];
Re: Help with bus job -
LeXuZ - 27.11.2014
But will this make the bus stops random?
Re: Help with bus job -
PowerPC603 - 27.11.2014
Yes it will, as it always takes a random number between 0 and the max-size of that array.
You could do this:
pawn Код:
new RandCoord = random(sizeof(BusCP));
new Float:x = BusCP[RandCoord][0];
new Float:y = BusCP[RandCoord][1];
new Float:z = BusCP[RandCoord][2];
SetPlayerCheckpoint(playerid, x, y, z, 10);
Or more directly:
pawn Код:
new RandCoord = random(sizeof(BusCP));
SetPlayerCheckpoint(playerid, BusCP[RandCoord][0], BusCP[RandCoord][1], BusCP[RandCoord][2], 10);
Re: Help with bus job -
LeXuZ - 27.11.2014
But, i didn't want this one to be random, i wanted it so it was a circle type of job
Re: Help with bus job -
LeXuZ - 27.11.2014
This was the first way i did it but it just stopped at the 12th one, but i wanted it to repeat
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 431)
{
if(BusDriver[playerid] == 1)
{
BusDriver[playerid] = 2;
SetPlayerCheckpoint(playerid, 1727.2363,1530.5306,10.6643, 5);//busstop2
SCM(playerid, -1, "Go to the next bus stop!");
return 1;
}
if(BusDriver[playerid] == 2)
{
BusDriver[playerid] = 3;
SetPlayerCheckpoint(playerid, 1943.2926,1310.3976,9.1094, 5);//busstop3
pInfo[playerid][Credits] ++;
GivePlayerMoney(playerid, 500);
return 1;
}
if(BusDriver[playerid] == 3)
{
BusDriver[playerid] = 4;
SetPlayerCheckpoint(playerid, 2038.1346,1025.7537,10.6719, 5);//busstop4
GivePlayerMoney(playerid, 500);
return 1;
}
if(BusDriver[playerid] == 4)
{
BusDriver[playerid] = 5;
SetPlayerCheckpoint(playerid, 2198.7781,968.7614,10.6719, 5);//busstop5
GivePlayerMoney(playerid, 500);
return 1;
}
if(BusDriver[playerid] == 5)
{
BusDriver[playerid] = 6;
SetPlayerCheckpoint(playerid, 2500.9714,1008.7056,10.6797, 5);//busstop6
pInfo[playerid][Credits] ++;
GivePlayerMoney(playerid, 500);
return 1;
}
if(BusDriver[playerid] == 6)
{
BusDriver[playerid] = 7;
SetPlayerCheckpoint(playerid, 2631.6003,1279.8844,10.6719, 5);//busstop7
GivePlayerMoney(playerid, 500);
return 1;
}
if(BusDriver[playerid] == 7)
{
BusDriver[playerid] = 8;
SetPlayerCheckpoint(playerid, 2532.7778,1530.7970,10.6719, 5);//busstop8
GivePlayerMoney(playerid, 500);
return 1;
}
if(BusDriver[playerid] == 8)
{
BusDriver[playerid] = 9;
SetPlayerCheckpoint(playerid, 2511.8542,1786.0403,10.6719, 5);//busstop9
GivePlayerMoney(playerid, 500);
return 1;
}
if(BusDriver[playerid] == 9)
{
BusDriver[playerid] = 10;
SetPlayerCheckpoint(playerid, 2531.6519,2287.5186,10.6719, 5);//busstop10
GivePlayerMoney(playerid, 500);
return 1;
}
if(BusDriver[playerid] == 10)
{
BusDriver[playerid] = 11;
SetPlayerCheckpoint(playerid, 2293.9094,2417.8982,10.6830, 5);//busstop11
GivePlayerMoney(playerid, 500);
return 1;
}
if(BusDriver[playerid] == 11)
{
BusDriver[playerid] = 12;
SetPlayerCheckpoint(playerid, 1963.5425,2287.6392,10.9233, 5);//busstop12
GivePlayerMoney(playerid, 500);
return 1;
}
Re: Help with bus job -
PowerPC603 - 27.11.2014
Something like this would do the trick.
It should start at the first index of the array and work it's way up until the end of the array, then start over from the first set of coordinates, so it keeps going.
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 431)
{
switch (BusDriver[playerid])
{
case 1:
{
SCM(playerid, -1, "Go to the next bus stop!");
}
case 2:
{
pInfo[playerid][Credits] ++;
GivePlayerMoney(playerid, 500);
}
case 3, 4, 6, 7, 8, 9, 10, 11:
{
GivePlayerMoney(playerid, 500);
}
case 5:
{
pInfo[playerid][Credits] ++;
}
}
// Increase the value of BusDriver every time you enter a checkpoint
BusDriver[playerid] = BusDriver[playerid] + 1;
// If the end of the array has been reached, set it back to 1 so you start over your bus-route
if (BusDriver[playerid] == sizeof(BusCP))
BusDriver[playerid] = 1;
// Set the checkpoint based on which step in the route you are driving
// Use "-1" because arrays don't start at 1, they start at 0, we need to substract 1 from the BusDriver variable
SetPlayerCheckpoint(playerid, BusCP[BusDriver[playerid] - 1][0], BusCP[BusDriver[playerid] - 1][1], BusCP[BusDriver[playerid] - 1][2], 5);//busstop2