Joypad gives almost 100% accuracy now.
#6

Try this it will limit the rate in which a joypad users shots will be synced. No I didn't really test it yet I don't have or know anyone with a joypad but I'm pretty sure it's correct just make sure you include it near the top of your script. Let me know if there is any problems.

pawn Код:
#define         SHOOTING_DELAY          300

static bool:JoyPadder[MAX_PLAYERS];
static LastShootTime[MAX_PLAYERS];

forward HasJoyPad(playerid);
public HasJoyPad(playerid) { return JoyPadder[playerid]; }

public OnPlayerConnect(playerid)
{
    JoyPadder[playerid] = false;
    return CallLocalFunction("JoyDelay_OnPlayerConnect", "i", playerid);
}

public OnPlayerUpdate(playerid)
{
    if(!JoyPadder[playerid])
    {
        new keys, ud, lr;
        GetPlayerKeys(playerid, keys, ud, lr);
        if((ud != 128 && ud != 0 && ud != -128) || (lr != 128 && lr != 0 && lr != -128)) JoyPadder[playerid] = true;
    }
    return CallLocalFunction("JoyDelay_OnPlayerUpdate", "i", playerid);
}

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(JoyPadder[playerid])
    {
        if(GetTickCount() - LastShootTime[playerid] < SHOOTING_DELAY) return 0;
        else LastShootTime[playerid] = GetTickCount();
    }
    return CallLocalFunction("JoyDelay_OnPlayerWeaponShot", "iiiifff", playerid, weaponid, hittype, hitid, fX, fY, fZ);
}

// Connect hooking
#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect JoyDelay_OnPlayerConnect

// Player update hooking
#if defined _ALS_OnPlayerUpdate
    #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif
#define OnPlayerUpdate JoyDelay_OnPlayerUpdate

// Weapon shot hooking
#if defined _ALS_OnPlayerWeaponShot
    #undef OnPlayerWeaponShot
#else
    #define _ALS_OnPlayerWeaponShot
#endif
#define OnPlayerWeaponShot JoyDelay_OnPlayerWeaponShot
Reply


Messages In This Thread
Joypad/Autoaim gives almost 100% accuracy now. - by T-N-Z - 16.01.2014, 19:01
Re: Joypad gives almost 100% accuracy now. - by Pottus - 16.01.2014, 19:03
Re: Joypad gives almost 100% accuracy now. - by DreDasLT - 16.01.2014, 19:04
AW: Re: Joypad gives almost 100% accuracy now. - by NetKiel - 16.01.2014, 19:07
Re: Joypad gives almost 100% accuracy now. - by 2KY - 16.01.2014, 19:18
Re: Joypad gives almost 100% accuracy now. - by Pottus - 16.01.2014, 19:21
Re: Joypad gives almost 100% accuracy now. - by Patrick - 16.01.2014, 19:23
Re: Joypad gives almost 100% accuracy now. - by hub4 - 16.01.2014, 19:24
Re: Joypad gives almost 100% accuracy now. - by Pottus - 16.01.2014, 19:26
Re: Joypad gives almost 100% accuracy now. - by Patrick - 16.01.2014, 19:27
Re: Joypad gives almost 100% accuracy now. - by Mauzen - 16.01.2014, 22:13
Re: Joypad gives almost 100% accuracy now. - by PawnoQ - 16.01.2014, 22:32
Re: Joypad gives almost 100% accuracy now. - by Mauzen - 16.01.2014, 22:40

Forum Jump:


Users browsing this thread: 2 Guest(s)