-
Notifications
You must be signed in to change notification settings - Fork 30
SetPlayerDisableKeysSync
Nexius edited this page Oct 14, 2024
·
6 revisions
const PLAYER_SYNC = 207;
const VEHICLE_SYNC = 200;
const PASSENGER_SYNC = 211;
const SPECTATING_SYNC = 212;
enum eDisabledKeys
{
Disable_LeftKey,
Disable_RightKey,
Disable_UpKey,
Disable_DownKey,
Disabled_Keys
};
new gPlayerDisabledKeys[MAX_PLAYERS][eDisabledKeys];
stock ProcessDisabledKeys(playerid, &lrKey, &udKey, &keys)
{
if ((lrKey == KEY_LEFT && gPlayerDisabledKeys[playerid][Disable_LeftKey])
|| (lrKey == KEY_RIGHT && gPlayerDisabledKeys[playerid][Disable_RightKey])
) {
lrKey = 0;
}
if ((udKey == KEY_UP && gPlayerDisabledKeys[playerid][Disable_UpKey])
|| (udKey == KEY_DOWN && gPlayerDisabledKeys[playerid][Disable_DownKey])
) {
udKey = 0;
}
keys &= ~gPlayerDisabledKeys[playerid][Disabled_Keys];
}
stock SetPlayerDisableKeysSync(playerid, keys, left = false, right = false, up = false, down = false)
{
gPlayerDisabledKeys[playerid][Disable_LeftKey] = left;
gPlayerDisabledKeys[playerid][Disable_RightKey] = right;
gPlayerDisabledKeys[playerid][Disable_UpKey] = up;
gPlayerDisabledKeys[playerid][Disable_DownKey] = down;
gPlayerDisabledKeys[playerid][Disabled_Keys] = keys;
}
IPacket:PLAYER_SYNC(playerid, BitStream:bs)
{
new onFootData[PR_OnFootSync];
BS_IgnoreBits(bs, 8);
BS_ReadOnFootSync(bs, onFootData);
ProcessDisabledKeys(playerid, onFootData[PR_lrKey], onFootData[PR_udKey], onFootData[PR_keys]);
BS_SetWriteOffset(bs, 8);
BS_WriteOnFootSync(bs, onFootData);
return 1;
}
IPacket:VEHICLE_SYNC(playerid, BitStream:bs)
{
new inCarData[PR_InCarSync];
BS_IgnoreBits(bs, 8);
BS_ReadInCarSync(bs, inCarData);
ProcessDisabledKeys(playerid, inCarData[PR_lrKey], inCarData[PR_udKey], inCarData[PR_keys]);
BS_SetWriteOffset(bs, 8);
BS_WriteInCarSync(bs, inCarData);
return 1;
}
IPacket:PASSENGER_SYNC(playerid, BitStream:bs)
{
new passengerData[PR_PassengerSync];
BS_IgnoreBits(bs, 8);
BS_ReadPassengerSync(bs, passengerData);
ProcessDisabledKeys(playerid, passengerData[PR_lrKey], passengerData[PR_udKey], passengerData[PR_keys]);
BS_SetWriteOffset(bs, 8);
BS_WritePassengerSync(bs, passengerData);
return 1;
}
IPacket:SPECTATING_SYNC(playerid, BitStream:bs)
{
new spectatingData[PR_SpectatingSync];
BS_IgnoreBits(bs, 8);
BS_ReadSpectatingSync(bs, spectatingData);
ProcessDisabledKeys(playerid, spectatingData[PR_lrKey], spectatingData[PR_udKey], spectatingData[PR_keys]);
BS_SetWriteOffset(bs, 8);
BS_WriteSpectatingSync(bs, spectatingData);
return 1;
}
- Refer to BrunoBM16's RPC and Packet lists