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

Health & Armor in Scoreboard


Post New Thread Reply   
 
Thread Tools Display Modes
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-17-2009 , 11:29   Re: Health & Armor in Scoreboard
Reply With Quote #21

Quote:
Originally Posted by xPaw View Post
You dont need to use globals for g_msg*, only for scoreinfo

MSG_ALL -> MSG_BROADCAST ?
You just don't need to send any message, just alter params of the resend-by-amxx-due-to-register_message one.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 09-17-2009 , 12:04   Re: Health & Armor in Scoreboard
Reply With Quote #22

Quote:
Originally Posted by ConnorMcLeod View Post
You just don't need to send any message, just alter params of the resend-by-amxx-due-to-register_message one.
Well HP can change, but if you will only change it in message ScoreInfo by setting args, it wont be so correct.
__________________
xPaw is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-17-2009 , 12:05   Re: Health & Armor in Scoreboard
Reply With Quote #23

Ah exact, but there is no need to hook Health message pre, register_event should be enough, same for armorvalue.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 09-17-2009 , 12:19   Re: Health & Armor in Scoreboard
Reply With Quote #24

Maybe laik that ?
PHP Code:
#include <amxmodx>

new bool:g_bConnected33 ];
new 
g_iMsgScoreInfog_iMaxPlayers;

public 
plugin_init( ) {
    
register_plugin"HP AP @ SB""1.0""Alucard" );
    
    
// Battery will work better instead of ArmorType ?
    
    
register_event"Health""EventChange""be" );
    
register_event"Battery""EventChange""be" );
    
    
register_message( ( g_iMsgScoreInfo get_user_msgid"ScoreInfo" ) ), "MessageScoreInfo" );
    
    
g_iMaxPlayers get_maxplayers( );
}

public 
client_putinserverid )
    
g_bConnectedid ] = true;

public 
client_disconnectid )
    
g_bConnectedid ] = false;

public 
MessageScoreInfo( const MsgId, const MsgType, const MsgDest ) {
    new 
id get_msg_arg_int);
    new 
bool:bAlive bool:( is_user_aliveid ) );
    
    
set_msg_arg_int2ARG_SHORTbAlive get_user_healthid ) : );
    
set_msg_arg_int3ARG_SHORTbAlive get_user_armorid ) : );
}

public 
EventChange( ) {
    static 
idbool:bAlive false;
    
    for( 
id 1id <= g_iMaxPlayersid++ ) {
        if( !
g_bConnectedid ] )
            continue;
        
        
bAlive bool:( is_user_aliveid ) );
        
        
message_beginMSG_BROADCASTg_iMsgScoreInfo );
        
write_byte id );
        
write_shortbAlive get_user_healthid ) : );
        
write_shortbAlive get_user_armorid ) : );
        
write_short);
        
write_shortget_user_teamid ) );
        
message_end( );
    }

__________________
xPaw is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-17-2009 , 12:23   Re: Health & Armor in Scoreboard
Reply With Quote #25

xPaw why do you send MSG_BROADCAST in the loop ? Once is enough.

PHP Code:
////////////////////////////////////////
//                                    //
//    Credits:              //
//  tostly, joropito, L//, Starsailor //
//                                    //
////////////////////////////////////////

#include <amxmodx>

#define PLUGIN    "New Plugin"
#define AUTHOR    "Alucard"
#define VERSION    "1.2"

enum _:ScoreInfo_Args {
    
PlayerID 1,
    
Frags,
    
Deaths,
    
ClassID,
    
TeamID
}

new 
g_msgScoreInfo
new g_MaxPlayers
new p_MsgOnp_MsgDelay

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_cvar("health_armor_scoreboard"VERSION,FCVAR_SERVER|FCVAR_SPONLY)
    
    
p_MsgOn register_cvar("has_msg_on""1")
    
p_MsgDelay register_cvar("has_msg_delay""180.0")

    
g_msgScoreInfo get_user_msgid("ScoreInfo")
    
register_message(g_msgScoreInfo"Message_ScoreInfo")

    
register_event("Battery""Event_Battery""b")
    
register_event("Health""Event_Health""b")
    
    
g_MaxPlayers get_maxplayers()
    
    
set_task(get_pcvar_float(p_MsgDelay), "MsgToPlayers", .flags="b")
}

/*Name:      ScoreInfo
Structure:     
byte     PlayerID
short     Frags
short     Deaths
short     ClassID?
short     TeamID */
public Message_ScoreInfo(iMsgIdiMsgTypeiMsgEnt)
{
    new 
id get_msg_arg_int(PlayerID)

    
set_msg_arg_int(FragsARG_SHORTget_user_health(id))
    
set_msg_arg_int(DeathsARG_SHORTget_user_armor(id))
}

Send_ScoreInfo(idiFragsiDeathsiTeamID)
{
    
message_begin(MSG_BROADCASTg_msgScoreInfo)
    
write_byte(id)  
    
write_short(iFrags
    
write_short(iDeaths
    
write_short(0
    
write_short(iTeamID
    
message_end()
}

/*Name:      Battery
Structure:     
short     Armor */
public Event_Batteryid )
{
    
Send_ScoreInfo(idget_user_health(id), read_data(1), get_user_team(id))
}

/*Name:      Health
Structure:     
byte     Health*/
public Event_Healthid )
{
    
Send_ScoreInfo(idread_data(1), get_user_armor(id), get_user_team(id))
}

public 
MsgToPlayers()
{
    if(
get_pcvar_num(p_MsgOn) )
    {
        
client_print(0print_chat"[H & A] In this server Frags & Deaths are replaced with Health & Armor in the Scoreboard.")
    }

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 09-17-2009 , 12:25   Re: Health & Armor in Scoreboard
Reply With Quote #26

I was lazy to think and blabla
__________________
xPaw is offline
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 09-17-2009 , 21:39   Re: Health & Armor in Scoreboard
Reply With Quote #27

Quote:
Version 1.2
  • In v1.1 sometimes the update of the hp & ap doesn't work correctyle, now work perfect (thx connor)
  • Code optimization (thx connor)
  • Added support when player die, 0 hp & 0 ap.
  • Added colors to the boring adv message.
  • Ofcourse added Connor in the credits.
Thx.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 09-18-2009 , 00:32   Re: Health & Armor in Scoreboard
Reply With Quote #28

PHP Code:
get_user_msgid("SayText"
Store in global variable.
__________________
xPaw is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 09-20-2009 , 15:36   Re: Health & Armor in Scoreboard
Reply With Quote #29

You should change this:

PHP Code:
get_players(playerscount"ch"
get_players() doesn't work well with flags. Also, the included is_user_connected() check is unnecessary.

Also make the changes suggested by previous posters.

There are a few mistakes and optimizations that can be made, however it is acceptable.

If you would like any information regarding possible adjustments you could make or things you could do to make this better, please feel free to post here or PM me.

Approved.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 09-20-2009 , 16:50   Re: Health & Armor in Scoreboard
Reply With Quote #30

Thx Hawk, updated:

Quote:
  • Version 1.3
    • get_user_msgid("SayText")stored in a global variable.
    • deleted "connected" check in chat_color stock.
I didn't change nothing about get_players.... cuz i have some doubts... i know that get_players have some problems with flags but as far as i know.. the problem is with the "e" flag...

http://forums.alliedmods.net/showpos...72&postcount=7
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
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 03:59.


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