Checkpoint help -
sim_sima - 17.06.2011
Hello guys.
Im makeing a train driver job, where the driver has to drive between checkpoints. (Using Incognito's streamer).
I made a /drive command, that will set the checkpoints if the player is inside the train.
I did like this:
pawn Код:
new traincp[5];
new ptraincp[MAX_PLAYERS];
pawn Код:
COMMAND:drive(playerid, params[])
{
if(PlayerInfo[playerid][pJob] == 2)
{
if(IsPlayerInVehicle(playerid, psdrivervehicles[0]))
{
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Train Driver Job started");
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Go to the Checkpoint");
traincp[0] = CreateDynamicRaceCP(1, 1772.4253,-1953.9143,13.5469, 2864.7729,1328.5391,10.8203, 4.0, 0, 0, playerid, 100.0);
}
else SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You must be in the Train or a Bus to drive");
}
else return 0;
return 1;
}
pawn Код:
public OnPlayerEnterDynamicRaceCP(playerid, checkpointid)
{
if(checkpointid == traincp[0])
{
ptraincp[playerid] = 1;
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
SetTimerEx("TrainCPS", 7000, false, "d", playerid);
}
if(checkpointid == traincp[1])
{
ptraincp[playerid] = 2;
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
SetTimerEx("TrainCPS", 7000, false, "d", playerid);
}
if(checkpointid == traincp[2])
{
ptraincp[playerid] = 3;
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
SetTimerEx("TrainCPS", 7000, false, "d", playerid);
}
if(checkpointid == traincp[3])
{
ptraincp[playerid] = 4;
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
SetTimerEx("TrainCPS", 7000, false, "d", playerid);
}
if(checkpointid == traincp[4])
{
ptraincp[playerid] = 5;
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
SetTimerEx("TrainCPS", 7000, false, "d", playerid);
}
return 1;
}
pawn Код:
forward TrainCPS(playerid);
public TrainCPS(playerid)
{
if(ptraincp[playerid] == 1)
{
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Drive to the next Station");
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) ServerMoney +2");
DestroyDynamicRaceCP(traincp[0]);
PlayerInfo[playerid][pMoney] += 2;
PlayerPlaySound(playerid, 1138, 0, 0, 0);
SaveUserData(playerid);
traincp[1] = CreateDynamicRaceCP(1, 2864.7729,1328.5391,10.8203, 1395.0898,2632.3098,10.8203, 4.0, 0, 0, playerid, 100.0);
}
if(ptraincp[playerid] == 2)
{
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Drive to the next Station");
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) ServerMoney +2");
DestroyDynamicRaceCP(traincp[1]);
PlayerInfo[playerid][pMoney] += 2;
PlayerPlaySound(playerid, 1138, 0, 0, 0);
SaveUserData(playerid);
traincp[2] = CreateDynamicRaceCP(1, 1395.0898,2632.3098,10.8203, -1944.3983,95.3343,25.7186, 4.0, 0, 0, playerid, 100.0);
}
if(ptraincp[playerid] == 3)
{
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Drive to the next Station");
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) ServerMoney +2");
DestroyDynamicRaceCP(traincp[2]);
PlayerInfo[playerid][pMoney] += 2;
PlayerPlaySound(playerid, 1138, 0, 0, 0);
SaveUserData(playerid);
traincp[3] = CreateDynamicRaceCP(1, -1944.3983,95.3343,25.7186, 840.6030,-1390.3347,-1.6173, 4.0, 0, 0, playerid, 100.0);
}
if(ptraincp[playerid] == 4)
{
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Drive to the next Station");
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) ServerMoney +2");
DestroyDynamicRaceCP(traincp[3]);
PlayerInfo[playerid][pMoney] += 2;
PlayerPlaySound(playerid, 1138, 0, 0, 0);
SaveUserData(playerid);
traincp[4] = CreateDynamicRaceCP(1, 840.6030,-1390.3347,-1.6173, 1772.4253,-1953.9143,13.5469, 4.0, 0, 0, playerid, 100.0);
}
if(ptraincp[playerid] == 5)
{
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Train driver Job completed");
DestroyDynamicRaceCP(traincp[4]);
DestroyDynamicRaceCP(traincp[0]);
PlayerInfo[playerid][pMoney] += 2;
PlayerPlaySound(playerid, 1138, 0, 0, 0);
SaveUserData(playerid);
}
return 1;
}
But it doesnt work exacteley.
Hope you can help me a bit. Thanks.
Re: Checkpoint help -
Madsen - 17.06.2011
so what exactly seems to be the problem sir?
Re: Checkpoint help -
sim_sima - 17.06.2011
Only the first checkpoint appears
Re: Checkpoint help -
Madsen - 18.06.2011
maybe you need to write else between the cp.
Re: Checkpoint help -
SchurmanCQC - 18.06.2011
Use else if after the first if.
Re: Checkpoint help -
Donya - 18.06.2011
try this
pawn Код:
COMMAND:drive(playerid, params[])
{
if(PlayerInfo[playerid][pJob] == 2)
{
if(IsPlayerInVehicle(playerid, psdrivervehicles[0]))
{
ptraincp[playerid] = 0;
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Train Driver Job started");
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Go to the Checkpoint");
traincp[0] = CreateDynamicRaceCP(1, 1772.4253,-1953.9143,13.5469, 2864.7729,1328.5391,10.8203, 4.0, 0, 0, playerid, 100.0);
}
else SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You must be in the Train or a Bus to drive");
}
else return 0;
return 1;
}
public OnPlayerEnterDynamicRaceCP(playerid, checkpointid)
{
if(checkpointid == traincp[0])
{
ptraincp[playerid] ++;
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
SetTimerEx("TrainCPS", 7000, false, "ii", playerid, ptraincp[playerid]);
}
return 1;
}
forward TrainCPS(playerid, id);
public TrainCPS(playerid, id)
{
switch(id)
{
case 1:
{
DestroyDynamicRaceCP(traincp[0]);
traincp[0] = CreateDynamicRaceCP(1, 2864.7729,1328.5391,10.8203, 1395.0898,2632.3098,10.8203, 4.0, 0, 0, playerid, 100.0);
}
case 2:
{
DestroyDynamicRaceCP(traincp[0]);
traincp[0] = CreateDynamicRaceCP(1, 1395.0898,2632.3098,10.8203, -1944.3983,95.3343,25.7186, 4.0, 0, 0, playerid, 100.0);
}
case 3:
{
DestroyDynamicRaceCP(traincp[0]);
traincp[0] = CreateDynamicRaceCP(1, -1944.3983,95.3343,25.7186, 840.6030,-1390.3347,-1.6173, 4.0, 0, 0, playerid, 100.0);
}
case 4:
{
DestroyDynamicRaceCP(traincp[0]);
traincp[0] = CreateDynamicRaceCP(1, 840.6030,-1390.3347,-1.6173, 1772.4253,-1953.9143,13.5469, 4.0, 0, 0, playerid, 100.0);
}
case 5:
{
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Train driver Job completed");
DestroyDynamicRaceCP(traincp[0]);
ptraincp[playerid] = 0;
}
}
if( id < 5) SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Drive to the next Station");
SendClientMessage(playerid, COLOR_YELLOW, "( ! ) ServerMoney +2");
PlayerInfo[playerid][pMoney] += 2;
PlayerPlaySound(playerid, 1138, 0, 0, 0);
SaveUserData(playerid);
return 1;
}
Re: Checkpoint help -
Wesley221 - 18.06.2011
I got a tutorial about this, check my signature if you still need help
Re: Checkpoint help -
sim_sima - 19.06.2011
Thank you for the help everyone