SA-MP Forums Archive
Checkpoint Command, Freeze + Unfreeze - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Checkpoint Command, Freeze + Unfreeze (/showthread.php?tid=85233)



Checkpoint Command, Freeze + Unfreeze - 6tynine - 06.07.2009

Hey I have this problem.
when I enter the Checkpoint I freeze. That works good.
But when I hit space bar to unfreeze it doesnt work here is a piece of a code.

pawn Код:
case 24:
            {
            SendClientMessage(playerid,0xFFFFFFFF,"[DEBUG]: Checkpoint ID: 14");
            TogglePlayerControllable(playerid, false);
            if(keys == KEY_SPRINT)
          {
            TogglePlayerControllable(playerid, true);
            return 1;
            }
 }



Re: Checkpoint Command, Freeze + Unfreeze - 6tynine - 06.07.2009

Anyone care to help ? xD


Re: Checkpoint Command, Freeze + Unfreeze - -Sneaky- - 06.07.2009

It would be better if you use a player variable + OnPlayerKeyStateChange, for example:

pawn Код:
// On top:
new IsInCheckPoint[MAX_PLAYERS];

// At OnPlayerEnterCheckpoint (case 24)
IsInCheckPoint[playerid] = 1; // 1 will mean in this case the entered checkpoint 24

// OnPlayerKeyStateChange
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if(IsInCheckPoint[playerid] == 1) // check if the player is in checkpoint 24
  {
    if(newkeys & 1024) // check if they pressed ALT
    {
      TogglePlayerControllable(playerid, true); // unfreeze the player
      IsInCheckPoint[playerid] = 0; // set this variable back to 0 so when you press ALT unfreezing wont be toggled again
      return 1;
    }
  }
  return 1;
}
For a list of keys check https://sampwiki.blast.hk/wiki/GetPlayerKeys#Key_List you will have to change the 1024 to the key you want.
I hope this helped you


Re: Checkpoint Command, Freeze + Unfreeze - ByFukara - 06.07.2009

close the line use }


Re: Checkpoint Command, Freeze + Unfreeze - 6tynine - 06.07.2009

Thanks Sneaky I used a simular thing but didnt include IsInCheckPoint. Thanks