Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma newdecls required
- #pragma semicolon 1
- #include <sourcemod>
- #include <sdktools>
- #define MAXLIST 11
- 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];
- static const char gModelsItemsList[MAXLIST][] =
- {
- "models/weapons/melee/v_katana.mdl", //0
- "models/weapons/melee/v_fireaxe.mdl", //1
- "models/weapons/melee/v_machete.mdl", //2
- "models/weapons/melee/v_crowbar.mdl", //3
- "models/v_models/v_knife_t.mdl", //4
- "models/weapons/melee/v_frying_pan.mdl", //5
- "models/weapons/melee/v_bat.mdl", //6
- "models/weapons/melee/v_cricket_bat.mdl", //7
- "models/weapons/melee/v_tonfa.mdl", //8
- "models/weapons/melee/v_electric_guitar.mdl", //9
- "models/weapons/melee/v_golfclub.mdl" //10
- };
- public void OnPluginStart()
- {
- AddCommandListener(HookPlayerChat, "say");
- RegConsoleCmd("s", cSwitch);
- RegConsoleCmd("sm_s", cSwitch);
- HookEvent("player_death", eDeath);
- }
- public void eDeath(Event event, const char[] name, bool dontbroadcast)
- {
- int client = GetClientOfUserId(event.GetInt("userid"));
- if(client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2)
- {
- float vPos[3];
- GetClientEyePosition(client, vPos);
- for(int i; i < 2; i++)
- {
- int entity = CreateEntityByName(sClassnameWeapon[client][i]);
- if(IsValidEntity(entity))
- {
- TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
- DispatchSpawn(entity);
- }
- else
- {
- entity = MeleeAwfull(sClassnameWeapon[client][i]);
- TeleportEntity(entity, vPos, NULL_VECTOR, NULL_VECTOR);
- }
- }
- }
- for(int i; i < 2; i++)
- {
- Format(sClassnameWeapon[client][i], sizeof sClassnameWeapon[][], "null");
- }
- }
- 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;
- char ModelName[128], sExplodeString[MAXLIST][56];
- int iNum;
- GetEntPropString(iSlot, Prop_Data, "m_ModelName", ModelName, sizeof ModelName);
- for(int i; i < MAXLIST; i++)
- {
- if(strcmp(ModelName, gModelsItemsList[i]) == 0)
- {
- iNum = ExplodeString(gModelsItemsList[i], "/", sExplodeString, sizeof sExplodeString, sizeof sExplodeString[]);
- ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "v_", "");
- if(StrContains(sExplodeString[iNum - 1], "knife") > 0)
- ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "_t.mdl", "");
- else
- ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], ".mdl", "");
- TrimString(sExplodeString[iNum - 1]);
- Format(sClassnameWeapon[client][0], sizeof sClassnameWeapon[][], "%s", sExplodeString[iNum - 1]);
- break;
- }
- }
- }
- 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;
- char ModelName[128], sExplodeString[MAXLIST - 6][36];
- int iNum;
- GetEntPropString(iSlot, Prop_Data, "m_ModelName", ModelName, sizeof ModelName);
- for(int i; i < MAXLIST; i++)
- {
- if(strcmp(ModelName, gModelsItemsList[i]) == 0)
- {
- iNum = ExplodeString(gModelsItemsList[i], "/", sExplodeString, sizeof sExplodeString, sizeof sExplodeString[]);
- ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "v_", "");
- if(StrContains(sExplodeString[iNum - 1], "knife") > 0)
- ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], "_t.mdl", "");
- else
- ReplaceString(sExplodeString[iNum - 1], sizeof sExplodeString[], ".mdl", "");
- TrimString(sExplodeString[iNum - 1]);
- Format(sClassnameWeapon[client][1], sizeof sClassnameWeapon[][], "%s", sExplodeString[iNum - 1]);
- break;
- }
- }
- }
- 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