#include #include new bool:g_bRestrict[MAXPLAYERS+1]; new String:sWeapons[MAXPLAYERS+1][12]; new g_iAmmo[MAXPLAYERS+1][3]; public OnClientPutInServer(client) { SDKHook(client, SDKHook_WeaponEquip, Hook_OnWeaponEquip); SDKHook(client, SDKHook_WeaponSwitch, Hook_OnWeaponEquip); } public Action:Hook_OnWeaponEquip(client, weapon) { decl String:item[20]; item[0] = '\0'; GetEdictClassname(weapon, item, sizeof(item)); if(strcmp(item, "weapon_m4a1") == 0 || strcmp(item, "weapon_usp") == 0) { SetEntProp(weapon, Prop_Send, "m_bSilencerOn", 0); if(g_bRestrict[client]) { g_bRestrict[client] = false; g_iAmmo[client][2] = 1; } } } public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon) { if(client < 1 || !IsClientInGame(client) || !IsPlayerAlive(client)) return Plugin_Continue; if (buttons & IN_ATTACK2) { new iWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"); if(iWeapon != -1 && !g_bRestrict[client]) { decl String:item[12]; item[0] = '\0'; GetEdictClassname(iWeapon, item, sizeof(item)); if(strcmp(item, "weapon_m4a1") == 0 || strcmp(item, "weapon_usp") == 0) { if(strcmp(item, "weapon_m4a1") == 0) { g_iAmmo[client][0] = GetEntProp(iWeapon, Prop_Send, "m_iClip1"); new ammoOffset = FindDataMapOffs(client, "m_iAmmo"); new m_iPrimaryAmmoType = -1; if((m_iPrimaryAmmoType = GetEntProp(iWeapon, Prop_Send, "m_iPrimaryAmmoType")) != -1) g_iAmmo[client][1] = GetEntData(client, ammoOffset + m_iPrimaryAmmoType * 4, 4); if(RemovePlayerItem(client, iWeapon)) AcceptEntityInput(iWeapon, "Kill"); } if(g_iAmmo[client][2] < 1) strcopy(sWeapons[client], 12, item); g_bRestrict[client] = true; g_iAmmo[client][2] = 0; FakeClientCommand(client, "use weapon_knife"); } } } else if(g_bRestrict[client]) { g_bRestrict[client] = false; if(strcmp(sWeapons[client], "weapon_m4a1") == 0) { GivePlayerItem(client, sWeapons[client]); new iWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon"); if(iWeapon != -1) { new m_iPrimaryAmmoType = -1; if ((m_iPrimaryAmmoType = GetEntProp(iWeapon, Prop_Send, "m_iPrimaryAmmoType")) != -1) SetEntProp(client, Prop_Send, "m_iAmmo", g_iAmmo[client][1], _, m_iPrimaryAmmoType); SetEntProp(iWeapon, Prop_Send, "m_iClip1", g_iAmmo[client][0]); } } else FakeClientCommand(client, "use %s", sWeapons[client]); } return Plugin_Continue; }