Raised This Month: $32 Target: $400
 8% 

Swap Defuser


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Fun Stuff       
Alekkkk
Member
Join Date: Mar 2012
Location: Bulgaria
Old 05-03-2012 , 16:18   Swap Defuser
Reply With Quote #1

Description

This is a very simple plugin. If a CT have defuser kit and dies, the kit will be gived to another CT who don't have one.

CVARs
  • amx_defuserenable <0|1>
    • 0 - Disabled
    • 1 - Enabled
  • amx_defusermsg <0|1>
    • 0 - Disable message
    • 1 - Will show message from who you got the defuser

Requirements
  • cstrike
  • hamsandwich

Installation
  • Get Plugin and place SwapDefuser.amxx to addons/amxmodx/plugins
  • Open the plugins.ini from your server's addons/amxmodx/configs folder and add SwapDefuser.amxx in it. Then save the file.
  • Place SwapDefuser.txt in your server's addons/amxmodx/data/lang folder.
Attached Files
File Type: txt SwapDefuser.txt (59 Bytes, 323 views)
File Type: sma Get Plugin or Get Source (SwapDefuser.sma - 1218 views - 1.1 KB)
__________________

Last edited by Alekkkk; 05-11-2012 at 00:42.
Alekkkk is offline
Send a message via Skype™ to Alekkkk
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 05-03-2012 , 16:31   Re: Swap Defuser
Reply With Quote #2

PHP Code:
new name[18
Name max length is 32.

PHP Code:
cs_set_user_defuse(id,0
This is not required, since when a player die, he loses defuser.

I would have made like that : (with Ham_Killed hooked as post)

PHP Code:
get_playersplayerscount"ae""CT" );
for( new 
0tempidcounti++ )
{
    
tempid players];
    if( !
cs_get_user_defusetempid ) )
    {
        
cs_set_user_defusetempid );

        if( 
get_pcvar_numgCvarShowMSG ) )
        {
            new 
name32 ];
            
get_user_nameidnamecharsmaxname ) );
            
client_printtempidprint_chat"%L"id"DEFUSER_MSG"name );
        }

        break;
    }

__________________
You can do anything you set your mind to, man.


Last edited by Devil259; 05-03-2012 at 16:32.
Devil259 is offline
Alekkkk
Member
Join Date: Mar 2012
Location: Bulgaria
Old 05-04-2012 , 12:54   Re: Swap Defuser
Reply With Quote #3

Quote:
Originally Posted by Devil259 View Post
PHP Code:
new name[18
Name max length is 32.
Fixed
Quote:
Originally Posted by Devil259 View Post
PHP Code:
cs_set_user_defuse(id,0
This is not required, since when a player die, he loses defuser.
If i remove that , the defuser would be dropped to the ground , i don't want that happend
Quote:
Originally Posted by Devil259 View Post
I would have made like that : (with Ham_Killed hooked as post)

PHP Code:
get_playersplayerscount"ae""CT" );
for( new 
0tempidcounti++ )
{
    
tempid players];
    if( !
cs_get_user_defusetempid ) )
    {
        
cs_set_user_defusetempid );

        if( 
get_pcvar_numgCvarShowMSG ) )
        {
            new 
name32 ];
            
get_user_nameidnamecharsmaxname ) );
            
client_printtempidprint_chat"%L"id"DEFUSER_MSG"name );
        }

        break;
    }

I wanted to take all CT's who don't have defuser and take random of them to give him a defuser.
Is there something wrong with my code , or you just prefer yours?
__________________
Alekkkk is offline
Send a message via Skype™ to Alekkkk
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-04-2012 , 13:10   Re: Swap Defuser
Reply With Quote #4

Quote:
Originally Posted by Alekkkk View Post
I wanted to take all CT's who don't have defuser and take random of them to give him a defuser.
Is there something wrong with my code , or you just prefer yours?
Your code gets a random CT without a defuser, and Devil's gets the first CT without a defuser.
Your code is fine as is for what you want to accomplish.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 05-04-2012 , 14:33   Re: Swap Defuser
Reply With Quote #5

I don't understand this line :

PHP Code:
if (cs_get_user_team(players[i]) != CS_TEAM_CT || !cs_get_user_defuse(players[i]) ) 
Why do you take players who aren't in CT team ?

Also, you should cache players[i] in a var.

Quote:
Originally Posted by Alekkkk View Post
If i remove that , the defuser would be dropped to the ground , i don't want that happend
Ok, I understand now
__________________
You can do anything you set your mind to, man.


Last edited by Devil259; 05-04-2012 at 14:34.
Devil259 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-04-2012 , 15:16   Re: Swap Defuser
Reply With Quote #6

Quote:
Originally Posted by Devil259 View Post
I don't understand this line :

PHP Code:
if (cs_get_user_team(players[i]) != CS_TEAM_CT || !cs_get_user_defuse(players[i]) ) 
Why do you take players who aren't in CT team ?
He is removing non-CT players, and CT players who don't have a defusal.
The defusal check is backwards, since he should only keep CT players who don't have one.

Also,
Code:
players[ i-- ] = players[ count-- ];
should be
Code:
players[ i-- ] = players[ --count ];
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Alekkkk
Member
Join Date: Mar 2012
Location: Bulgaria
Old 05-05-2012 , 09:19   Re: Swap Defuser
Reply With Quote #7

My fault. Fixed.
__________________
Alekkkk is offline
Send a message via Skype™ to Alekkkk
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 05-05-2012 , 17:20   Re: Swap Defuser
Reply With Quote #8

Quote:
PHP Code:
get_players(playerscount)   
    
    for (new 
icounti++)
    {
        if (
cs_get_user_team(players[i]) != CS_TEAM_CT || cs_get_user_defuse(players[i]) )
            
playersi-- ] = players[ --count ];
    } 
I would get only alive CTs, then check if they have a diffuse

PHP Code:
get_players(playerscount"ae""CT"
PHP Code:
if( cs_get_user_defuse(players[i]) ) 
that would cut your for-loop iterations in about half, and get rid of another one of your if- checks. As well as make it easier to read. (directly showing you're only dealing with alive CTs)
This is just personal opinion. Your code looks like it works fine. But that would be more efficient.

Other than that...well done, man.

Last edited by Liverwiz; 05-05-2012 at 17:27.
Liverwiz is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-09-2015 , 11:44   Re: Swap Defuser
Reply With Quote #9

Unapproved, do not post plugins just for the sake of posting. You could add more things, like give defuse only when no ct have defuse kit(controlable by cvar), maybe give to one that have a requiered ration(considering dead/kills -> from entire map or only current round), etc.

If you add more things PM me and I will check it again.
__________________
HamletEagle 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 00:11.


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