Checkpoint help.
#1

Hey, I'm having problems with jobs. For example, farmer, when I use /milkcow it sets a checkpoint, and then its supposed to set another checkpoint but it doesnt =/ Need help if any1 can help me solve it, there are no errors or any warnings. Here's the code;

milkcow cmd:
PHP код:
CMD:milkcow(playeridparams[])
{
    if(
IsPlayerConnected(playerid))
    {
        if(
PlayerInfo[playerid][pJob] == 23 || PlayerInfo[playerid][pJob2] == 23)
        {
            if(
PlayerInfo[playerid][pMilkTime] == 0)
            {
                if(
IsMilkingCows[playerid] == 0)
                {
                    
SendClientMessage(playeridCOLOR_LIGHTBLUE"  *INFO: Milk all of the cows, then go to into the barn to finish.");
                    
SetPlayerCheckpoint(playerid, -400.5316,-1352.9856,24.40251.0);
                    
IsMilkingCows[playerid] = 1;
                    
PlayerInfo[playerid][pMilkTime] += 1800;
                }
                else
                {
                    
SendClientMessage(playeridCOLOR_GRAD2"  You are already milking the cows !");
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_GRAD2" Wait until the cows are ready to be milked again!");
                return 
1;
            }
        }
        else
        {
            
SendClientMessage(playeridCOLOR_GRAD2"You are not a Farmer.");
            return 
1;
        }
    }
    return 
1;

and the other checkpoints, under onplayerentercheckpoint;
PHP код:
else if(IsMilkingCows[playerid] > 0)//farmerjob
    
{
        if(
IsMilkingCows[playerid] == 1)
        {
            
MilkTime[playerid] += 1;
            
TogglePlayerControllable(playerid0);
            
DisablePlayerCheckpoint(playerid);
            
SetPlayerCheckpoint(playerid, -415.4362,-1367.9500,23.7354,1.0);
            
IsMilkingCows[playerid] = 2;
        }
        else if(
IsMilkingCows[playerid] == 2)
        {
            
MilkTime[playerid] += 1;
            
TogglePlayerControllable(playerid0);
            
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(playerid0);
            
DisablePlayerCheckpoint(playerid);
            
SetPlayerCheckpoint(playerid, -419.0900,-1347.9215,24.7898,1.0);
            
IsMilkingCows[playerid] = 4;
        }
        else if(
IsMilkingCows[playerid] == 4)
        {
            
MilkTime[playerid] += 1;
            
TogglePlayerControllable(playerid0);
               
DisablePlayerCheckpoint(playerid);
               
SetPlayerCheckpoint(playerid, -404.1791,-1325.3143,26.9061,1.0);
               
IsMilkingCows[playerid] = 5;
        }
        else if(
IsMilkingCows[playerid] == 5)
        {
            
MilkTime[playerid] += 1;
            
TogglePlayerControllable(playerid0);
               
DisablePlayerCheckpoint(playerid);
               
SetPlayerCheckpoint(playerid, -426.7935,-1327.0194,28.7070,1.0);
               
IsMilkingCows[playerid] = 6;
        }
        else if(
IsMilkingCows[playerid] == 6)
        {
            
CowEndTime[playerid] += 1;
            
TogglePlayerControllable(playerid0);
               
DisablePlayerCheckpoint(playerid);
               
SetPlayerCheckpoint(playerid, -366.2761,-1428.3999,25.7266,3.0);
               
IsMilkingCows[playerid] = 7;
        }
        else if(
IsMilkingCows[playerid] == 7)
        {
               
DisablePlayerCheckpoint(playerid);
               
SendClientMessage(playeridCOLOR_LIGHTBLUE"   Well Done! Here's your Pay Check of $100");
               
IsMilkingCows[playerid] = 0;
               
GivePlayerMoney(playerid100);
        } 
thanks a lot for helpers
Reply
#2

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
Debug your code by putting print lines in the code so you can interactively see what the code is doing.

For instance:

pawn Код:
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)
        {
            print("\tMilking cows == 2");
            MilkTime[playerid] += 1;
// etc...
This way you can see if, for instance maybe the "IsMilkingCows[playerid]" isn't passing the checks due to a possible OOB error, either here or in another part of your script which is causing (what I believe is called) memory leak (where you try to assign values out of bounds and it ends up being put in another variable somewhere else)
when i tried what you said it still doesnt show another checkpoint but however this is what it shows on the console;

PHP код:
MilkingCows 0
Milking Cows 
== 1
Disabled checkpoint
setting new one
-End of code block 
thats what i editted;

PHP код:
else if(IsMilkingCows[playerid] > 0)//farmerjob
    
{
        print(
"Milking cows > 0");
        if(
IsMilkingCows[playerid] == 1)
        {
            print(
"\tMilking cows == 1");
            
MilkTime[playerid] += 1;
            
TogglePlayerControllable(playerid0);
            
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"); 
Reply
#3

bump anyone help please
Reply
#4

another bump, help me please =[
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)