CMD:milkcow(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pJob] == 23 || PlayerInfo[playerid][pJob2] == 23)
{
if(PlayerInfo[playerid][pMilkTime] == 0)
{
if(IsMilkingCows[playerid] == 0)
{
SendClientMessage(playerid, COLOR_LIGHTBLUE, " *INFO: Milk all of the cows, then go to into the barn to finish.");
SetPlayerCheckpoint(playerid, -400.5316,-1352.9856,24.4025, 1.0);
IsMilkingCows[playerid] = 1;
PlayerInfo[playerid][pMilkTime] += 1800;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " You are already milking the cows !");
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " Wait until the cows are ready to be milked again!");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "You are not a Farmer.");
return 1;
}
}
return 1;
}
else if(IsMilkingCows[playerid] > 0)//farmerjob
{
if(IsMilkingCows[playerid] == 1)
{
MilkTime[playerid] += 1;
TogglePlayerControllable(playerid, 0);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, -415.4362,-1367.9500,23.7354,1.0);
IsMilkingCows[playerid] = 2;
}
else if(IsMilkingCows[playerid] == 2)
{
MilkTime[playerid] += 1;
TogglePlayerControllable(playerid, 0);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, -429.1931,-1357.7994,24.1332,1.0);
IsMilkingCows[playerid] = 3;
}
else if(IsMilkingCows[playerid] == 3)
{
MilkTime[playerid] += 1;//1
TogglePlayerControllable(playerid, 0);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, -419.0900,-1347.9215,24.7898,1.0);
IsMilkingCows[playerid] = 4;
}
else if(IsMilkingCows[playerid] == 4)
{
MilkTime[playerid] += 1;
TogglePlayerControllable(playerid, 0);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, -404.1791,-1325.3143,26.9061,1.0);
IsMilkingCows[playerid] = 5;
}
else if(IsMilkingCows[playerid] == 5)
{
MilkTime[playerid] += 1;
TogglePlayerControllable(playerid, 0);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, -426.7935,-1327.0194,28.7070,1.0);
IsMilkingCows[playerid] = 6;
}
else if(IsMilkingCows[playerid] == 6)
{
CowEndTime[playerid] += 1;
TogglePlayerControllable(playerid, 0);
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, -366.2761,-1428.3999,25.7266,3.0);
IsMilkingCows[playerid] = 7;
}
else if(IsMilkingCows[playerid] == 7)
{
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, COLOR_LIGHTBLUE, " Well Done! Here's your Pay Check of $100");
IsMilkingCows[playerid] = 0;
GivePlayerMoney(playerid, 100);
}
Debug your code by putting print lines in the code so you can interactively see what the code is doing.
For instance: pawn Код:
|
MilkingCows > 0
Milking Cows == 1
Disabled checkpoint, setting new one
-End of code block
else if(IsMilkingCows[playerid] > 0)//farmerjob
{
print("Milking cows > 0");
if(IsMilkingCows[playerid] == 1)
{
print("\tMilking cows == 1");
MilkTime[playerid] += 1;
TogglePlayerControllable(playerid, 0);
DisablePlayerCheckpoint(playerid);
print("\tDisabled checkpoint, setting new one");
SetPlayerCheckpoint(playerid, -415.4362,-1367.9500,23.7354,1.0);
IsMilkingCows[playerid] = 2;
print("\t- End of code block");
}
else if(IsMilkingCows[playerid] == 2)
{
MilkTime[playerid] += 1;
print("\tMilking cows == 2");