Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma newdecls required
- #include <sourcemod>
- #include <sdktools>
- int iWeapon[2048 + 1], iAmmo[MAXPLAYERS + 1][2][2];
- bool iCookies[MAXPLAYERS + 1][2], iState[MAXPLAYERS + 1], IsMelee[MAXPLAYERS + 1][2], IsDual[MAXPLAYERS + 1][2];
- char sClassnameWeapon[MAXPLAYERS + 1][2][36];
- public void OnPluginStart()
- {
- AddCommandListener(HookPlayerChat, "say");
- RegConsoleCmd("s", cSwitch);
- RegConsoleCmd("sm_s", cSwitch);
- }
- public Action HookPlayerChat(int iClient, const char[] sCommand, int iArgs)
- {
- if (StrEqual(sCommand, "say") || StrEqual(sCommand, "say_team"))
- {
- char sArg[2];
- GetCmdArg(1, sArg, sizeof(sArg));
- if(strcmp(sArg, "s") == 0)
- {
- cSwitch(iClient, 0);
- return Plugin_Continue;
- }
- }
- return Plugin_Continue;
- }
- public Action cSwitch (int client, int args)
- {
- int iSlot = GetPlayerWeaponSlot(client, 1), AmmoType, Ammo, iClip;
- if(!iState[client])
- {
- if(!iCookies[client][0])
- {
- if(IsValidEntity(iSlot))
- {
- GetEntityClassname(iSlot, sClassnameWeapon[client][0], sizeof sClassnameWeapon[][]);
- if(strcmp(sClassnameWeapon[client][0], "weapon_melee") == 0)
- {
- IsMelee[client][0] = true;
- GetEntPropString(iSlot, Prop_Data, "m_strMapSetScriptName", sClassnameWeapon[client][0], sizeof sClassnameWeapon[][]);
- }
- else if(strcmp(sClassnameWeapon[client][0], "weapon_pistol") == 0 && GetEntProp(iSlot, Prop_Send, "m_hasDualWeapons"))
- IsDual[client][0] = true;
- if(!IsMelee[client][0])
- {
- AmmoType = GetEntProp(iSlot, Prop_Send, "m_iPrimaryAmmoType");
- Ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, AmmoType);
- iClip = GetEntProp(iSlot, Prop_Send, "m_iClip1");
- }
- iAmmo[client][0][0] = iClip;
- iAmmo[client][0][1] = Ammo;
- RemovePlayerItem(client, iSlot);
- AcceptEntityInput(iSlot, "kill");
- iCookies[client][0] = true;
- if(iCookies[client][1])
- {
- iSlot = GetPlayerWeaponSlot(client, 1);
- if(!IsValidEntity(iSlot))
- {
- if(!IsMelee[client][1])
- {
- if(IsDual[client][1])
- {
- int entity;
- for(int i; i <= 2; i++)
- {
- entity = CreateEntityByName(sClassnameWeapon[client][1]);
- DispatchSpawn(entity);
- if(IsValidEntity(entity))
- {
- AcceptEntityInput(entity, "Use", client);
- }
- }
- iWeapon[entity] = GetClientUserId(client);
- CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
- iCookies[client][1] = false;
- IsDual[client][1] = false;
- }
- else
- {
- int entity = CreateEntityByName(sClassnameWeapon[client][1]);
- DispatchSpawn(entity);
- if(IsValidEntity(entity))
- {
- AcceptEntityInput(entity, "Use", client);
- iCookies[client][1] = false;
- }
- iWeapon[entity] = GetClientUserId(client);
- CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
- }
- }
- else
- {
- int entity = MeleeAwfull(sClassnameWeapon[client][1]);
- AcceptEntityInput(entity, "Use", client);
- iCookies[client][1] = false;
- IsMelee[client][1] = false;
- }
- }
- }
- }
- }
- else
- {
- iSlot = GetPlayerWeaponSlot(client, 1);
- if(!IsValidEntity(iSlot))
- {
- if(!IsMelee[client][0])
- {
- if(IsDual[client][0])
- {
- int entity;
- for(int i; i <= 2; i++)
- {
- entity = CreateEntityByName(sClassnameWeapon[client][0]);
- DispatchSpawn(entity);
- if(IsValidEntity(entity))
- {
- AcceptEntityInput(entity, "Use", client);
- }
- }
- iWeapon[entity] = GetClientUserId(client);
- CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
- iCookies[client][0] = false;
- IsDual[client][0] = false;
- }
- else
- {
- int entity = CreateEntityByName(sClassnameWeapon[client][0]);
- DispatchSpawn(entity);
- if(IsValidEntity(entity))
- {
- AcceptEntityInput(entity, "Use", client);
- iCookies[client][0] = false;
- }
- iWeapon[entity] = GetClientUserId(client);
- CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
- }
- }
- else
- {
- int entity = MeleeAwfull(sClassnameWeapon[client][0]);
- AcceptEntityInput(entity, "Use", client);
- iCookies[client][0] = false;
- IsMelee[client][0] = false;
- }
- }
- }
- iState[client] = true;
- }
- else
- {
- if(!iCookies[client][1])
- {
- if(IsValidEntity(iSlot))
- {
- GetEntityClassname(iSlot, sClassnameWeapon[client][1], sizeof sClassnameWeapon[][]);
- if(strcmp(sClassnameWeapon[client][1], "weapon_melee") == 0)
- {
- IsMelee[client][1] = true;
- GetEntPropString(iSlot, Prop_Data, "m_strMapSetScriptName", sClassnameWeapon[client][1], sizeof sClassnameWeapon[][]);
- }
- else if(strcmp(sClassnameWeapon[client][1], "weapon_pistol") == 0 && GetEntProp(iSlot, Prop_Send, "m_hasDualWeapons"))
- {
- IsDual[client][1] = true;
- }
- if(!IsMelee[client][1])
- {
- AmmoType = GetEntProp(iSlot, Prop_Send, "m_iPrimaryAmmoType");
- Ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, AmmoType);
- iClip = GetEntProp(iSlot, Prop_Send, "m_iClip1");
- }
- iAmmo[client][1][0] = iClip;
- iAmmo[client][1][1] = Ammo;
- RemovePlayerItem(client, iSlot);
- AcceptEntityInput(iSlot, "kill");
- iCookies[client][1] = true;
- if(iCookies[client][0])
- {
- iSlot = GetPlayerWeaponSlot(client, 1);
- if(!IsMelee[client][0])
- {
- if(IsDual[client][0])
- {
- int entity;
- for(int i; i <= 2; i++)
- {
- entity = CreateEntityByName(sClassnameWeapon[client][0]);
- DispatchSpawn(entity);
- if(IsValidEntity(entity))
- {
- AcceptEntityInput(entity, "Use", client);
- }
- }
- iWeapon[entity] = GetClientUserId(client);
- CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
- iCookies[client][0] = false;
- IsDual[client][0] = false;
- }
- else
- {
- int entity = CreateEntityByName(sClassnameWeapon[client][0]);
- DispatchSpawn(entity);
- if(IsValidEntity(entity))
- {
- AcceptEntityInput(entity, "Use", client);
- iCookies[client][0] = false;
- }
- iWeapon[entity] = GetClientUserId(client);
- CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
- }
- }
- else
- {
- int entity = MeleeAwfull(sClassnameWeapon[client][0]);
- AcceptEntityInput(entity, "Use", client);
- iCookies[client][0] = false;
- IsMelee[client][0] = false;
- }
- }
- }
- }
- else
- {
- iSlot = GetPlayerWeaponSlot(client, 1);
- if(!IsValidEntity(iSlot))
- {
- if(!IsMelee[client][1])
- {
- if(IsDual[client][1])
- {
- int entity;
- for(int i; i <= 2; i++)
- {
- entity = CreateEntityByName(sClassnameWeapon[client][1]);
- DispatchSpawn(entity);
- if(IsValidEntity(entity))
- {
- AcceptEntityInput(entity, "Use", client);
- }
- }
- iWeapon[entity] = GetClientUserId(client);
- CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
- iCookies[client][1] = false;
- IsDual[client][1] = false;
- }
- else
- {
- int entity = CreateEntityByName(sClassnameWeapon[client][1]);
- DispatchSpawn(entity);
- if(IsValidEntity(entity))
- {
- AcceptEntityInput(entity, "Use", client);
- iCookies[client][1] = false;
- }
- iWeapon[entity] = GetClientUserId(client);
- CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
- }
- }
- else
- {
- int entity = MeleeAwfull(sClassnameWeapon[client][1]);
- AcceptEntityInput(entity, "Use", client);
- iCookies[client][1] = false;
- IsMelee[client][1] = false;
- }
- }
- }
- iState[client] = false;
- }
- return Plugin_Handled;
- }
- public Action tXclip(Handle timer, int entity)
- {
- entity = EntRefToEntIndex(entity);
- if(entity != INVALID_ENT_REFERENCE)
- {
- int iAmmoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType");
- if(iAmmoType)
- {
- int Clip, Ammo, client;
- client = GetClientOfUserId(iWeapon[entity]);
- Clip = iAmmo[client][0][0];
- Ammo = iAmmo[client][0][1];
- int iCurrentWeapon = GetPlayerWeaponSlot(client, 1);
- SetEntProp(client, Prop_Send, "m_iAmmo", Ammo, _, iAmmoType);
- SetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1", Clip);
- }
- }
- }
- public Action tXclip2(Handle timer, int entity)
- {
- entity = EntRefToEntIndex(entity);
- if(entity != INVALID_ENT_REFERENCE)
- {
- int iAmmoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType");
- if(iAmmoType)
- {
- int Clip, Ammo, client;
- client = GetClientOfUserId(iWeapon[entity]);
- Clip = iAmmo[client][1][0];
- Ammo = iAmmo[client][1][1];
- int iCurrentWeapon = GetPlayerWeaponSlot(client, 1);
- SetEntProp(client, Prop_Send, "m_iAmmo", Ammo, _, iAmmoType);
- SetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1", Clip);
- }
- }
- }
- int MeleeAwfull(const char[] Melee)
- {
- int iMWeapon = CreateEntityByName("weapon_melee");
- if (IsValidEntity(iMWeapon))
- {
- DispatchKeyValue(iMWeapon, "melee_script_name", Melee);
- DispatchSpawn(iMWeapon);
- char ModelName[128];
- GetEntPropString(iMWeapon, Prop_Data, "m_ModelName", ModelName, sizeof ModelName);
- if (StrContains( ModelName, "hunter", false ) != -1)
- AcceptEntityInput(iMWeapon, "kill");
- }
- return iMWeapon;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement