(Help) Server bug with checkpoints.
#1

Well I want when a dialog key is pressed, a checkpoint appears. I made that, and the checkpoint appeared. Then when I pick it up, it shows me the message, and the object attaches, but the next checkpoint doesn't appear. I used variables for that, why didn't it work?

This is the code under OnDialogResponse

pawn Код:
if(Works[playerid] == true) return SendClientMessage(playerid,0xFFFFFFFF,"You took the job already.");
    OldSkin[playerid] = GetPlayerSkin(playerid);
    Works[playerid] = true; JobAmmount[playerid] = 0; JobCP[playerid] = 1;
    SetPlayerCheckpoint(playerid,2230.3528,-2286.1353,14.3751,1.5);
And under OnPlayerEnterCheckpoint

pawn Код:
new string[128]; // Not used
    new string2[128]; // Not used
    new name[MAX_PLAYER_NAME]; // Not used
    if(Works[playerid])
    {
        if(JobCP[playerid] == 1 && IsPlayerInRangeOfPoint(playerid,2.0,2230.3528,-2286.1353,14.3751))
        {
            SendClientMessage(playerid,0xFFFFFFFF,"Take it to the checkpoint.");
            JobCP[playerid] = 2;
            DisablePlayerCheckpoint(playerid);
            SetPlayerCheckpoint(playerid,2172.4146,-2255.5405,13.3041,1.5); // THIS ONE IS NOT BEING SET
            ApplyAnimation(playerid,"CARRY","crry_prtial",4.0,1,0,0,1,1,1);
            SetPlayerAttachedObject(playerid, 1 , 2060, 1,0.11,0.36,0.0,0.0,90.0);
            ApplyAnimation(playerid,"CARRY","crry_prtial",4.0,1,0,0,1,1,1);
        }
        if(JobCP[playerid] == 2  && IsPlayerInRangeOfPoint(playerid,2.0,2172.4146,-2255.5405,13.3041))
        {
            SendClientMessage(playerid,0xFFFFFFFF,"Go back to the previous checkpoint.");
            JobAmmount[playerid] ++;
            format(string,sizeof(string),"Carried: {228B22}%d",JobAmmount[playerid]);
            SendClientMessage(playerid,0xFFFFFFFF,string);
            ApplyAnimation(playerid,"CARRY","crry_prtial",4.0,0,0,0,0,1,0);
            if(IsPlayerAttachedObjectSlotUsed(playerid,1)) RemovePlayerAttachedObject(playerid,1);
            JobCP[playerid] = 1;
            DisablePlayerCheckpoint(playerid);
            SetPlayerCheckpoint(playerid,2230.3528,-2286.1353,14.3751,1.5);
        }
    }
If someone helps and it works, I'll give reputation of course)
Reply
#2

As long as you don't have any other scripts using checkpoints the variables should be fine alone. There's no need to keep up with what checkpoint they are on and check if they are in range. Either or but not both. Try this out.

pawn Код:
new string[128]; // Not used
new string2[128]; // Not used
new name[MAX_PLAYER_NAME]; // Not used
if(Works[playerid])
{
    switch(JobCP[playerid])
    {
        case 1:
        {
            SendClientMessage(playerid,0xFFFFFFFF,"Take it to the checkpoint.");

            JobCP[playerid] = 2;
            DisablePlayerCheckpoint(playerid);
            SetPlayerCheckpoint(playerid,2172.4146,-2255.5405,13.3041,1.5); // THIS ONE IS NOT BEING SET
            ApplyAnimation(playerid,"CARRY","crry_prtial",4.0,1,0,0,1,1,1);
            SetPlayerAttachedObject(playerid, 1 , 2060, 1,0.11,0.36,0.0,0.0,90.0);
            ApplyAnimation(playerid,"CARRY","crry_prtial",4.0,1,0,0,1,1,1);
            return 1;
        }
        case 2:
        {
            SendClientMessage(playerid,0xFFFFFFFF,"Go back to the previous checkpoint.");

            JobAmmount[playerid] ++;
            format(string,sizeof(string),"Carried: {228B22}%d",JobAmmount[playerid]);
            SendClientMessage(playerid,0xFFFFFFFF,string);

            if(IsPlayerAttachedObjectSlotUsed(playerid,1))
            RemovePlayerAttachedObject(playerid,1);

            JobCP[playerid] = 1;
            ApplyAnimation(playerid,"CARRY","crry_prtial",4.0,0,0,0,0,1,0);
            DisablePlayerCheckpoint(playerid);
            SetPlayerCheckpoint(playerid,2230.3528,-2286.1353,14.3751,1.5);
            return 1;
        }
    }
}
I'm pretty sure it wasn't working because you set JobCP equal to 2 then you don't return so it just checks the next statement to see if it's equal to 2 and it is.
Reply
#3

Let me try.
Reply
#4

Same problem, the CP doesn't appear.

And yes, beside that I have other systems in the gamemode which are using checkpoints. What now?
Reply
#5

When you enter the checkpoint nothing happens or does it still send the message?
Reply
#6

All the code works (Message sends, object gets attached, etc.) but the Checkpoint doesn't appear.
Reply
#7

pawn Код:
DisablePlayerCheckpoint(playerid);
You don't need to destroy them if you create another checkpoint. Remove them, perhaps they're the problem.
Reply
#8

Doesn't work.
Reply
#9

Did you remove all of them?
Check the rest of your OnPlayerEnterCheckpoint, perhaps it have DisablePlayerCheckpoint.
Reply
#10

Try placing the SetPlayerCheckpoint function at the end of that call. Want to see if one of my theories pans out:
pawn Код:
if(JobCP[playerid] == 1 && IsPlayerInRangeOfPoint(playerid,2.0,2230.3528,-2286.1353,14.3751))
{
   SendClientMessage(playerid,0xFFFFFFFF,"Take it to the checkpoint.");
   JobCP[playerid] = 2;
   DisablePlayerCheckpoint(playerid);
   ApplyAnimation(playerid,"CARRY","crry_prtial",4.0,1,0,0,1,1,1);
   SetPlayerAttachedObject(playerid, 1 , 2060, 1,0.11,0.36,0.0,0.0,90.0);
   ApplyAnimation(playerid,"CARRY","crry_prtial",4.0,1,0,0,1,1,1);
   SetPlayerCheckpoint(playerid,2172.4146,-2255.5405,13.3041,1.5); // THIS ONE IS NOT BEING SET
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)