AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Show also while spectating (https://forums.alliedmods.net/showthread.php?t=185215)

mazmaajinsh 05-14-2012 07:38

Show also while spectating
 
Hello.
I found this plugin, and what it does is shows information about player on which you are aiming - name, HP, armor.

But could someone show me, how to make it also display the information of the person while you are spectating him?

Code:
/*****************************************************\ =============================== || [ZP] Aim Info Plugin v1.0 || =============================== ||DESCRIPTION||     When you aim at your friend, a hud message     appears which shows you the Name, HP,     Armor and Ammo Packs of your friend. ||CREDITS||     - AMX MOD X Team ----> For most of the natives     - MeRcyLeZZ ----> For ZP 4.3     - Sn!ff3r ----> For the Actual Aim info Plugin \*****************************************************/ #include <amxmodx> #include <zombieplague> #define PLUGIN "Aim Info Plugin" #define VERSION "1.0" #define AUTHOR "@bdul!+Sn!ff3r" new g_status_sync public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("StatusValue", "showStatus", "be", "1=2", "2!0")     register_event("StatusValue", "hideStatus", "be", "1=1", "2=0")     register_dictionary("zp_aim_info.txt");         g_status_sync = CreateHudSyncObj() } public showStatus(id) {     if(!is_user_bot(id) && is_user_connected(id))     {         new name[32], pid = read_data(2)             get_user_name(pid, name, 31)         new color1 = 0, color2 = 0             new team1 = zp_get_user_zombie(id), team2 = zp_get_user_zombie(pid)             if (team2 == 1)             color1 = 255         else             color2 = 255                         if (team1 == team2)    // friend         {             set_hudmessage(color1, 50, color2, -1.0, 0.60, 1, 0.01, 3.0, 0.01, 0.01, -1)             ShowSyncHudMsg(id, g_status_sync, "%L", LANG_PLAYER, "AIM_INFO", name, get_user_health(pid), get_user_armor(pid), zp_get_user_ammo_packs(pid))         }     } } public hideStatus(id) {     ClearSyncHud(id, g_status_sync) } /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE *{\\ rtf1\\ ansi\\ ansicpg1252\\ deff0\\ deflang1033{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par } */

hornet 05-14-2012 07:47

Re: Show also while spectating
 
You need a repeated task or think that displays the message during whilst spectating. I believe that EV_INT_iuser2 is the correct key to get the player id that a user is spectating.

mazmaajinsh 05-14-2012 10:50

Re: Show also while spectating
 
how should i do that?

Bugsy 05-14-2012 23:36

Re: Show also while spectating
 
In a perfect world you would only want the entity thinking when there are player(s) spectating. I don't feel like doing the extra work though. I also do not have the zombieplague include so I was not able to compile\test.

PHP Code:

#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <zombieplague>

new const Version[] = "0.1";

const 
MAX_PLAYERS 32;

new 
g_status_sync g_iSpecEntity;

#define IsSpectating(%1)    (is_user_connected(%1)&&!is_user_alive(%1)&&!is_user_bot(%1))

public plugin_init() 
{
    
register_plugin"Spectate Info" Version "@bdul!+Sn!ff3r+bugsy" );
    
    
register_dictionary("zp_aim_info.txt");
    
g_status_sync CreateHudSyncObj()
    
    
g_iSpecEntity create_entity"info_target" );
    
entity_set_stringg_iSpecEntity EV_SZ_classname "spec_entity" );
    
register_think"spec_entity" "fw_SpecEntThink" );
    
entity_set_floatg_iSpecEntity EV_FL_nextthink , ( get_gametime() + 0.2 ) );
}

public 
fw_SpecEntThinkiEntity )
{
    static 
iSpectator iSpectated;
    
    for ( 
iSpectator iSpectator <= MAX_PLAYERS iSpectator++ )
    {
        if ( 
IsSpectatingiSpectator ) && ( iSpectated peviSpectator pev_iuser2 ) ) )
        {
            
//iSpectator is spectating iSpectated
        
            
static name[32];
            
            
get_user_name(iSpectatednamecharsmax(name))
            new 
color1 0color2 0
            
            
new team1 zp_get_user_zombie(iSpectator), team2 zp_get_user_zombie(iSpectated)
            
            if (
team2 == 1)
                
color1 255
            
else
                
color2 255
            
            
if (team1 == team2)    // friend
            
{
                
set_hudmessage(color150color2, -1.00.6010.013.00.010.01, -1)
                
ShowSyncHudMsg(iSpectatorg_status_sync"%L"LANG_PLAYER"AIM_INFO"nameget_user_health(iSpectated), get_user_armor(iSpectated), zp_get_user_ammo_packs(iSpectated))
            }
        }
    }
    
    
entity_set_floatg_iSpecEntity EV_FL_nextthink , ( get_gametime() + 0.2 ) );



Rirre 05-15-2012 13:34

Re: Show also while spectating
 
@Bugsy, can you make a version without ZP?


All times are GMT -4. The time now is 00:24.

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