Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ShopAPI>
- #include <sdktools>
- public Plugin myinfo =
- {
- name = "HidonAnime",
- author = "JuSTaR",
- description = "Hidonim Anime",
- version = "1.0",
- url = "https://www.fxp.co.il/"
- }
- const int MAX_SONGS = 30; // what? not enough?
- const int PRIZE = 140;
- Handle:HudTimer;
- float TimerTick = 1.0;
- int DisplayTime = 60;
- char Song_Path[MAX_SONGS][128];
- char Song_Name[MAX_SONGS][64];
- char DisplayMsg[128] = "[ Nostalgia Hidon ]\nWhat Is The Name of This Anime Series?";
- int SongsLoaded;
- int RandomSong_ID;
- public OnPluginStart()
- {
- RegConsoleCmd("say", LookForAnswer);
- RegAdminCmd("start_hidon_anime", Start_Hidon_Anime, ADMFLAG_RCON);
- RegAdminCmd("stop_hidon_anime", Stop_Hidon_Anime, ADMFLAG_RCON);
- RegConsoleCmd("pa", Play_Again);
- RegConsoleCmd("play_again", Play_Again);
- RegConsoleCmd("s", Stop_Music);
- RegConsoleCmd("stop", Stop_Music);
- LoadSongsData();
- }
- public Action Play_Again(int client, int arg)
- {
- if (HudTimer != null)
- {
- char buffer[64];
- Format(buffer, sizeof(buffer), "%s%s", "*", Song_Path[RandomSong_ID][5]);
- EmitSoundToClient(client, buffer);
- }
- }
- public Action Stop_Music(int client, int arg)
- {
- char buffer[64];
- Format(buffer, sizeof(buffer), "%s%s", "*", Song_Path[RandomSong_ID][5]);
- StopSound(client, SNDCHAN_AUTO, buffer);
- }
- public Action Stop_Hidon_Anime(int client, int args)
- {
- ResetHidonAnime();
- }
- public OnMapStart()
- {
- char buffer[64];
- for (int i = 0; i < SongsLoaded; i++) // loading count down sounds
- {
- Format(buffer, sizeof(buffer), "%s%s", "*", Song_Path[i][5]);
- PrecacheSound(buffer);
- AddFileToDownloadsTable(Song_Path[i]);
- }
- }
- public Action Start_Hidon_Anime(int client, int args)
- {
- if (HudTimer != null)
- ResetHidonAnime();
- RandomSong_ID = GetRandomInt(0, SongsLoaded-1);
- char buffer[64];
- Format(buffer, sizeof(buffer), "%s%s", "*", Song_Path[RandomSong_ID][5]);
- EmitSoundToAll(buffer);
- HudTimer = CreateTimer(TimerTick, SetHud, _, TIMER_REPEAT);
- }
- public Action SetHud(Handle:timer)
- {
- SetHudTextParams(-1.0, 0.15, 1.0, GetRandomInt(0, 255), GetRandomInt(0, 255), GetRandomInt(0, 255), 255, 1, TimerTick, 0.0, 0.0);
- if (DisplayTime > 0)
- ShowHud(DisplayMsg);
- else
- {
- ResetHidonAnime();
- PrintToChatAll("[ Anime Hidon ] The answer was %s. Nobody answered correctly.. what a nerds..", Song_Name[RandomSong_ID]);
- }
- DisplayTime--;
- }
- public void ShowHud(char msg[128])
- {
- for(new i = 1; i <= MaxClients; i++) // display hud
- if(IsClientInGame(i) && !IsFakeClient(i))
- ShowHudText(i, -1, msg);
- }
- public Action LookForAnswer(int client, int args)
- {
- if (HudTimer != null)
- {
- char arg[64];
- GetCmdArg(1, arg, sizeof(arg));
- if (StrEqual(arg, Song_Name[RandomSong_ID], false))
- {
- int first_color[4];
- int second_color[4];
- for (int i = 0; i < 4; i++)
- {
- first_color[i] = GetRandomInt(0, 255);
- second_color[i] = GetRandomInt(0, 255);
- }
- SetHudTextParamsEx(-1.0, 0.15, 15.0, first_color, second_color, 2, 1.0, 0.3, 0.3);
- Format(DisplayMsg, sizeof(DisplayMsg), "%s%N%s%d%s", "[ Anime Hidon ]\n", client, " has won ", PRIZE, " Points!");
- ShowHud(DisplayMsg);
- PrintToChatAll("[ Anime Hidon ] %N has answered [ %s ], and won %d Points!", client, Song_Name[RandomSong_ID], PRIZE);
- Native_GivePoints(client, PRIZE);
- ResetHidonAnime();
- }
- }
- }
- public void ResetHidonAnime()
- {
- DisplayTime = 60;
- strcopy(DisplayMsg, sizeof(DisplayMsg), "[ Nostalgia Hidon ]\nWhat Is The Name of This Anime Series?");
- if (HudTimer != null)
- {
- KillTimer(HudTimer);
- HudTimer = null;
- }
- }
- public void LoadSongsData()
- {
- new Handle:lines = CreateArray(256);
- char word[64];
- char line[128];
- ReadFromConfigFile(lines);
- SongsLoaded = GetArraySize(lines);
- if (SongsLoaded > 0) // if there are any Hidonim
- {
- for (int i = 0; i < SongsLoaded; i++) // for each Hidon configuration
- {
- GetArrayString(lines, i, line, sizeof(line)); // get Hidon configuration line
- int len; // uses to move BreakString crusor - to go to the next word
- len = BreakString(line[len], word, sizeof(line)); // get first word in line
- Song_Path[i] = word;
- len += BreakString(line[len], word, sizeof(line)); // get second word in line
- Song_Name[i] = word;
- }
- }
- else
- SetFailState("[ Anime Hidon ] No Anime songs were found.");
- lines = null;
- }
- public void ReadFromConfigFile(Handle lines)
- {
- char path[64] = "addons\\sourcemod\\configs\\Hidonim\\Anime_List.ini";
- if (!FileExists(path))
- SetFailState("[ Anime Hidon ] ERROR: Unable to find Anime_List.ini - config file.");
- new Handle:file = OpenFile(path, "r");
- char buffer[256];
- while (!IsEndOfFile(file) && ReadFileLine(file, buffer, sizeof(buffer)))
- if (StrContains(buffer, "//") == -1)
- PushArrayString(lines, buffer);
- CloseHandle(file);
- }
Advertisement
Add Comment
Please, Sign In to add comment