Disable keys
#1

Is it possible to disable keys like KEY_FIRE?
ex. to make a fighting free zone.
Reply
#2

Could apply an animation when they do that? Wouldn't stop them, doing it, but it will stop the fight.
Reply
#3

You could check the player's key under OnPlayerUpdate; then if they pressed it, return 0.

E.g
pawn Код:
OnPlayerUpdate(playerid)
{
if(PRESSED(KEY_FIRE)) return 0;
return 1;
}
Reply
#4

But if I'm not wrong The Toni, that means if the guys holds that key, he could use it to run away because nobody would see his location, no?
Reply
#5

I would suggest creating a global boolean variable which is set to true if the player is in the area that you want to be 'fight free' ( because I don't like putting proximity checks in onplayerupdate )

pawn Код:
new bool:inzone[MAX_PLAYERS];
...
public OnPlayerUpdate(playerid)
{
     if(inzone[playerid])
     {
          SetPlayerArmedWeapon(playerid, 0);
     }
     return 1;
}
or, as Austin suggested, applying an animation when the player presses fire is worth testing too.
Reply
#6

OnPlayerKeyStateChange, check if the player presses KEY_FIRE, check if he's in range of the zone, if so TogglePlayerControllable(playerid, true), or as Rachael suggested SetPlayerArmedWeapon(playerid, 0).

Using OnPlayerUpdate, you can imagine how many times SetPlayerArmedWeapon(playerid, 0) would be called, way too much.
Reply
#7

Quote:
Originally Posted by The Toni
Посмотреть сообщение
You could check the player's key under OnPlayerUpdate; then if they pressed it, return 0.

E.g
pawn Код:
OnPlayerUpdate(playerid)
{
if(PRESSED(KEY_FIRE)) return 0;
return 1;
}
Returning 0 on Keys does not stop them from triggering the action...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)