Raised This Month: $ Target: $400
 0% 

Getting spec info


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ex1ne
Senior Member
Join Date: Oct 2011
Location: Norway
Old 01-12-2013 , 03:45   Getting spec info
Reply With Quote #1

I'm doing a ghost plugin for my server and I can't really figure out how to find a spectator...
Not like the team, but someone who's dead and looking at someone who's a ghost.
I want to add a hud message to the one who's looking at the ghost. Somewhat like "This player is currently in Ghost-Mode". I couldn't find anything by searching.
__________________
Ex1ne is offline
naven
Veteran Member
Join Date: Jun 2008
Location: Poland, Cieszyn
Old 01-12-2013 , 05:54   Re: Getting spec info
Reply With Quote #2

use this http://forums.alliedmods.net/showthread.php?p=484967
__________________
naven.com.pl
"At the end of the day, there are always going to be mental disorders and people who cause violence for no other reason than the fact that they're fucked up and lost. And all we can do is try to learn from it." Corey Taylor.
naven is offline
Ex1ne
Senior Member
Join Date: Oct 2011
Location: Norway
Old 01-12-2013 , 06:02   Re: Getting spec info
Reply With Quote #3

I looked at that and it really didn't tell me anything
__________________
Ex1ne is offline
naven
Veteran Member
Join Date: Jun 2008
Location: Poland, Cieszyn
Old 01-12-2013 , 08:54   Re: Getting spec info
Reply With Quote #4

Ah, perhaps this one: http://forums.alliedmods.net/showthread.php?p=408500
It's easier to see id's in here.
__________________
naven.com.pl
"At the end of the day, there are always going to be mental disorders and people who cause violence for no other reason than the fact that they're fucked up and lost. And all we can do is try to learn from it." Corey Taylor.
naven is offline
Ex1ne
Senior Member
Join Date: Oct 2011
Location: Norway
Old 01-12-2013 , 09:36   Re: Getting spec info
Reply With Quote #5

I tried recreating it tho I really didn't understand the code, and it isn't working. Whats wrong?

PHP Code:
public c_Ghost_spec()
{
    new 
bool:sendname[32], iPlayers[32], iNum;
    
get_players(iPlayersiNum);
    for(new 
alive;alive iNum;alive++)
    {
        new 
bool:sendto[33];
        
send false;
        
        if(!
is_user_alive(iPlayers[alive]))
        {
            continue;
        }
        
sendto[iPlayers[alive]] = true;
        
get_user_name(iPlayers[alive], namesizeof(name) -1);
        for(new 
dead;dead iNum;dead++)
        {
            if(
is_user_connected(iPlayers[dead]))
            {
                if(
is_user_alive(iPlayers[dead]))
                {
                    continue;
                }
                if(
pev(iPlayers[dead], pev_iuser2) == iPlayers[alive])
                {
                    
send true;
                    
sendto[iPlayers[dead]] = true;
                }
            }
        }
        if(
send)
        {
            for(new 
i;iNum;i++)
            {
                if(
sendto[iPlayers[i]])
                {
                    
set_hudmessage(0000.100.3006.01.1);
                    
show_hudmessage(iPlayers[i], "%s^nIs in Ghost-Mode^nTo go Ghost-Mode^nType /ghost"name);
                }
            }
        }
    }
    return 
PLUGIN_CONTINUE;

__________________
Ex1ne is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 01-12-2013 , 11:12   Re: Getting spec info
Reply With Quote #6

Normaly

PHP Code:
if(!is_user_alive(id))
{
new 
intTarget pev(idpev_iuser2)
if(
is_user_alive(intTarget))
{
// Spectating intTarget
}

__________________
Retired.
Xalus is offline
Ex1ne
Senior Member
Join Date: Oct 2011
Location: Norway
Old 01-12-2013 , 23:08   Re: Getting spec info
Reply With Quote #7

I tried Xalus's method, which didn't work. Have I done something wrong?
PHP Code:
*Death*
set_task(1.0"c_Ghost_spec"read_data(2) + TASK_SHOW_HUD,_,_"b");

*
Spawn*
if(
task_exists(TASK_SHOW_HUD))
    
remove_task(TASK_SHOW_HUD);

public 
c_Ghost_spec(id)
{
    
id -= TASK_SHOW_HUD;
    if(!
is_user_alive(id))
    {
        new 
intTarget pev(idpev_iuser2);
        if(
is_user_alive(intTarget) && g_Ghost[intTarget])
        {
            new 
name[32];
            
get_user_name(intTargetnamesizeof(name) -1);
            
set_hudmessage(0000.100.3006.01.1);
            
show_hudmessage(id"%s^nIs in Ghost-Mode^nTo go Ghost-Mode^nType /ghost"name);
        }
    } 
            

__________________
Ex1ne is offline
pokemonmaster
princess milk
Join Date: Nov 2010
Location: Somewhere in this world
Old 01-13-2013 , 15:46   Re: Getting spec info
Reply With Quote #8

Not sure if this is what you were thinking of doing, perhaps, its correct
Code:
show_hudmessage(id, "%s^nIs in Ghost-Mode^nTo go Ghost-Mode^nType /ghost", name); 
// Shouldn't this be
intTarget so it prints to the player who is spectating?
__________________
اَشْهَدُ اَنْ لَّآ اِلٰهَ اِلَّا اللہُ وَحْدَه لَا شَرِيْكَ لَه وَ اَشْهَدُ اَنَّ مُحَمَّدًا عَبْدُه وَرَسُوْلُه
No longer active in AMXX. Sorry.
pokemonmaster is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 01-13-2013 , 16:04   Re: Getting spec info
Reply With Quote #9

Nope,

Id = dead player, intTarget is the alive guy that ID is spectation.
__________________
Retired.
Xalus is offline
Ex1ne
Senior Member
Join Date: Oct 2011
Location: Norway
Old 01-14-2013 , 05:29   Re: Getting spec info
Reply With Quote #10

Quote:
Originally Posted by Xalus View Post
Nope,

Id = dead player, intTarget is the alive guy that ID is spectation.
Which means I did it correct? But it ain't working..
__________________
Ex1ne 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 13:40.


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