16.01.2014, 19:21
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