Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* TODO List:
- * 1. Add ShowInfo
- * 2. add selection to go to war
- * 3. Add stop lr + native
- * 4. Add infinate ammo to war
- * 5. Check No Scope
- * 6. Add hook and unhook to SDKHooks
- * 7. Give always knife so model wont fuck up and block where u cant use knife
- */
- #pragma semicolon 1
- #define DEBUG
- #include <sourcemod>
- #include <sdktools>
- #include <cstrike>
- #include <sdkhooks>
- #include <smlib>
- EngineVersion g_Game;
- #define MOVES 5
- #define MAXBUTTONS 11
- #define MAX_BUTTONS 25
- int g_LastButtons[MAXPLAYERS + 1];
- int ComboMoves[MOVES] = {0, ...};
- int PlayerPos[MAXPLAYERS + 1] = {0, ...};
- //maybe enum
- // need defines whatever
- char sButtons[][] = { // maybe add walk
- "Attack",
- "Attack2",
- "Jump",
- "Duck",
- "Forward",
- "Back",
- "Use",
- "Moveleft",
- "Moveright",
- "Reload",
- "Score"
- };
- int Buttons[MAXBUTTONS] = {
- IN_ATTACK,
- IN_ATTACK2,
- IN_JUMP,
- IN_DUCK,
- IN_FORWARD,
- IN_BACK,
- IN_USE,
- IN_MOVELEFT,
- IN_MOVERIGHT,
- IN_RELOAD,
- IN_SCORE
- };
- enum LastRequest
- {
- LR_DUEL = 0,
- LR_S4S,
- LR_GUNTOSS,
- LR_POWERDEAGLE,
- LR_COMBO,
- LR_RAMBO
- };
- #define MAXWEAPONS 7
- enum WeaponInfo {
- String:WeaponName[64],
- String:WeaponClassname[64],
- HP
- }
- new Weapons[MAXWEAPONS][WeaponInfo] = {
- { "Knife", "weapon_knife", 500 },
- { "Deagle", "weapon_deagle", 700 },
- { "M4A1", "weapon_m4a1", 1500},
- { "AK-47", "weapon_ak47", 1500},
- { "Nova", "weapon_nova", 1000},
- { "Scout", "weapon_ssg08", 800},
- { "AWP", "weapon_awp", 1000}
- };
- #define MAXSWEAPONS 4
- enum SWeaponInfo {
- String:WeaponName[64],
- String:WeaponClassname[64]
- }
- new SWeapons[MAXSWEAPONS][SWeaponInfo] = {
- { "Deagle", "weapon_deagle" },
- { "P250", "weapon_p250" },
- { "Nova", "weapon_nova"},
- { "Scout [No Scope]", "weapon_ssg08" }
- };
- //Integers
- LastRequest LRType;
- int Prisoner = 0;
- int Guard = 0;
- int PWep = 0;
- int GWep = 0;
- int DuelWep = 0;
- //bool Gravity = false;
- //bool HP = false;
- //bool Speed = false;
- bool NoScope = false;
- bool Armor = false;
- //bool Jump = false;
- //bool HS = false;
- //Bools
- bool IsActive = false;
- //Natives
- //native int GetPlayerCash(id);
- //native int SetPlayerCash(id, amount);
- public Plugin myinfo =
- {
- name = "",
- author = "Gior",
- description = "",
- version = "1.0",
- url = ""
- };
- public void OnPluginStart()
- {
- g_Game = GetEngineVersion();
- if(g_Game != Engine_CSGO && g_Game != Engine_CSS)
- {
- SetFailState("This plugin is for CSGO/CSS only.");
- }
- AddCommandListener(BlockDrop, "drop");
- HookEvent("player_death", EventPlayerDeath, EventHookMode_Post);
- HookEvent("weapon_fire", EventWeaponFire);
- HookEvent("player_hurt", PlayerHurt);
- HookEvent("round_end", RoundEnd);
- RegConsoleCmd("sm_lr", LRMenu);
- }
- public Action BlockDrop(int id, const char[] command, int argc)
- {
- if(IsActive)
- {
- if(id == Prisoner || id == Guard)
- {
- switch(LRType)
- {
- case LR_S4S, LR_POWERDEAGLE, LR_DUEL:return Plugin_Handled;
- }
- }
- }
- return Plugin_Continue;
- }
- public OnClientPutInServer(id)
- {
- SDKHook(id, SDKHook_WeaponCanUse, WeaponCanUse);
- }
- public Action WeaponCanUse(id, wep)
- {
- if(IsActive)
- {
- if(id == Prisoner || id == Guard)
- {
- switch(LRType)
- {
- case LR_S4S, LR_DUEL, LR_POWERDEAGLE:return Plugin_Handled;
- }
- }
- }
- return Plugin_Continue;
- }
- public Action LRMenu(id, args) // TODO: maybe put all in one line, why to give so much information?
- {
- if(!IsClientInGame(id))
- return;
- if(!IsPlayerAlive(id))
- {
- PrintToChat(id, "You must be Alive to use Last Request!");
- return;
- }
- else if(GetClientTeam(id) != CS_TEAM_T)
- {
- PrintToChat(id, "You must be a Prisoner to use Last Request!");
- return;
- }
- else if(IsActive)
- {
- PrintToChat(id, "There is already an Active Last Request!");
- return;
- }
- else if(GetAliveTerror() > 1)
- {
- PrintToChat(id, "There are %d Prisoners left before you can use Last Request!", (GetAliveTerror() - 1));
- return;
- }
- else if(GetAliveTerror() != 1)
- {
- PrintToChat(id, "There are no Alive Prisoners!");
- return;
- }
- else if(GetAliveCT() <= 0)
- {
- PrintToChat(id, "There are no Alive Guards!");
- return;
- }
- Handle menu = CreateMenu(LRMenuHandler);
- SetMenuTitle(menu, "Choose a Last Request:");
- AddMenuItem(menu, "duel", "Duels [High HP]");
- AddMenuItem(menu, "s4s", "Shot4Shot");
- AddMenuItem(menu, "gt", "Gun Toss");
- AddMenuItem(menu, "pd", "Power Deagle");
- AddMenuItem(menu, "cc", "Combo Contest");
- AddMenuItem(menu, "ra", "Rambo Mode");
- DisplayMenu(menu, id, MENU_TIME_FOREVER);
- }
- public LRMenuHandler(Menu menu, MenuAction action, int id, int pos)
- {
- if(action == MenuAction_Select)
- {
- char info[16];
- GetMenuItem(menu, pos, info, 16);
- if(StrEqual(info, "duel"))
- {
- LRType = LR_DUEL;
- ChooseWeapon(id);
- }
- else if(StrEqual(info, "s4s"))
- {
- LRType = LR_S4S;
- ChooseWeapon(id);
- }
- else if(StrEqual(info, "gt"))
- {
- LRType = LR_GUNTOSS;
- ChooseGuard(id);
- }
- else if(StrEqual(info, "pd"))
- {
- LRType = LR_POWERDEAGLE;
- ChooseGuard(id);
- }
- else if(StrEqual(info, "cc"))
- {
- LRType = LR_COMBO;
- ChooseGuard(id);
- }
- else if(StrEqual(info, "ra"))
- {
- LRType = LR_RAMBO;
- Prisoner = id;
- InitiateLR();
- }
- //TODO: maybe LRType = LastRequest:pos
- //ChooseGuard(id); // TODO: Add here if pos != rebel, then menu
- }
- else if(action == MenuAction_End)
- CloseHandle(menu);
- }
- ChooseWeapon(id)
- {
- if(GetAliveCT() <= 0 || GetAliveTerror() != 1 || IsActive)
- {
- PrintToChat(id, "You can't use LR now!");
- return;
- }
- Handle menu = CreateMenu(WeaponsHandler);
- SetMenuTitle(menu, "Choose a Weapon for the %s:", LRType == LR_DUEL ? "Duel" : "Shot4Shot");
- char temp[5];
- if(LRType == LR_DUEL)
- {
- for (int i = 0; i < MAXWEAPONS; i++)
- {
- Format(temp, 5, "%d", i);
- AddMenuItem(menu, temp, Weapons[i][WeaponName]);
- }
- }
- else if(LRType == LR_S4S)
- {
- for (int i = 0; i < MAXSWEAPONS; i++)
- {
- Format(temp, 5, "%d", i);
- AddMenuItem(menu, temp, SWeapons[i][WeaponName]);
- }
- }
- DisplayMenu(menu, id, MENU_TIME_FOREVER);
- }
- public WeaponsHandler(Menu menu, MenuAction action, int id, int pos)
- {
- if(action == MenuAction_Select)
- {
- char temp[5];
- GetMenuItem(menu, pos, temp, 5);
- DuelWep = StringToInt(temp);
- if(LRType == LR_DUEL)
- ChooseSettings(id);
- else if(LRType == LR_S4S)
- ChooseGuard(id);
- }
- else if(action == MenuAction_End)
- CloseHandle(menu);
- }
- ChooseSettings(id)
- {
- if(GetAliveCT() <= 0 || GetAliveTerror() != 1 || IsActive)
- {
- PrintToChat(id, "You can't use LR now!");
- return;
- }
- Handle menu = CreateMenu(SettingsHandler);
- SetMenuTitle(menu, "Choose Settings for the Duel:");
- char format[100];
- Format(format, 100, "No Scope: %s\n\n", NoScope ? "On" : "Off");
- AddMenuItem(menu, "noscope", format);
- Format(format, 100, "Armor: %s\n\n", Armor ? "On" : "Off");
- AddMenuItem(menu, "armor", format);
- AddMenuItem(menu, "done", "Done!");
- DisplayMenu(menu, id, MENU_TIME_FOREVER);
- }
- public SettingsHandler(Menu menu, MenuAction action, int id, int pos)
- {
- if(action == MenuAction_Select)
- {
- char info[10];
- GetMenuItem(menu, pos, info, 15);
- if (StrEqual(info, "noscope"))
- {
- NoScope = !NoScope;
- ChooseSettings(id);
- }
- else if(StrEqual(info, "armor"))
- {
- Armor = !Armor;
- ChooseSettings(id);
- }
- else if(StrEqual(info, "done"))
- {
- ChooseGuard(id);
- }
- }
- else if(action == MenuAction_End)
- CloseHandle(menu);
- }
- ChooseGuard(id)
- {
- if(GetAliveCT() <= 0 || GetAliveTerror() != 1 || IsActive)
- {
- PrintToChat(id, "You can't use LR now!");
- return;
- }
- Handle menu = CreateMenu(CTMenuHandler);
- SetMenuTitle(menu, "Choose a Guard:");
- char name[64];
- char temp_id[5];
- for (int i = 1; i <= MaxClients; i++)
- {
- if(!IsValidClient(i, true) || !(GetClientTeam(i) == CS_TEAM_CT))
- continue;
- Format(temp_id, 5, "%d", i);
- GetClientName(i, name, 64);
- AddMenuItem(menu, temp_id, name);
- }
- DisplayMenu(menu, id, MENU_TIME_FOREVER);
- return;
- }
- public CTMenuHandler(Menu menu, MenuAction action, int id, int pos)
- {
- if(action == MenuAction_Select)
- {
- char temp_id[5];
- GetMenuItem(menu, pos, temp_id, 5);
- Prisoner = id;
- Guard = StringToInt(temp_id);
- InitiateLR();
- }
- else if(action == MenuAction_End)
- CloseHandle(menu);
- }
- InitiateLR()
- {
- if(GetAliveCT() <= 0 || GetAliveTerror() != 1 || IsActive)
- {
- PrintToChatAll("You can't use LR now!");
- return;
- }
- Client_RemoveAllWeapons(Prisoner);
- Client_RemoveAllWeapons(Guard);
- switch(LRType)
- {
- case LR_DUEL:
- {
- Entity_SetHealth(Prisoner, Weapons[DuelWep][HP], true);
- Entity_SetHealth(Guard, Weapons[DuelWep][HP], true);
- if(Armor)
- {
- Client_SetArmor(Prisoner, 1000);
- Client_SetArmor(Guard, 1000);
- }
- PWep = GivePlayerItem(Prisoner, Weapons[DuelWep][WeaponClassname]);
- GWep = GivePlayerItem(Guard, Weapons[DuelWep][WeaponClassname]);
- }
- case LR_S4S:
- {
- Entity_SetHealth(Prisoner, 100, true);
- Entity_SetHealth(Guard, 100, true);
- PWep = GivePlayerItem(Prisoner, SWeapons[DuelWep][WeaponClassname]);
- GWep = GivePlayerItem(Guard, SWeapons[DuelWep][WeaponClassname]);
- Weapon_SetClips(PWep, 1, 1);
- Weapon_SetClips(GWep, 0, 0);
- SetEntProp(PWep, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
- SetEntProp(GWep, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
- }
- case LR_GUNTOSS:
- {
- Entity_SetHealth(Prisoner, 100, true);
- Entity_SetHealth(Guard, 100, true);
- PWep = GivePlayerItem(Prisoner, "weapon_deagle");
- GWep = GivePlayerItem(Guard, "weapon_deagle");
- //Weapon_SetClips(PWep, 0, 0);
- //Weapon_SetClips(GWep, 0, 0);
- //
- //SetEntProp(PWep, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
- //SetEntProp(GWep, Prop_Send, "m_iPrimaryReserveAmmoCount", 0);
- }
- case LR_POWERDEAGLE:
- {
- Entity_SetHealth(Prisoner, 500, true);
- Entity_SetHealth(Guard, 500, true);
- PWep = GivePlayerItem(Prisoner, "weapon_deagle");
- GWep = GivePlayerItem(Guard, "weapon_deagle");
- }
- case LR_COMBO:
- {
- for (int i = 0; i < MOVES; i++)
- {
- ComboMoves[i] = Math_GetRandomInt(0, (MAXBUTTONS - 1));
- }
- PlayerPos[Prisoner] = 0;
- PlayerPos[Guard] = 0;
- PrintHintText(Prisoner, "<u>%s</u> \n--><b><font color='#FF6666'>%s</font></b> \n%s", (PlayerPos[Prisoner] == 0) ? "Begin:" : "Continue:", sButtons[ComboMoves[PlayerPos[Prisoner]]], (PlayerPos[Prisoner] == (MOVES - 1)) ? "Done!" : sButtons[ComboMoves[PlayerPos[Prisoner] + 1]]);
- PrintHintText(Guard, "<u>%s</u> \n--><b><font color='#FF6666'>%s</font></b> \n%s", (PlayerPos[Guard] == 0) ? "Begin:" : "Continue:", sButtons[ComboMoves[PlayerPos[Guard]]], (PlayerPos[Guard] == (MOVES - 1)) ? "Done!" : sButtons[ComboMoves[PlayerPos[Guard] + 1]]);
- }
- case LR_RAMBO:
- {
- Entity_SetHealth(Prisoner, 50 + 100 * GetAliveCT(), true);
- PWep = GivePlayerItem(Prisoner, "weapon_negev");
- }
- }
- IsActive = true;
- ShowInfo();
- }
- ShowInfo()
- {
- PrintToChatAll(" \x10Last Request \x01has been \x04Activated\x01!");
- switch(LRType)
- {
- case LR_DUEL:
- {
- PrintToChatAll(" \x07%N \x01has started a \x06Duel \x01against \x0C%N \x01with \x08%s\x01!", Prisoner, Guard, Weapons[DuelWep][WeaponName]);
- PrintToChatAll(" \x06No Scope \x01is %s", NoScope ? "\x04On" : "\x02Off");
- PrintToChatAll(" \x06Armor \x01is %s", Armor ? "\x04On" : "\x02Off");
- PrintToChatAll(" Fight till the Death!");
- }
- case LR_S4S:
- {
- PrintToChatAll(" \x07%N \x01has started a \x06Shot4Shot \x01against \x0C%N \x01with \x08%s\x01!", Prisoner, Guard, SWeapons[DuelWep][WeaponName]);
- PrintToChatAll(" Each one takes a shot at his turn.");
- }
- case LR_GUNTOSS:
- {
- PrintToChatAll(" \x07%N \x01has started a \x06Gun Toss \x01against \x0C%N\x01!", Prisoner, Guard);
- PrintToChatAll(" Longest toss will win.");
- }
- case LR_POWERDEAGLE:
- {
- PrintToChatAll(" \x07%N \x01has started a \x06Power Deagle \x01against \x0C%N\x01!", Prisoner, Guard);
- PrintToChatAll(" Fight till the Death!");
- }
- case LR_COMBO:
- {
- PrintToChatAll(" \x07%N \x01has started a \x06Combo Contest \x01against \x0C%N\x01!", Prisoner, Guard);
- PrintToChatAll(" First one to Complete the Combination will win!");
- }
- case LR_RAMBO:
- {
- PrintToChatAll(" \x07%N \x01went \x06Rambo!", Prisoner);
- PrintToChatAll(" Kill them all!");
- }
- }
- PrintToChatAll(" Winner will be Awarded!");
- }
- public Action PlayerHurt(Handle event, char[] name, bool dontBroadcast)
- {
- if(IsActive)
- {
- switch(LRType)
- {
- case LR_POWERDEAGLE:
- {
- int id = GetClientOfUserId(GetEventInt(event, "userid"));
- int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
- if(id != attacker && IsClientInGame(id) && IsClientInGame(attacker) && (Prisoner == attacker || Prisoner == id) && (Guard == attacker || Guard == id))
- {
- //char weapon[64];
- //GetEventString(event, "weapon", weapon, 64);
- //StrEqual(weapon, "deagle");
- float vec[3];
- vec[0] = Math_GetRandomFloat(1.0, 1000.0);
- vec[1] = Math_GetRandomFloat(1.0, 1000.0);
- vec[2] = Math_GetRandomFloat(1.0, 1000.0);
- TeleportEntity(id, NULL_VECTOR, NULL_VECTOR, vec);
- }
- }
- }
- }
- }
- public Action EventWeaponFire(Handle event, char[] name, bool dontBroadcast)
- {
- if(IsActive)
- {
- int id = GetClientOfUserId(GetEventInt(event, "userid"));
- if(id == Prisoner || id == Guard)
- {
- switch(LRType)
- {
- case LR_S4S:
- {
- if(id == Prisoner)
- Weapon_SetClips(GWep, 1, 1);
- else if(id == Guard) //TODO: Not sure we need if here
- Weapon_SetClips(PWep, 1, 1);
- }
- }
- }
- }
- }
- public Action EventPlayerDeath(Handle event, char[] name, bool dontBroadcast)
- {
- if(GetAliveTerror() == 1 && GetAliveCT() > 0)
- {
- int terror = Client_GetNext(CLIENTFILTER_NOBOTS | CLIENTFILTER_ALIVE | CLIENTFILTER_TEAMONE);
- LRMenu(terror, 0);
- }
- if(IsActive && LRType != LR_RAMBO) // TODO: add here if not rebel
- {
- int victim = GetClientOfUserId(GetEventInt(event, "userid"));
- if(victim == Prisoner || victim == Guard)
- {
- IsActive = false;
- NoScope = false;
- Armor = false;
- if(GetAliveTerror() == 1 && GetAliveCT() > 0)
- {
- int terror = Client_GetNext(CLIENTFILTER_NOBOTS | CLIENTFILTER_ALIVE | CLIENTFILTER_TEAMONE);
- LRMenu(terror, 0);
- }
- }
- }
- }
- public Action RoundEnd(Handle event, char[] name, bool dontBroadcast)
- {
- IsActive = false;
- NoScope = false;
- Armor = false;
- }
- public Action OnPlayerRunCmd(id, &buttons)
- {
- if(IsActive)
- {
- if(id == Prisoner || id == Guard)
- {
- switch(LRType)
- {
- case LR_DUEL:
- {
- if(NoScope)
- {
- if(buttons & IN_ATTACK2)
- buttons &= ~IN_ATTACK2;
- }
- }
- case LR_COMBO:
- {
- if(!(g_LastButtons[id] & buttons) && IsPressing(buttons))
- {
- if((buttons & Buttons[ComboMoves[PlayerPos[id]]]))
- {
- PlayerPos[id]++;
- }
- else
- {
- PrintToChat(id, "Wrong Button!");
- PlayerPos[id] = 0;
- }
- if(PlayerPos[id] >= MOVES)
- {
- PrintHintText(id, "You Won!");
- if(id == Prisoner)
- {
- PrintHintText(Guard, "You Lost!");
- ForcePlayerSuicide(Guard);
- }
- else if(id == Guard)
- {
- PrintHintText(Prisoner, "You Lost!");
- ForcePlayerSuicide(Prisoner);
- }
- IsActive = false;
- }
- else
- {
- PrintHintText(id, "<u>%s</u> \n--><b><font color='#FF6666'>%s</font></b> \n%s", (PlayerPos[id] == 0) ? "Begin:" : "Continue:", sButtons[ComboMoves[PlayerPos[id]]], (PlayerPos[id] == (MOVES - 1)) ? "Done!" : sButtons[ComboMoves[PlayerPos[id] + 1]]);
- }
- }
- g_LastButtons[id] = buttons;
- }
- }
- }
- }
- }
- public bool IsPressing(buttons)
- {
- for(int i = 0; i < MAX_BUTTONS; i++)
- {
- if(buttons & (1 << i))
- {
- return true;
- }
- }
- return false;
- }
- public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
- {
- CreateNative("IsLRActive", Native_IsLRActive);
- return APLRes_Success;
- }
- public int Native_IsLRActive(Handle plugin, int numParams)
- {
- return IsActive;
- }
- stock int GetAliveTerror()
- {
- int count = 0;
- for (int i = 1; i <= MaxClients; i++)
- {
- if(!IsValidClient(i) || (GetClientTeam(i) != CS_TEAM_T) || !IsPlayerAlive(i))
- continue;
- count++;
- }
- return count;
- }
- stock int GetAliveCT()
- {
- int count = 0;
- for (int i = 1; i <= MaxClients; i++)
- {
- if(!IsValidClient(i) || (GetClientTeam(i) != CS_TEAM_CT) || !IsPlayerAlive(i))
- continue;
- count++;
- }
- return count;
- }
- stock bool IsValidClient(int client, bool bAlive = false)
- {
- return (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && (!bAlive || IsPlayerAlive(client)));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement