Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma semicolon 1
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- float LastDrop[MAXPLAYERS+1];
- #define MAX_FRAMECHECK 10
- bool bPistol[MAXPLAYERS+1] = {true, ...};
- bool bPistolFix[MAXPLAYERS+1] = {true, ...};
- public void OnPluginStart()
- {
- HookEvent("player_use", Event_Ammo_Pickup);
- HookEvent("item_pickup", OnItemPickup);
- AutoExecConfig(true, "l4d_pistol_reloading");
- }
- public Action:OnItemPickup(Handle:event, const String:name[],bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- new String:item[64];
- GetEventString(event, "item", item, sizeof(item));
- if(StrEqual(item ,"grenade_launcher"))
- {
- PrintHintText(client, "Вы можете воспольнить патроны для гранатамёта из стопки патронов.");
- }
- else if(StrEqual(item ,"rifle_m60"))
- {
- PrintHintText(client, "Вы можете воспольнить патроны для M60 из стопки патронов.");
- }
- }
- public void ConvarChanged(Handle hCvar, const char[] sOldVal, const char[] sNewVal)
- {
- CvarsChanged();
- }
- public void OnMapStart()
- {
- CvarsChanged();
- }
- void CvarsChanged()
- {
- SetConVarInt(FindConVar("ammo_pistol_max"), 30);
- }
- public void OnClientPostAdminCheck(int client)
- {
- if (IsFakeClient(client)) return;
- bPistol[client] = true;
- bPistolFix[client] = true;
- SDKHook(client, SDKHook_WeaponEquip, Hook_WeaponEquip);
- }
- public Action Hook_WeaponEquip(int client, int weapon)
- {
- if (!IsSurvivor(client) || !bPistolFix[client])
- return;
- bPistolFix[client] = false;
- }
- public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
- {
- int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- if(IsValidEntity(iCurrentWeapon))
- {
- if (buttons & IN_USE)
- {
- LastDrop[client] = GetEngineTime();
- if ((GetEngineTime() - LastDrop[client]) < 2)
- {
- char sWeaponEx[32];
- GetEntityClassname(iCurrentWeapon, sWeaponEx, sizeof(sWeaponEx));
- if(StrEqual(sWeaponEx, "weapon_pistol") || StrEqual(sWeaponEx, "weapon_pistol_magnum"))
- {
- int AmmoType = GetEntProp(iCurrentWeapon, Prop_Data, "m_iPrimaryAmmoType");
- int Ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, AmmoType);
- int Clip = GetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1");
- PrintHintText(client, "В обойме:%i В запасе:%i", Clip, Ammo);
- }
- }
- }
- }
- }
- /*[----->|BOT PISTOL AMMO|<-----]*/
- public void OnGameFrame()
- {
- int iFrameskip = 0;
- iFrameskip = (iFrameskip + 1) % MAX_FRAMECHECK;
- if(iFrameskip != 0 || !IsServerProcessing())
- return;
- for (int client = 1; client <= MaxClients; client++)
- {
- if (!IsSurvivor(client) || !IsPlayerAlive(client) || !IsFakeClient(client))
- continue;
- int Weapon = GetPlayerWeaponSlot(client, 1);
- if (Weapon == -1) continue;
- char sWeapon[32];
- GetEntityClassname(Weapon, sWeapon, sizeof(sWeapon));
- int AmmoType = GetEntProp(Weapon, Prop_Data, "m_iPrimaryAmmoType");
- int Ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, AmmoType);
- if (StrEqual(sWeapon, "weapon_pistol"))
- {
- if (AmmoType == -1) continue;
- if (Ammo == 0)
- SetEntProp(client, Prop_Send, "m_iAmmo", 15, _, AmmoType);
- }
- if (StrEqual(sWeapon, "weapon_pistol", false) && GetEntProp(Weapon, Prop_Send, "m_hasDualWeapons"))
- {
- if (AmmoType == -1) continue;
- if (Ammo == 0)
- {
- SetEntProp(client, Prop_Send, "m_iAmmo", 30, _, AmmoType);
- }
- }
- if (StrEqual(sWeapon, "weapon_pistol_magnum", false))
- {
- SetEntProp(client, Prop_Send, "m_iAmmo", 8, _, AmmoType);
- }
- }
- }
- public Action Event_Ammo_Pickup(Event event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(event.GetInt("userid"));
- if (!IsSurvivor(client) || !IsPlayerAlive(client)) return;
- int AmmoPile = event.GetInt("targetid");
- if (!IsValidEntity(AmmoPile)) return;
- char sWeapon[32];
- GetEntityClassname(AmmoPile, sWeapon, sizeof(sWeapon));
- if (!StrEqual(sWeapon, "weapon_ammo_spawn", false))
- return;
- int Weapon = GetPlayerWeaponSlot(client, 1);
- if (Weapon == -1) return;
- GetEntityClassname(Weapon, sWeapon, sizeof(sWeapon));
- if (!(StrEqual(sWeapon, "weapon_pistol", false) || StrEqual(sWeapon, "weapon_pistol_magnum", false)))
- return;
- float cPos[3];
- GetEntPropVector(client, Prop_Data, "m_vecAbsOrigin", cPos);
- float aPos[3];
- GetEntPropVector(AmmoPile, Prop_Data, "m_vecAbsOrigin", aPos);
- if (GetVectorDistance(cPos, aPos) <= 100)
- {
- bPistol[client] = true; //FIXES WEAPON EMPTY MESSAGE IN AMMO LOCK TIMER
- int AmmoType = GetEntProp(Weapon, Prop_Data, "m_iPrimaryAmmoType");
- if (AmmoType == -1) return;
- int Clip = GetEntProp(Weapon, Prop_Send, "m_iClip1");
- if (StrEqual(sWeapon, "weapon_pistol", false) && GetEntProp(Weapon, Prop_Send, "m_hasDualWeapons"))
- {
- SetEntProp(Weapon, Prop_Send, "m_iClip1", Clip);
- SetEntProp(client, Prop_Send, "m_iAmmo", 120, _, AmmoType);
- }
- else if (StrEqual(sWeapon, "weapon_pistol", false))
- {
- SetEntProp(Weapon, Prop_Send, "m_iClip1", Clip);
- SetEntProp(client, Prop_Send, "m_iAmmo", 120, _, AmmoType);
- }
- if (StrEqual(sWeapon, "weapon_pistol_magnum", false))
- {
- SetEntProp(Weapon, Prop_Send, "m_iClip1", Clip);
- SetEntProp(client, Prop_Send, "m_iAmmo", 32, _, AmmoType);
- }
- }
- }
- stock bool IsValidAdmin(int client)
- {
- if (GetUserFlagBits(client) & ADMFLAG_ROOT) return true;
- return false;
- }
- stock bool IsValidClient(int client)
- {
- if (client > 0 && client <= MaxClients && IsClientInGame(client)) return true;
- return false;
- }
- stock bool IsSpectator(int client)
- {
- if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 1) return true;
- return false;
- }
- stock bool IsSurvivor(int client)
- {
- if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2) return true;
- return false;
- }
- stock bool IsInfected(int client)
- {
- if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 3) return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement