PDA

View Full Version : (Help) Server bug with checkpoints.


GangsTa_
28/08/2011, 06:45 AM
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


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


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)

Backwardsman97
28/08/2011, 06:59 AM
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.


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.

GangsTa_
28/08/2011, 07:02 AM
Let me try.

GangsTa_
28/08/2011, 07:07 AM
Same problem, the CP doesn't appear.

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

Backwardsman97
28/08/2011, 07:20 AM
When you enter the checkpoint nothing happens or does it still send the message?

GangsTa_
28/08/2011, 09:04 AM
All the code works (Message sends, object gets attached, etc.) but the Checkpoint doesn't appear.

=WoR=Varth
28/08/2011, 09:10 AM
DisablePlayerCheckpoint(playerid);


You don't need to destroy them if you create another checkpoint. Remove them, perhaps they're the problem.

GangsTa_
28/08/2011, 09:22 AM
Doesn't work.

=WoR=Varth
28/08/2011, 09:51 AM
Did you remove all of them?
Check the rest of your OnPlayerEnterCheckpoint, perhaps it have DisablePlayerCheckpoint.

Bakr
28/08/2011, 09:55 AM
Try placing the SetPlayerCheckpoint function at the end of that call. Want to see if one of my theories pans out:

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
}

GangsTa_
28/08/2011, 10:11 AM
Doesn't work anyway, tried both things.

GangsTa_
31/08/2011, 05:25 PM
BUMP