Raised This Month: $51 Target: $400
 12% 

[REQ] Plugin to Off / On with Command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 02-28-2015 , 08:56   [REQ] Plugin to Off / On with Command
Reply With Quote #1

Hi all,

I want this plugin can be turned off and on with the command in the chat. Each player has the choice whether to work or not. Here it the plugin :

PHP Code:
#include <amxmodx> 
#include <csx> 
#include <chatcolor> 

const LEVELS 

enum 

    
HS_KILL,
    
HS_KILLED,
    
KNIFE_KILL,
    
KNIFE_KILLED,
    
NADE_KILL,
    
NADE_KILLED,
    
PREPARE_RESTART


new const 
g_szSounds[][] = 

    
"sound/darknezz-zone/gotone.wav",
    
"sound/darknezz-zone/ow.wav",
    
"sound/darknezz-zone/humiliation.wav",
    
"sound/darknezz-zone/humiliation.wav",
    
"sound/darknezz-zone/nade.wav",
    
"sound/darknezz-zone/nade.wav",
    
"sound/darknezz-zone/preparestart.wav"


new const 
g_iLevelsLEVELS ] = 

    
1//4, 
    
2//7, 
    
3//10, 
    
4//13, 
    
5//16, 
    
6//19, 
    
7  //22 


new const 
g_szSounds_KillstreakLEVELS ][] = 

    
"sound/darknezz-zone/firstkill.wav"
    
"sound/darknezz-zone/multikill.wav"
    
"sound/darknezz-zone/doublekill.wav"
    
"sound/darknezz-zone/triplekill.wav"
    
"sound/darknezz-zone/monsterkill.wav"
    
"sound/darknezz-zone/megakill.wav"
    
"sound/darknezz-zone/excellent.wav" 


new const 
g_szMessagesLEVELS ][] = 

    
"%s: First-Kill!"
    
"%s: Multi-Kill!"
    
"%s: Double-Kill!"
    
"%s: Triple-Kill!"
    
"%s: Monster-Kill!"
    
"%s: Mega-Kill!"
    
"%s: EXCELLENT!" 


new 
g_iKills33 ]; 
new 
g_iDeaths33 ]; 

new 
g_iRoundCount;
new 
g_iSyncHud

public 
plugin_precache() 

    for( new 
sizeof g_szSounds ++ ) 
    {
        
precache_genericg_szSounds] ); 
    }

    for( new 
0LEVELSi++ ) 
    {
        
precache_genericg_szSounds_Killstreak] ); 
    }


public 
plugin_init() 

    
register_plugin"Ultimate Sounds""1.0""hornet & kostov" ); 
    
    
register_logevent"LogEvent_Round_Start"2"1=Round_Start" ); 
    
    
g_iSyncHud CreateHudSyncObj(); 


public 
client_deathiKilleriVictimiWeaponiHitGroup/*, TK*/ 
{    
    if( !
is_user_connectediKiller ) || get_user_teamiKiller ) == get_user_teamiVictim ) ) 
    { 
        return 
    } 
    
    if( 
iHitGroup == HIT_HEAD 
    { 
        
client_cmdiKiller"spk ^"%s^""g_szSoundsHS_KILL ] ); 
        
client_cmdiVictim"spk ^"%s^""g_szSoundsHS_KILLED ] ); 
        
client_print_color00"^4[Darknezz-zone] ^3%s ^1killed ^3%s ^1with a HeadShot!"get_nickiKiller ), get_nickiVictim ) ); 
       
        return; 
    } 
    
    switch( 
iWeapon 
    { 
        case 
CSW_KNIFE
        { 
            
client_cmdiKiller"spk ^"%s^""g_szSoundsKNIFE_KILL ] ); 
            
client_cmdiVictim"spk ^"%s^""g_szSoundsKNIFE_KILLED ] ); 
            
client_print_color00"^4[Darknezz-zone] ^3%s ^1killed ^3%s ^1with a Knife!"get_nickiKiller ), get_nickiVictim ) ); 
        }    

        case 
CSW_HEGRENADE
        { 
            
client_cmdiKiller"spk ^"%s^""g_szSoundsNADE_KILL ] ); 
            
client_cmdiVictim"spk ^"%s^""g_szSoundsNADE_KILLED ] ); 
            
client_print_color00"^4[Darknezz-zone] ^3%s ^1killed ^3%s ^1with a HE Grenade!"get_nickiKiller ), get_nickiVictim ) ); 
        } 
    } 
    
    for( new 
0LEVELSi++ ) 
    { 
        if( 
g_iKillsiKiller ] == g_iLevels] ) 
        { 
            
NumberLeveliKiller
        } 
    } 

    
g_iKillsiKiller ] ++ 
    
g_iDeathsiKiller ] = 
    
    g_iDeaths
iVictim ] ++ 
    
g_iKillsiVictim ] = 


public 
LogEvent_Round_Startid 
{    
    ++
g_iRoundCount
    
    
set_hudmessage0100200, -1.00.3000.04.00.10.2, -); 
    
ShowSyncHudMsg0g_iSyncHud"Pick up your weapons and FIGHT! ^nRound %d started."g_iRoundCount ); 
    
    
client_cmd0"spk ^"%s^""g_szSoundsPREPARE_RESTART ] ); 


NumberLevelidg_iLevels 
{     
    
set_hudmessage01002000.050.6500.04.00.10.2, -); 
    
ShowSyncHudMsg0g_iSyncHudg_szMessagesg_iLevels ] ); 
    
    
client_cmd0"spk ^"%s^""g_szSounds_Killstreakg_iLevels ] ); 


get_nickindex 

    new 
szName32 ]; get_user_nameindexszNamecharsmaxszName ) ); 
    return 
szName

Thanks in advance !
Lolz0r is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-01-2015 , 13:11   Re: [REQ] Plugin to Off / On with Command
Reply With Quote #2

Spoiler


Didn't tested but should work. A question, did you tested this plugin before posting ? I see some things inside it that make no sense at all.
__________________
HamletEagle is offline
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 03-01-2015 , 17:49   Re: [REQ] Plugin to Off / On with Command
Reply With Quote #3

I tested it quickly. The command for the entire plugin work ? And what things you seem wrong ? Tomorrow I will test it and tell if it works and I edit my post.

Spoiler
Lolz0r is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-02-2015 , 09:12   Re: [REQ] Plugin to Off / On with Command
Reply With Quote #4

Not sure to understand you, command is say /usound and it shut down the plugin only for the player that use it. If you want to turn it on, just write the command again.
__________________
HamletEagle is offline
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 03-02-2015 , 12:31   Re: [REQ] Plugin to Off / On with Command
Reply With Quote #5

After "debug" :

Otherwise the plugin is good coded, how think ?
Attached Thumbnails
Click image for larger version

Name:	error.PNG
Views:	124
Size:	6.4 KB
ID:	142821  
Lolz0r is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-02-2015 , 13:39   Re: [REQ] Plugin to Off / On with Command
Reply With Quote #6

Have you tested this before asking for a modification ? Because the error is not related to what I did, it was missing some parts of the code.

PHP Code:
#include <amxmodx>  
#include <csx>  
#include <chatcolor>  

const LEVELS 7  

enum  
{  
    
HS_KILL
    
HS_KILLED
    
KNIFE_KILL
    
KNIFE_KILLED
    
NADE_KILL
    
NADE_KILLED
    
PREPARE_RESTART 
}  

new const 
g_szSounds[][] =  
{  
    
"sound/darknezz-zone/gotone.wav"
    
"sound/darknezz-zone/ow.wav"
    
"sound/darknezz-zone/humiliation.wav"
    
"sound/darknezz-zone/humiliation.wav"
    
"sound/darknezz-zone/nade.wav"
    
"sound/darknezz-zone/nade.wav"
    
"sound/darknezz-zone/preparestart.wav" 
}  

new const 
g_iLevelsLEVELS ] =  
{  
    
1//4,  
    
2//7,  
    
3//10,  
    
4//13,  
    
5//16,  
    
6//19,  
    
7  //22  
}  

new const 
g_szSounds_KillstreakLEVELS ][] =  
{  
    
"sound/darknezz-zone/firstkill.wav",  
    
"sound/darknezz-zone/multikill.wav",  
    
"sound/darknezz-zone/doublekill.wav",  
    
"sound/darknezz-zone/triplekill.wav",  
    
"sound/darknezz-zone/monsterkill.wav",  
    
"sound/darknezz-zone/megakill.wav",  
    
"sound/darknezz-zone/excellent.wav"  
}  

new const 
g_szMessagesLEVELS ][] =  
{  
    
"%s: First-Kill!",  
    
"%s: Multi-Kill!",  
    
"%s: Double-Kill!",  
    
"%s: Triple-Kill!",  
    
"%s: Monster-Kill!",  
    
"%s: Mega-Kill!",  
    
"%s: EXCELLENT!"  
}  

new 
g_iKills33 ];  
new 
g_iDeaths33 ];  
new 
bool:PluginState[33]

new 
g_iRoundCount
new 
g_iSyncHud;  

public 
plugin_precache()  
{  
    for( new 
sizeof g_szSounds ++ )  
    { 
        
precache_genericg_szSounds] );  
    } 

    for( new 
0LEVELSi++ )  
    { 
        
precache_genericg_szSounds_Killstreak] );  
    } 
}  

public 
plugin_init()  
{  
    
register_plugin"Ultimate Sounds""1.0""hornet & kostov" );  

    
register_logevent"LogEvent_Round_Start"2"1=Round_Start" );  

    
register_clcmd("say /usound""ClientCommand_ChangeSoundState")

    
g_iSyncHud CreateHudSyncObj();  
}  

public 
client_connect(id)
{
    
PluginState[id] = true
}

public 
client_deathiKilleriVictimiWeaponiHitGroup/*, TK*/ )  
{     
    if( !
is_user_connectediKiller ) || get_user_teamiKiller ) == get_user_teamiVictim ) )  
    {  
        return  
    }  

    if( 
iHitGroup == HIT_HEAD )  
    {  
        if(
PluginState[iKiller]) client_cmdiKiller"spk ^"%s^""g_szSoundsHS_KILL ] );  
        if(
PluginState[iVictim]) client_cmdiVictim"spk ^"%s^""g_szSoundsHS_KILLED ] );  
        
client_print_color00"^4[Darknezz-zone] ^3%s ^1killed ^3%s ^1with a HeadShot!"get_nickiKiller ), get_nickiVictim ) );  
        
        return;  
    }  

    switch( 
iWeapon )  
    {  
        case 
CSW_KNIFE:  
        {  
            if(
PluginState[iKiller]) client_cmdiKiller"spk ^"%s^""g_szSoundsKNIFE_KILL ] );  
            if(
PluginState[iVictim]) client_cmdiVictim"spk ^"%s^""g_szSoundsKNIFE_KILLED ] );  
            
client_print_color00"^4[Darknezz-zone] ^3%s ^1killed ^3%s ^1with a Knife!"get_nickiKiller ), get_nickiVictim ) );  
        }     

        case 
CSW_HEGRENADE:  
        {  
            if(
PluginState[iKiller]) client_cmdiKiller"spk ^"%s^""g_szSoundsNADE_KILL ] );  
            if(
PluginState[iVictim]) client_cmdiVictim"spk ^"%s^""g_szSoundsNADE_KILLED ] );  
            
client_print_color00"^4[Darknezz-zone] ^3%s ^1killed ^3%s ^1with a HE Grenade!"get_nickiKiller ), get_nickiVictim ) );  
        }  
    }  

    for( new 
0LEVELSi++ )  
    {  
        if( 
g_iKillsiKiller ] == g_iLevels] )  
        {  
            
NumberLeveliKiller)  
        }  
    }  

    
g_iKillsiKiller ] ++  
    
g_iDeathsiKiller ] = 0  

    g_iDeaths
iVictim ] ++  
    
g_iKillsiVictim ] = 0  
}  

public 
LogEvent_Round_Start()  
{     
    ++
g_iRoundCount;  

    new 
Players[32], PlayersNumid
    get_players
(PlayersPlayersNum)
    for(new 
iPlayersNumi++)
    {
        
id Players[i]
        if(
PluginState[id])
        {
            
set_hudmessageid100200, -1.00.3000.04.00.10.2, -);  
            
ShowSyncHudMsgidg_iSyncHud"Pick up your weapons and FIGHT! ^nRound %d started."g_iRoundCount );  

            
client_cmdid"spk ^"%s^""g_szSoundsPREPARE_RESTART ] );
        }
    }
}  

NumberLevelidg_iLevels )  
{      
    
set_hudmessage01002000.050.6500.04.00.10.2, -);  
    
    new 
PlayerName[32]
    
get_user_name(idPlayerNamecharsmax(PlayerName))
    
ShowSyncHudMsg0g_iSyncHudg_szMessagesg_iLevels ], PlayerName );  
    
    
client_cmd0"spk ^"%s^""g_szSounds_Killstreakg_iLevels ] );  
}  

get_nickindex )  
{  
    new 
szName32 ]; get_user_nameindexszNamecharsmaxszName ) );  
    return 
szName;  
}  

public 
ClientCommand_ChangeSoundState(id)
{
    new const 
Messages[][] =
    {
        
"disabled",
        
"enabled"
    
}
    
PluginState[id] = !PluginState[id]
    
client_print(idprint_chat"You have just %s ultimate sounds"Messages[PluginState[id]])

Try now and see.
__________________
HamletEagle is offline
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 03-04-2015 , 13:20   Re: [REQ] Plugin to Off / On with Command
Reply With Quote #7

Sorry for the delay, but there was no way to test...

I think there was no error with the plugin from # 1
Mistakes are not you here :

NumberLevel (iKiller, i)
--->
NumberLevel (i)


and

NumberLevel (id, g_iLevels)
--->
NumberLevel (g_iLevels)


In the plugin of # 6 two lines are what in # 1 and no such problems.

After the test :
Chat messages and this function :

NumberLevel (g_iLevels)

the command should also apply to them, now it does not work for them.


EDIT: One question :

If I use this get_nick( index ) instead
new PlayerName[32]
get_user_name(id, PlayerName, charsmax(PlayerName))


Instead of PlayerName , what should I write ?

Last edited by Lolz0r; 03-05-2015 at 12:47.
Lolz0r is offline
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 03-24-2015 , 12:07   Re: [REQ] Plugin to Off / On with Command
Reply With Quote #8

I forgot about that, obviously and you.

Can you add the command for NumberLevel function and for all three chat messages ?
Lolz0r is offline
Reply



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 07:55.


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