AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   [request] bomb reward. (https://forums.alliedmods.net/showthread.php?t=238778)

FR0NTLINE 04-16-2014 15:51

[request] bomb reward.
 
I'm in need of A health reward for THE CT who defuses the bomb
He will receive 25 health the next round for his Accomplishments.
Thank you.

Buckshot 04-16-2014 16:38

Re: [request] bomb reward.
 
Code:
#include < amxmodx > #include < fakemeta_util > // edit: I got a brainfart, and included this instead of using set_user_health.. but whatever, it doesnt make any performances worse, so im just gonna be lazy n leave you here, fakemeta. #include < hamsandwich > #pragma semicolon 1 new bool:HasReward[ 32 ]; public plugin_init( ) {     register_plugin( "Bomb Reward", "1.0", "BuckShot" );         register_logevent( "Player_DefusedBomb", 3, "2=Defused_The_Bomb" );     RegisterHam( Ham_Spawn, "player", "FwdHamPlayerSpawnPost", 1 ); } stock get_loguser_index( ) {     new loguser[ 80 ], name[ 32 ];     read_logargv( 0, loguser, 79 );     parse_loguser( loguser, name, 31 );       return get_user_index( name ); } public Player_DefusedBomb( ) {         new id = get_loguser_index( );     HasReward[ id ] = true; } public FwdHamPlayerSpawnPost( id ) {     if( HasReward[ id ] )     {         set_pev( id, pev_health, float( pev( id, pev_health ) + 25 ) );         HasReward[ id ] = false;     } } public client_disconnect( id ) {     if( HasReward[ id ] )         HasReward[ id ] = false; }

Flick3rR 04-16-2014 16:52

Re: [request] bomb reward.
 
Well, it works, buckshot! And I had some time, made this:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "Defuse/Plant Bonus"
#define VERSION "1.0"
#define AUTHOR "AUTHOR"

new bool:HasDefuse[33], bool:HasPlant[33]
new 
cvar_plant

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("HLTV""new_round""a""1=0""2=0")  
    
register_logevent("defused"3"2=Defused_The_Bomb")
    
register_logevent("planted"3"2=Planted_The_Bomb")
    
cvar_plant register_cvar("plant_hp_bonus""0")
}

public 
defused()
{
    new 
id get_loguser_index()
    
HasDefuse[id] = true
    ColorMessage
(id"^3You will receive a ^425 HP bonus ^3at the begining of next round for defusing the bomb!")
}

public 
planted()
{
    if(
get_pcvar_num(cvar_plant))
    {
        new 
id get_loguser_index()
        
HasPlant[id] = true
        ColorMessage
(id"^3You will receive a ^425 HP bonus ^3at the begining of next round for planting the bomb!")
    }
}

public 
new_round(id)
{
    if(
HasDefuse[id] == true || HasPlant[id] == true)
        
set_user_health(idget_user_health(id) + 25)
}

stock get_loguser_index()
{
    new 
loguser[80], name[32]
    
read_logargv(0loguser79)
    
parse_loguser(logusername31)
 
    return 
get_user_index(name)
}

stock ColorMessage(const id, const input[], any:...){
            new 
count 1players[32];
            static 
msg191 ];
            
vformat(msg190input3);
            if (
idplayers[0] = id; else get_players(players count "ch"); {
                for (new 
0counti++){
                    if (
is_user_connected(players[i])){
                        
message_begin(MSG_ONE_UNRELIABLE get_user_msgid("SayText"), _players[i]);
                        
write_byte(players[i]);
                        
write_string(msg);
                        
message_end();}}}
        } 

Added colormessage and eventually bonus for planting the bomb - turn it on or off with the cvar:
plant_hp_bonus "0/1"
It's turned off by default (as you wish)

Buckshot 04-16-2014 17:03

Re: [request] bomb reward.
 
Quote:

Originally Posted by Flick3rR (Post 2125504)
Well, it works, buckshot! And I had some time, made this:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "Defuse/Plant Bonus"
#define VERSION "1.0"
#define AUTHOR "AUTHOR"

new bool:HasDefuse[33], bool:HasPlant[33]
new 
cvar_plant

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("HLTV""new_round""a""1=0""2=0")  
    
register_logevent("defused"3"2=Defused_The_Bomb")
    
register_logevent("planted"3"2=Planted_The_Bomb")
    
cvar_plant register_cvar("plant_hp_bonus""0")
}

public 
defused()
{
    new 
id get_loguser_index()
    
HasDefuse[id] = true
    ColorMessage
(id"^3You will receive a ^425 HP bonus ^3at the begining of next round for defusing the bomb!")
}

public 
planted()
{
    if(
get_pcvar_num(cvar_plant))
    {
        new 
id get_loguser_index()
        
HasPlant[id] = true
        ColorMessage
(id"^3You will receive a ^425 HP bonus ^3at the begining of next round for planting the bomb!")
    }
}

public 
new_round(id)
{
    if(
HasDefuse[id] == true || HasPlant[id] == true)
        
set_user_health(idget_user_health(id) + 25)
}

stock get_loguser_index()
{
    new 
loguser[80], name[32]
    
read_logargv(0loguser79)
    
parse_loguser(logusername31)
 
    return 
get_user_index(name)
}

stock ColorMessage(const id, const input[], any:...){
            new 
count 1players[32];
            static 
msg191 ];
            
vformat(msg190input3);
            if (
idplayers[0] = id; else get_players(players count "ch"); {
                for (new 
0counti++){
                    if (
is_user_connected(players[i])){
                        
message_begin(MSG_ONE_UNRELIABLE get_user_msgid("SayText"), _players[i]);
                        
write_byte(players[i]);
                        
write_string(msg);
                        
message_end();}}}
        } 

Added colormessage and eventually bonus for planting the bomb - turn it on or off with the cvar:
plant_hp_bonus "0/1"
It's turned off by default (as you wish)

You got many problems in your code... I'm not gonna review your whole code, but one thing i see right away: You can't get player index in a global event such as hltv event like this: "public new_round(id)"..

FR0NTLINE 04-16-2014 17:20

Re: [request] bomb reward.
 
It works! Thanks.

hornet 04-16-2014 19:20

Re: [request] bomb reward.
 
@Buckshot to be safe from errors, you need to set reward false on player on disconnect.

Buckshot 04-16-2014 19:30

Re: [request] bomb reward.
 
Quote:

Originally Posted by hornet (Post 2125576)
@Buckshot to be safe from errors, you need to set reward false on player on disconnect.

Thanks, fixed :) Still learning you know.

FR0NTLINE 04-16-2014 20:20

Re: [request] bomb reward.
 
Thanks Hornet I was hoping you'd pop up for a correction :)
AND THANK YOU BUCKSHOT!!!!!!

swapped 04-17-2014 01:27

Re: [request] bomb reward.
 
Quote:

Originally Posted by hornet (Post 2125576)
@Buckshot to be safe from errors, you need to set reward false on player on disconnect.

Also check is_user_alive() in ham_Spawn

hornet 04-17-2014 02:57

Re: [request] bomb reward.
 
Quote:

Originally Posted by swapped (Post 2125655)
Also check is_user_alive() in ham_Spawn

Not required.


All times are GMT -4. The time now is 17:53.

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