Raised This Month: $62 Target: $400
 15% 

(req)Anyone has a plugin !song ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joez252
New Member
Join Date: Apr 2019
Old 04-14-2019 , 06:39   (req)Anyone has a plugin !song ?
Reply With Quote #1

I need a plugin! songs where there is a menu with songs and everyone can let it go.
joez252 is offline
Rowdy4E
Junior Member
Join Date: Nov 2018
Old 04-14-2019 , 10:55   Re: (req)Anyone has a plugin !song ?
Reply With Quote #2

Quote:
Originally Posted by joez252 View Post
I need a plugin! songs where there is a menu with songs and everyone can let it go.
- configure your own sounds in config.cfg (Folder path: configs/Sounds)
- volume min & max: 0.1 - 1.0
- cd (cooldown) in seconds

PHP Code:
#pragma semicolon 1

#define DEBUG

#define PLUGIN_AUTHOR "Rowdy"
#define PLUGIN_VERSION "1.00"
#define PLUGIN_CONFIG "configs/Sounds"
#define MAX_SOUNDS 56

#include <sourcemod>
#include <sdktools>

#pragma newdecls required

enum Sounds_Preferences {
    
String:gSoundName[64],
    
String:gSoundPath[255],
    
Float:gVolume,
    
gCooldown
};

int iSoundId 0;
int iSound[MAX_SOUNDS][Sounds_Preferences];
char cSoundsConfig[255];

Handle hTimer;
int iGlobalCooldown;

Handle hAdminFlag;
char cAdminFlag[2];

public 
Plugin myinfo 
{
    
name "SoundsManager",
    
author PLUGIN_AUTHOR,
    
description "Play your own sound with this plugin. Customize your cooldown & volume for specific sound.",
    
version PLUGIN_VERSION,
    
url "http://steamcommunity.com/profiles/76561198307962930"
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("sm_sounds"Command_Sounds);
    
RegConsoleCmd("sm_soundsreload"Command_Reload);
    
    
HookEvent("round_start"OnRoundStart);
    
    
hAdminFlag CreateConVar("soundsmanager_flag""b""Set admin flag for access to command.\nLeave it blank for no access needed.");
    
    
AutoExecConfig(true"soundsmanager");
}

public 
void OnMapStart() {
    
LoadConfig();
}

public 
void OnMapEnd() {
    if (
hTimer != null)
        
delete hTimer;
}

public 
void OnConfigsExecuted() {
    
GetConVarString(hAdminFlagcAdminFlagsizeof(cAdminFlag));
}

void LoadConfig() {
    
char file[255];
    
BuildPath(Path_SMfilesizeof(file), "%s"PLUGIN_CONFIG);
    if (!
DirExists(file))
        
CreateDirectory(file511);
        
    
BuildPath(Path_SMcSoundsConfigsizeof(cSoundsConfig), "%s/config.cfg"PLUGIN_CONFIG);
    if (!
FileExists(cSoundsConfig)) {
        
KeyValues kv = new KeyValues("sounds");
        
kv.ImportFromFile(cSoundsConfig);
        
kv.JumpToKey("Sound #1"true);
        
kv.SetString("path""sound/myfolder/apple.mp3");
        
kv.SetFloat("volume"1.0);
        
kv.SetNum("cd"5);
        
kv.Rewind();
        
kv.ExportToFile(cSoundsConfig);
        
delete kv;
    }
    
clearSoundIds();
    
KeyValues kv = new KeyValues("sounds");
    
kv.ImportFromFile(cSoundsConfig);
    if (
kv.GotoFirstSubKey()) {
        
char cSoundName[64], cSoundPath[255], cDownloadPath[255];
        
float fSoundVolume;
        
int iSoundCooldown;
        do {
            
kv.GetSectionName(cSoundNamesizeof(cSoundName));
            
kv.GetString("path"cSoundPathsizeof(cSoundPath));
            
fSoundVolume kv.GetFloat("volume"1.0);
            
iSoundCooldown kv.GetNum("cd"0);
            
            if (
StrContains(cSoundPath"sound/") != -1)
                
strcopy(cSoundPathsizeof(cSoundPath), cSoundPath[6]);
            
PrecacheSound(cSoundPathtrue);
            
Format(cDownloadPathsizeof(cDownloadPath), "sound/%s"cSoundPath);
            
AddFileToDownloadsTable(cDownloadPath);
            
            
strcopy(iSound[iSoundId][gSoundName], 64cSoundName);
            
strcopy(iSound[iSoundId][gSoundPath], 255cSoundPath);
            
iSound[iSoundId][gVolume] = fSoundVolume;
            
iSound[iSoundId][gCooldown] = iSoundCooldown;
            
            
iSoundId++;
        } while (
kv.GotoNextKey());
    }
    
delete kv;
}

public 
void OnRoundStart(Handle eventchar[] namebool dontBroadcast) {
    
iGlobalCooldown 0;
}

void clearSoundIds() {
    for (
int i 0MAX_SOUNDSi++) {
        
strcopy(iSound[iSoundId][gSoundName], 64"");
        
strcopy(iSound[iSoundId][gSoundPath], 255"");
        
iSound[iSoundId][gVolume] = 1.0;
        
iSound[iSoundId][gCooldown] = 0;
    }
    
iSoundId 0;
}

public 
Action Command_Reload(int clientint args) {
    if (!
HasPlayerAccess(clientcAdminFlag)) {
        
PrintToChat(client" \x02You don't have access to this command!");
        return 
Plugin_Continue;
    }
    
    
LoadConfig();
    
PrintToChat(client"Config is now reloaded!");
    
    return 
Plugin_Handled;
}

public 
Action Command_Sounds(int clientint args) {
    if (!
HasPlayerAccess(clientcAdminFlag)) {
        
PrintToChat(client" \x02You don't have access to this command!");
        return 
Plugin_Continue;
    }
    
SoundsMenu(client);
    
    return 
Plugin_Handled;
}

public 
void SoundsMenu(int client) {
    if (
IsCooldown()) {
        
PrintToChat(client"You need to wait %i second/s to play another sound."iGlobalCooldown 1);
        return;
    }
    
    
Menu menu = new Menu(SoundsMenuHandler);
    
char cId[5];
    
    
menu.SetTitle("Choose sound to play:");
    
    for (
int i 0iSoundIdi++) {
        
IntToString(icIdsizeof(cId));
        
menu.AddItem(cIdiSound[i][gSoundName]);
    }
    
    
menu.Display(client60);
}

public 
int SoundsMenuHandler(Menu menuMenuAction actionint clientint pos) {
    if (
action == MenuAction_Select) {
        if (
IsCooldown()) {
            
PrintToChat(client"You need to wait %i second/s to play another sound."iGlobalCooldown 1);
            return;
        }
        
        
char Item[5];
        
menu.GetItem(posItemsizeof(Item));
        
int id StringToInt(Item);
        
        
EmitSoundToAll(iSound[id][gSoundPath], ____iSound[id][gVolume]);
        
iGlobalCooldown iSound[id][gCooldown] + 1;
        if (
hTimer == null)
            
hTimer CreateTimer(1.0refreshTimer_TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
        
PrintToChat(client"Now playing: %s"iSound[id][gSoundName]);
    }
}

public 
Action refreshTimer(Handle timer) {
    if (
iGlobalCooldown 1) {
        
iGlobalCooldown--;
    } else if (
iGlobalCooldown == 1) {
        
iGlobalCooldown--;
        if (
hTimer != null)
            
delete hTimer;
    }
}

public 
bool IsCooldown() {
    if (
iGlobalCooldown 0)
        return 
true;
    return 
false;
}

public 
bool HasPlayerAccess(int clientchar[] accessflag) {
    if (
strlen(accessflag) == 1) {
        
AdminId admin GetUserAdmin(client);
        
AdminFlag flag;
        
        if (!
FindFlagByChar(accessflag[0], flag))
            return 
false;
        if (!
GetAdminFlag(adminflag))
            return 
false;
        return 
true;
    }
    return 
true;

__________________


PHP, MySQL, SM, IPS Apps & Plugins

Last edited by Rowdy4E; 04-14-2019 at 11:00.
Rowdy4E is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:27.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode