GetPlayerKeys while frozen
#1

Hi...
I'm working on a little debug filterscript and I'd need to know how / if it's possible to detect if a player is pressing a certain key while he is frozen (TogglePlayerControllable)

if I use the normal way
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if((newkeys & KEY_ACTION) && !(oldkeys & KEY_ACTION))
  {
    SendClientMessage(playerid, 0x999999AA, "Key pressed");
  }
  return 1;
}
it doesn't work (I'm not sending that msg in my code, this is just an example)...
it works with no key, I've tried different keys...

is there a plugin, include or another way to do it?

(please don't reply and suggest to use one of the existing debug scripts)

thanks
Reply
#2

bump
Reply
#3

Quote:
Originally Posted by Sascha
Посмотреть сообщение
bump
You should rather give it a try
Reply
#4

what you mean?
I've tried on different ways (onplayerkeystatechange, onplayerupdate and a timer) and nothing works..
I could try just to set the player in any interior or so and later set him back to the pos, however I would dislike to do that... hehe
Reply
#5

Quote:
Originally Posted by Sascha
Посмотреть сообщение
what you mean?
I've tried on different ways (onplayerkeystatechange, onplayerupdate and a timer) and nothing works..
I could try just to set the player in any interior or so and later set him back to the pos, however I would dislike to do that... hehe
Sorry lol, i have incurred an annoying habit ( reading titles only, and reply ) caused by this forum being spammed by Childs.
Reply
#6

haha I know what you mean lol...
but any idea for a solution?
with out that I can't continue with my script lol^^
Reply
#7

Try GetPlayerKeys under OnPlayerUpdate.
It works perfectly, but your code should work too.
Reply
#8

Quote:
Originally Posted by armyoftwo
Посмотреть сообщение
Try GetPlayerKeys under OnPlayerUpdate.
It works perfectly, but your code should work too.
Quote:
Originally Posted by Sascha
Посмотреть сообщение
what you mean?
I've tried on different ways (onplayerkeystatechange, onplayerupdate and a timer) and nothing works..
I could try just to set the player in any interior or so and later set him back to the pos, however I would dislike to do that... hehe
Look's like you did the same mistake as me.
Reply
#9

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE)
    {
        SendClientMessage(playerid, 0x999999AA, "Key pressed");
    }
    return 1;
}
Be sure that you have also returned your OnPlayerKeyStateChange in your Gamemode to 1
pawn Код:
//Main Gamemode Script..
//...
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    //Your stuff in your Gamemode...
    return 1; //<-- Set this to 1 to call this callback in another scripts (Filterscripts, etc.)
}
//Some other stuff you have added...
P.S.: I won't suggest to use GetPlayerKeys on OnPlayerUpdate since this function will be called when a player sends a sync (rapidly)
Reply
#10

dude... I would advice you to read what I've said before and try it the way I described...
when the player is frozen (TogglePlayerControllable(playerid, 0) none of this ways works for me, so please don't suggest me a way that I've already mentioned not to work...
Reply
#11

Don't know why it doesn't work for you, but OnPlayerKeyStateChange works for me (frozen or not).
Reply
#12

weird..
Reply
#13

Are you inside a vehicle when trying?
Reply
#14

It should work when player is freezed. In my script it works. I think the problem is somewhere else in the script
Try the code without freezing the player and see if it works

i do it like this
pawn Код:
if(newkeys == KEY_ACTION && oldkeys != KEY_ACTION)
Reply
#15

nop, I'm outside of a vehicle... sec I'll post my code...

the command that freezes the player also sets sgtPlayerVehicle[playerid] = 0
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(sgtPlayerVehicle[playerid] != -1)
    {
        if((newkeys & KEY_SECONDARY_ATTACK) && !(oldkeys & KEY_SECONDARY_ATTACK))
        {
            TextDrawHideForPlayer(playerid, Info);
            TextDrawHideForPlayer(playerid, Name[playerid]);
            DestroyVehicle(sgtVehicle[playerid]);
            sgtVehicle[playerid] = -1;
            sgtPlayerVehicle[playerid] = -1;
            TogglePlayerControllable(playerid, 1);
            SetCameraBehindPlayer(playerid);
        }
        else if((newkeys & KEY_ACTION) && !(oldkeys & KEY_ACTION))
        {
            TextDrawHideForPlayer(playerid, Info);
            TextDrawHideForPlayer(playerid, Name[playerid]);
            sgtVehicle[playerid] = -1;
            sgtPlayerVehicle[playerid] = -1;
            TogglePlayerControllable(playerid, 1);
            SetCameraBehindPlayer(playerid);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)