AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved/Old Plugins (https://forums.alliedmods.net/forumdisplay.php?f=27)
-   -   Swap Defuser (https://forums.alliedmods.net/showthread.php?t=184312)

Alekkkk 05-03-2012 16:18

Swap Defuser
 
2 Attachment(s)
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.

Devil259 05-03-2012 16:31

Re: Swap Defuser
 
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;
    }



Alekkkk 05-04-2012 12:54

Re: Swap Defuser
 
Quote:

Originally Posted by Devil259 (Post 1701404)
PHP Code:

new name[18

Name max length is 32.

Fixed
Quote:

Originally Posted by Devil259 (Post 1701404)
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 (Post 1701404)
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?

Exolent[jNr] 05-04-2012 13:10

Re: Swap Defuser
 
Quote:

Originally Posted by Alekkkk (Post 1702082)
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.

Devil259 05-04-2012 14:33

Re: Swap Defuser
 
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 (Post 1702082)
If i remove that , the defuser would be dropped to the ground , i don't want that happend

Ok, I understand now :mrgreen:

Exolent[jNr] 05-04-2012 15:16

Re: Swap Defuser
 
Quote:

Originally Posted by Devil259 (Post 1702143)
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 ];

Alekkkk 05-05-2012 09:19

Re: Swap Defuser
 
My fault. Fixed.

Liverwiz 05-05-2012 17:20

Re: Swap Defuser
 
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.

HamletEagle 10-09-2015 11:44

Re: Swap Defuser
 
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.


All times are GMT -4. The time now is 04:16.

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