[Tutorial] How to detect joypad.
#9

Quote:
Originally Posted by justsomeguy
View Post
i'd suggest you use this maybe?:
pawn Code:
public OnPlayerConnect(playerid)
{
    new keys, ud, lr;
    GetPlayerKeys(playerid, keys, ud, lr);
    if((ud != 128 && ud != 0 && ud != -128) || (lr != 128 && lr != 0 && lr != -128))
        SendClientMessage(playerid, 0x0FFFFFFA, "JOYPADDER!");
    else
        SendClientMessage(playerid, 0x0FFFFFFA, "Not a joypadder.");
        }
    return 1;
}
(not sure this even works! dont get mad at me! i havent tested it i only know that it does not give's errors!).
this would not work, because: when they connect and are not yet spawned GetPlayerKeys does not work at all, it only works when they are spawned, but even if it did work when they had just connected they would have to be holding down the up/down or left/right keys at the exact second that they connect.

you could do:

pawn Code:
new JoyPadders[MAX_PLAYERS];
OnPlayerUpdate(playerid) {
    if(JoyPadders[playerid] == 0) {
        new keys, ud, lr;
        GetPlayerKeys(playerid, keys, ud, lr);
        if((ud != 128 && ud != 0 && ud != -128) || (lr != 128 && lr != 0 && lr != -128))
            JoyPadders[playerid] = 1;
        else
            // nothing
    }
}
Reply


Messages In This Thread
How to detect joypad. - by Whitetiger - 10.05.2011, 05:56
Re: How to detect joypad. - by kacper55331 - 10.05.2011, 05:57
Re: How to detect joypad. - by justsomeguy - 10.05.2011, 09:31
Re: How to detect joypad. - by Whitetiger - 11.05.2011, 05:52
Re: How to detect joypad. - by Lorenc_ - 11.05.2011, 08:06
Re: How to detect joypad. - by Gh0sT_ - 11.05.2011, 10:44
Re: How to detect joypad. - by Whitetiger - 11.05.2011, 10:45
Re: How to detect joypad. - by justsomeguy - 11.05.2011, 19:19
Re: How to detect joypad. - by Whitetiger - 11.05.2011, 22:43
Re: How to detect joypad. - by justsomeguy - 21.05.2011, 09:33

Forum Jump:


Users browsing this thread: 1 Guest(s)