03.01.2011, 13:40
I'm making a bus system, but for some reason the routes (check points that show you which way to go) are working, but the stops are not.
I will post all code related to my bus system:
Now, I enter a route checkpoint and the next one is created, but I enter a stop checkpoint and NOTHING happens.
I will post all code related to my bus system:
pawn Код:
enum BusDetails {
Float: CheckX,
Float: CheckY,
Float: CheckZ,
Type //1 = stop, 0 = route
}
new busDetails[51][BusDetails];
new busStep[MAX_PLAYERS];
pawn Код:
public OnGameModeInit()
{
busDetails[1][CheckX] = -2296.3999;
busDetails[1][CheckY] = 2371.6006;
busDetails[1][CheckZ] = 5.5731;
busDetails[1][Type] = 0;
busDetails[2][CheckX] = -2372.3784;
busDetails[2][CheckY] = 2422.6028;
busDetails[2][CheckZ] = 8.3968;
busDetails[2][Type] = 0;
busDetails[3][CheckX] = -2488.5;
busDetails[3][CheckY] = 2432.1;
busDetails[3][CheckZ] = 25.4;
busDetails[3][Type] = 1;
pawn Код:
command(busroute, playerid, params[])
{
#pragma unused params
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 437) // 437 is the coach model
{
if(Jobs[Player[playerid][Job]][JobType] == 8) {
SendClientMessage(playerid, WHITE, "You have started the bus route.");
SendClientMessage(playerid, WHITE, "The small checkpoints are the route, the large checkpoints are stops.");
SetPlayerCheckpoint(playerid, busDetails[1][CheckX],busDetails[1][CheckY],busDetails[1][CheckZ], 2);
SetPVarInt(playerid, "BusRoute", 1);
busStep[playerid] = 1;
}
}
}
pawn Код:
public UnfreezePlayer(playerid)
{
TogglePlayerControllable(playerid, 1);
}
public OnPlayerEnterCheckpoint(playerid)
{
if(GetPVarInt(playerid, "BusRoute") == 1) {
if(IsPlayerInRangeOfPoint(playerid, 5.0, busDetails[busStep[playerid]][CheckX], busDetails[busStep[playerid]][CheckY], busDetails[busStep[playerid]][CheckZ])) {
if(busDetails[busStep[playerid]][Type] == 1) {
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.0, 0.0);
TogglePlayerControllable(playerid, 0);
SetTimerEx("UnfreezePlayer", 5000, false, "i", playerid);
SendClientMessage(playerid, WHITE, "Wait for the customers to get on...");
}
if(busDetails[busStep[playerid] + 1][Type] == 0) {
SetPlayerCheckpoint(playerid, busDetails[busStep[playerid] + 1][CheckX], busDetails[busStep[playerid] + 1][CheckY], busDetails[busStep[playerid] + 1][CheckZ], 2.0);
} else {
SetPlayerCheckpoint(playerid, busDetails[busStep[playerid] + 1][CheckX], busDetails[busStep[playerid] + 1][CheckY], busDetails[busStep[playerid] + 1][CheckZ], 10.0);
SendClientMessage(playerid, WHITE, "The next checkpoint is a stop, make sure you let the customers on!");
}
busStep[playerid]++;
}
}
Now, I enter a route checkpoint and the next one is created, but I enter a stop checkpoint and NOTHING happens.