22.03.2014, 13:18
Hello everybody !
I tryed to make a drive test but I failed and I can't find the bug...The las CP doesn't disapear...
Here it's my callback OnPlayerstateChange
I tryed to make a drive test but I failed and I can't find the bug...The las CP doesn't disapear...
pawn Код:
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
switch(b[playerid])
{
case 1:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 2;
SetPlayerRaceCheckpoint(playerid,0,1061.1392,-1836.7216,13.3777,1039.8059,-1632.2556,13.2578,6);
return 1;
}
case 2:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 3;
SetPlayerRaceCheckpoint(playerid,0,1039.8059,-1632.2556,13.2578,1127.1981,-1574.7451,13.2525,6);
return 1;
}
case 3:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 4;
SetPlayerRaceCheckpoint(playerid,0,1127.1981,-1574.7451,13.2525,1199.7024,-1489.2717,13.2578,6);
return 1;
}
case 4:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 5;
SetPlayerRaceCheckpoint(playerid,0,1199.7024,-1489.2717,13.2578,1205.4761,-1329.9934,13.2732,6);
return 1;
}
case 5:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 6;
SetPlayerRaceCheckpoint(playerid,0,1205.4761,-1329.9934,13.2732,1245.5938,-1148.8344,23.4607,6);
return 1;
}
case 6:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 7;
SetPlayerRaceCheckpoint(playerid,0,1245.5938,-1148.8344,23.4607,1431.1051,-1162.3669,23.5388,6);
return 1;
}
case 7:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 8;
SetPlayerRaceCheckpoint(playerid,0,1431.1051,-1162.3669,23.5388,1573.8604,-1097.8197,23.3386,6);
return 1;
}
case 8:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 9;
SetPlayerRaceCheckpoint(playerid,0,1573.8604,-1097.8197,23.3386,1416.8152,-1031.5005,23.5313,6);
return 1;
}
case 9:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 10;
SetPlayerRaceCheckpoint(playerid,0,1416.8152,-1031.5005,23.5313,1345.0087,-1159.0543,23.5764,6);
return 1;
}
case 10:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 11;
SetPlayerRaceCheckpoint(playerid,0,1345.0087,-1159.0543,23.5764,1344.5813,-1385.4471,13.3903,6);
return 1;
}
case 11:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 12;
SetPlayerRaceCheckpoint(playerid,0,1344.5813,-1385.4471,13.3903,1300.4211,-1575.2240,13.2577,6);
return 1;
}
case 12:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 13;
SetPlayerRaceCheckpoint(playerid,0,1300.4211,-1575.2240,13.2577,1299.7689,-1754.8136,13.2579,6);
return 1;
}
case 13:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 14;
SetPlayerRaceCheckpoint(playerid,0,1299.7689,-1754.8136,13.2579,1260.1609,-1809.0724,13.2848,6);
return 1;
}
case 14:
{
DisablePlayerCheckpoint(playerid);
b[playerid] = 15;
SetPlayerRaceCheckpoint(playerid,1,1260.1609,-1809.0724,13.2848,0,0,0,6);
return 1;
}
case 15:
{
new Float:vhp;
new vehid = GetPlayerVehicleID(playerid);GetVehicleHealth(vehid,vhp);
if(vhp > 650)
{
b[playerid] = 0;
RemovePlayerFromVehicle(playerid);
SetVehicleToRespawn(GetPlayerVehicleID(playerid));
PlayerInfo[playerid][pLicB] = 1;
SendClientMessage(playerid,COLOR_YELLOW,"[D.M.V]: Congratulations, you have aquired your driving license.");
if(PlayerInfo[playerid][pBankAcc] == 1)
{
SendClientMessage(playerid,COLOR_YELLOW,"Your driving test was paid from your bank account !");
PlayerInfo[playerid][pBank] -= 2500;
}
else if(PlayerInfo[playerid][pCash] > 2500)
{
SendClientMessage(playerid,COLOR_YELLOW,"You have passed your driving test and you've paid the instructor with 2500$.");
new oldcash= GetPlayerMoney(playerid);
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,oldcash-2500);
}
}
else
{
b[playerid] = 0;
RemovePlayerFromVehicle(playerid);
SetVehicleToRespawn(GetPlayerVehicleID(playerid));
SendClientMessage(playerid,COLOR_YELLOW,"[D.M.V]: You failed to take the driving license because you wrecked the car !");
}
DisablePlayerCheckpoint(playerid);
return 1;
}
}
return 1;
}
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
{
for(new i=0;i<=30;i++)
{
if(GetPlayerVehicleID(playerid) == dmvCar[i])
{
if(b[playerid] != 1 || amd[playerid] != 1 || ct[playerid] != 1)
{
SendClientMessage(playerid,COLOR_GREY,"You don't have the keys to start the engine !");
RemovePlayerFromVehicle(playerid);
}
else if(b[playerid] == 1 && GetVehicleModel(vehicleid) == 445)
{
SetPlayerRaceCheckpoint(playerid,0,1214.6903,-1839.1429,13.2575,1061.1392,-1836.7216,13.3777,6);
}
}
}
}
return 1;
}