Checkpoint Command, Freeze + Unfreeze
#1

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;
            }
 }
Reply
#2

Anyone care to help ? xD
Reply
#3

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
Reply
#4

close the line use }
Reply
#5

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

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)