Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PLUGIN_VERSION "0.1"
- /*=======================================================================================
- Plugin Info:
- * Name : [L4D] PaSSifiC - Particles and Sound Sequence Interactive Constructor
- * Author : Alex Dragokas
- * Descr. : Creates in-game set of effects and sounds to use by another plugins
- * Link :
- ========================================================================================
- Change Log:
- 0.1 (xx-Oct-2018)
- - First commit
- ========================================================================================
- Description:
- // TODO
- Commands:
- 1. "" - ...
- Settings (ConVars):
- 1. "" - ...
- Using:
- ...
- ======================================================================================*/
- #pragma semicolon 1
- #pragma newdecls required
- #include <sourcemod>
- #include <sdktools>
- public Plugin myinfo =
- {
- name = "PaSSifiC",
- author = "Alex Dragokas",
- description = "Creates in-game set of effects and sounds to use by another plugins",
- version = PLUGIN_VERSION,
- url = "https://github.com/dragokas/"
- };
- KeyValues kv;
- char g_sCurParticleGrp[60][MAXPLAYERS+1];
- public void OnPluginStart()
- {
- //LoadTranslations("passific.phrases");
- CreateConVar("passific_version", PLUGIN_VERSION, "PaSSifiC Version", FCVAR_SPONLY | FCVAR_NOTIFY | FCVAR_REPLICATED);
- RegConsoleCmd("sm_passific_load", Command_LoadConfigs, "Reload configs.");
- RegConsoleCmd("sm_passific", Command_MenuMain, "Show passific main menu");
- Command_LoadConfigs(0, 0);
- }
- public Action Command_LoadConfigs(int client, int args)
- {
- char ParticlesPath[PLATFORM_MAX_PATH];
- BuildPath(Path_SM, ParticlesPath, PLATFORM_MAX_PATH, "data/sm_passific_particles.txt");
- if (!FileExists(ParticlesPath))
- SetFailState("[SM] ERROR: Passific - Missing file, '%s'", ParticlesPath);
- kv = CreateKeyValues("particles");
- if (!FileToKeyValues(kv, ParticlesPath))
- SetFailState("[SM] ERROR: Passific - Incorrectly formatted file, '%s'", ParticlesPath);
- if (!kv.GotoFirstSubKey())
- SetFailState("[SM] ERROR: Passific - Config file is empty, '%s'", ParticlesPath);
- }
- /* ------------------------
- // "Main Menu"
- ---------------------------*/
- Action Command_MenuMain(int client, int args)
- {
- if (!IsClientAdmin(client))
- {
- PrintToChat(client, "You are not allowed to use this feature!");
- return Plugin_Handled;
- }
- Menu menu = CreateMenu(MenuHandler_MenuMain, MENU_ACTIONS_DEFAULT);
- menu.SetTitle("Select particle action");
- menu.AddItem("1", "Choose in list");
- menu.AddItem("2", "Next");
- menu.AddItem("3", "Repeat");
- menu.AddItem("4", "Edit");
- menu.AddItem("5", "Add to sequence");
- menu.Display(client, MENU_TIME_FOREVER);
- return Plugin_Handled;
- }
- public int MenuHandler_MenuMain(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_End:
- delete menu;
- case MenuAction_Select:
- {
- int client = param1;
- int ItemIndex = param2;
- char nAction[5];
- int iAction;
- menu.GetItem(ItemIndex, nAction, sizeof(nAction));
- iAction = StringToInt(nAction);
- switch(iAction) {
- case 1: {
- Command_Particle_Grp_Choose(client);
- }
- }
- }
- }
- }
- void Command_Particle_Grp_Choose(int client)
- {
- Menu menu = CreateMenu(MenuHandler_Particle_Grp_Choose, MENU_ACTIONS_DEFAULT);
- menu.SetTitle("Particles: Choose the group");
- kv.Rewind();
- kv.GotoFirstSubKey();
- char sParticleGrp[40];
- do
- {
- kv.GetSectionName(sParticleGrp, sizeof(sParticleGrp));
- menu.AddItem(sParticleGrp, sParticleGrp);
- } while (kv.GotoNextKey());
- menu.ExitBackButton = true;
- menu.Display(client, MENU_TIME_FOREVER);
- }
- public int MenuHandler_Particle_Grp_Choose(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_End:
- delete menu;
- case MenuAction_Cancel:
- if (param2 == MenuCancel_ExitBack)
- Command_MenuMain(param1, 0);
- case MenuAction_Select:
- {
- int client = param1;
- int ItemIndex = param2;
- char sParticleGrp[40];
- menu.GetItem(ItemIndex, sParticleGrp, sizeof(sParticleGrp));
- PrintToChat(client, "\x03[Passific] Chosen group: \x05%s", sParticleGrp);
- CreateMenu_ParticleChoose(client, sParticleGrp);
- }
- }
- }
- void CreateMenu_ParticleChoose(int client, char[] sParticleGrp, int StartItem = 0)
- {
- Menu menu = CreateMenu(MenuHandler_ParticleChoose, MENU_ACTIONS_DEFAULT);
- menu.SetTitle("Choose effect");
- kv.Rewind();
- if (kv.JumpToKey(sParticleGrp))
- {
- strcopy(g_sCurParticleGrp[client], sizeof(g_sCurParticleGrp[]), sParticleGrp);
- int iTotal = kv.GetNum("Total", 0);
- char sParticleName[60], s_Idx[5];
- for (int i = 1; i <= iTotal; i++)
- {
- IntToString(i, s_Idx, sizeof(s_Idx));
- kv.JumpToKey(s_Idx);
- kv.GetString("name", sParticleName, sizeof(sParticleName), "error");
- kv.GoBack();
- if (!StrEqual(sParticleName, "error"))
- menu.AddItem(sParticleName, sParticleName);
- }
- menu.ExitBackButton = true;
- menu.DisplayAt(client, StartItem, MENU_TIME_FOREVER);
- }
- }
- public int MenuHandler_ParticleChoose(Menu menu, MenuAction action, int param1, int param2)
- {
- switch (action)
- {
- case MenuAction_End:
- delete menu;
- case MenuAction_Cancel:
- if (param2 == MenuCancel_ExitBack)
- Command_Particle_Grp_Choose(param1);
- case MenuAction_Select:
- {
- int client = param1;
- int ItemIndex = param2;
- char sParticle[40];
- menu.GetItem(ItemIndex, sParticle, sizeof(sParticle));
- PrintToChat(client, "\x03[Passific] Chosen particle: \x05%s", sParticle);
- SpawnEffect(client, sParticle);
- CreateMenu_ParticleChoose(client, g_sCurParticleGrp[client], menu.Selection );
- }
- }
- }
- void SpawnEffect(int client, char[] sParticleName)
- {
- float pos[3];
- // GetClientAbsOrigin(client, pos);
- GetClientEyePosition(client, pos);
- int iEntity = CreateEntityByName("info_particle_system", -1);
- if (iEntity != -1)
- {
- PrintToChat(client, "\x03[Passific] Spawning effect on: \x05%N", client);
- DispatchKeyValue(iEntity, "effect_name", sParticleName);
- DispatchKeyValueVector(iEntity, "origin", pos);
- DispatchSpawn(iEntity);
- SetVariantString("!activator");
- AcceptEntityInput(iEntity, "SetParent", client);
- ActivateEntity(iEntity);
- AcceptEntityInput(iEntity, "Start");
- SetVariantString("OnUser1 !self:kill::1.5:1");
- AcceptEntityInput(iEntity, "AddOutput");
- AcceptEntityInput(iEntity, "FireUser1");
- }
- }
- bool IsClientAdmin(int client)
- {
- if (!IsClientInGame(client)) return false;
- return GetUserAdmin(client) != INVALID_ADMIN_ID;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement