Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FILTERSCRIPT
- #include <a_samp>
- // taken from weapon-config (https://github.com/oscar-broman/samp-weapon-config/blob/master/weapon-config.inc)
- IsBulletWeapon(weaponid)
- return (WEAPON_COLT45 <= weaponid <= WEAPON_SNIPER) || weaponid == WEAPON_MINIGUN;
- GetWeaponSlot(weaponid)
- {
- switch(weaponid)
- {
- case 1: return 0;
- case 2..9: return 1;
- case 22..24: return 2;
- case 25..27: return 3;
- case 28, 29, 32: return 4;
- case 30, 31: return 5;
- case 33, 34: return 6;
- case 35..38: return 7;
- case 16..18, 39: return 8;
- case 41..43: return 9;
- case 10..15: return 10;
- case 44..46: return 11;
- case 40: return 12;
- }
- return -1;
- }
- SetPlayerArmedWeaponEx(playerid, weaponid)
- {
- SetPVarInt(playerid, "switch_WeaponID", weaponid);
- PlayerPlaySound(playerid, 1138, 0.0, 0.0, 0.0);
- return SetPlayerArmedWeapon(playerid, weaponid);
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- if(newstate == PLAYER_STATE_PASSENGER)
- {
- new weapID = GetPlayerWeapon(playerid);
- SetPVarInt(playerid, "switch_WeaponID", weapID);
- if(IsBulletWeapon(weapID)) SendClientMessage(playerid, 0x3F9DDDFF, "WEAPON SWITCHING: {FFFFFF}You can switch weapons using ~k~~CONVERSATION_YES~/~k~~CONVERSATION_NO~.");
- }
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER && IsBulletWeapon(GetPVarInt(playerid, "switch_WeaponID")))
- {
- // Next Weapon
- if(newkeys & KEY_YES)
- {
- new curWeap = GetPVarInt(playerid, "switch_WeaponID"), weapSlot = GetWeaponSlot(curWeap), weapID, weapAmmo;
- for(new i = weapSlot + 1; i <= 7; i++)
- {
- GetPlayerWeaponData(playerid, i, weapID, weapAmmo);
- if(IsBulletWeapon(weapID) && weapID != curWeap)
- {
- SetPlayerArmedWeaponEx(playerid, weapID);
- GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~y~~h~Next Weapon ~>~", 1000, 3);
- break;
- }
- }
- }
- // Previous Weapon
- if(newkeys & KEY_NO)
- {
- new curWeap = GetPVarInt(playerid, "switch_WeaponID"), weapSlot = GetWeaponSlot(curWeap), weapID, weapAmmo;
- for(new i = weapSlot - 1; i >= 2; i--)
- {
- GetPlayerWeaponData(playerid, i, weapID, weapAmmo);
- if(IsBulletWeapon(weapID) && weapID != curWeap)
- {
- SetPlayerArmedWeaponEx(playerid, weapID);
- GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~y~~h~~<~ Previous Weapon", 1000, 3);
- break;
- }
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement