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

Need to change plugin for default OFF and ON with command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
007asha
Member
Join Date: Mar 2010
Old 09-05-2010 , 11:53   Need to change plugin for default OFF and ON with command
Reply With Quote #1

Hello all.

I want to change plugin "show teammate`s health", because not all like this.

So:
by default it`s off (for players who join), but if any1 write in chat "/th" he will see health of team mates!

Here`s a plugin:

Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <fun>
#define NAME "show teammate's health"
#define VERSION "1.3.1"
#define AUTHOR "K.K.Lv+Ryokin"

new g_max_players, g_sync_creat_statustext, g_sync_creat_list
new bool:g_teammate[33]
public plugin_init()
{
register_plugin(NAME, VERSION, AUTHOR)
 
RegisterHam(Ham_Spawn, "player", "player_spawn", 1)
 
register_clcmd("say /health", "clcmd_health")
 
register_event("StatusValue", "show_teammate_health", "be", "1=2", "2!0")
register_event("StatusValue", "set_team", "be", "1=1")
 
g_max_players = get_maxplayers()
g_sync_creat_statustext = CreateHudSyncObj()
g_sync_creat_list = CreateHudSyncObj()
}
public clcmd_health(client)
{
show_health(client)
return PLUGIN_CONTINUE
}
public player_spawn(client)
{
remove_task(client)
if (is_user_alive(client))
{
set_task(1.0, "show_health", client,_,_,"b")
}
}
public show_health(client)
{
static message[1024];
static name[32];
 
new health, id, len;
 
len = format(message, charsmax(message), "Жизни союзника:^n");
for (id = 1; id <= g_max_players; id++)
{
if (id != client && is_user_connected(id) && cs_get_user_team(id) == cs_get_user_team(client) && is_user_alive(id))
{
health = get_user_health(id);
get_user_name(id, name, 31);
len += format(message[len], charsmax(message) - len, "%-22.22s: %d^n", name, health);
}
}
set_hudmessage(100, 200, 0, 0.05, 0.35, 0, 0.02, 5.0, 0.1, 0.2, 2);
ShowSyncHudMsg(client, g_sync_creat_list, message);
}
public set_team(id)
g_teammate[id] = bool:(read_data(2) == 1);
public show_teammate_health(id)
{
if(!is_user_bot(id) && is_user_connected(id) && is_user_alive(id))
{
static name[32]
 
new pid = read_data(2)
new red = 0, blue = 0
 
if (cs_get_user_team(pid) == CS_TEAM_T)
red = 255
else if(cs_get_user_team(pid) == CS_TEAM_CT)
blue = 255
 
get_user_name(pid, name, charsmax(name))
new health = get_user_health(pid)
if (g_teammate[id])
{
set_hudmessage(red, 50, blue, -1.0, 0.60, 1, 0.01, 0.6, 0.01, 0.01, 8)
ShowSyncHudMsg(id, g_sync_creat_statustext, "Союзник:%s -- Жизни:%d", name, health)
}
else
{
set_hudmessage(red, 50, blue, -1.0, 0.60, 1, 0.01, 0.6, 0.01, 0.01, 8)
ShowSyncHudMsg(id, g_sync_creat_statustext, "Враг:%s", name)
}
}
return PLUGIN_CONTINUE
}
public client_disconnect(client)
{
remove_task(client)
}
007asha is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-05-2010 , 13:01   Re: Need to change plugin for default OFF and ON with command
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <fun>
#define NAME "show teammate's health"
#define VERSION "1.3.1"
#define AUTHOR "K.K.Lv+Ryokin"

new g_max_playersg_sync_creat_statustextg_sync_creat_list
new bool:g_teammate[33]

public 
plugin_init()
{
    
register_plugin(NAMEVERSIONAUTHOR)

    
RegisterHam(Ham_Spawn"player""player_spawn"1)

    
register_clcmd("say /health""clcmd_health")
    
register_clcmd("say /th""cmdStartHealthLoop")

    
register_event("StatusValue""show_teammate_health""be""1=2""2!0")
    
register_event("StatusValue""set_team""be""1=1")

    
g_max_players get_maxplayers()
    
g_sync_creat_statustext CreateHudSyncObj()
    
g_sync_creat_list CreateHudSyncObj()
}

public 
clcmd_health(client)
{
    
show_health(client)
    return 
PLUGIN_CONTINUE
}

public 
cmdStartHealthLoop(id)
{
    
remove_task(client)
    if (
is_user_alive(client))
    {
        
set_task(1.0"show_health"client,_,_,"b")
    }
}

public 
show_health(client)
{
    static 
message[1024];
    static 
name[32];

    new 
healthidlen;

    
len format(messagecharsmax(message), "????? ????????:^n");
    for (
id 1id <= g_max_playersid++)
    {
        if (
id != client && is_user_connected(id) && cs_get_user_team(id) == cs_get_user_team(client) && is_user_alive(id))
        {
            
health get_user_health(id);
            
get_user_name(idname31);
            
len += format(message[len], charsmax(message) - len"%-22.22s: %d^n"namehealth);
        }
    }
    
set_hudmessage(10020000.050.3500.025.00.10.22);
    
ShowSyncHudMsg(clientg_sync_creat_listmessage);
}

public 
set_team(id)
    
g_teammate[id] = bool:(read_data(2) == 1);

public 
show_teammate_health(id)
{
    if(!
is_user_bot(id) && is_user_connected(id) && is_user_alive(id))
    {
        static 
name[32]

        new 
pid read_data(2)
        new 
red 0blue 0

        
if (cs_get_user_team(pid) == CS_TEAM_T)
        
red 255
        
else if(cs_get_user_team(pid) == CS_TEAM_CT)
        
blue 255

        get_user_name
(pidnamecharsmax(name))
        new 
health get_user_health(pid)
        if (
g_teammate[id])
        {
            
set_hudmessage(red50blue, -1.00.6010.010.60.010.018)
            
ShowSyncHudMsg(idg_sync_creat_statustext"???????:%s -- ?????:%d"namehealth)
        }
        else
        {
            
set_hudmessage(red50blue, -1.00.6010.010.60.010.018)
            
ShowSyncHudMsg(idg_sync_creat_statustext"????:%s"name)
        }
    }
    return 
PLUGIN_CONTINUE
}

public 
client_disconnect(client)
{
    
remove_task(client)

__________________
fysiks 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 03:44.


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