AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting spec info (https://forums.alliedmods.net/showthread.php?t=205568)

Ex1ne 01-12-2013 03:45

Getting spec info
 
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.

naven 01-12-2013 05:54

Re: Getting spec info
 
use this http://forums.alliedmods.net/showthread.php?p=484967

Ex1ne 01-12-2013 06:02

Re: Getting spec info
 
I looked at that and it really didn't tell me anything

naven 01-12-2013 08:54

Re: Getting spec info
 
Ah, perhaps this one: http://forums.alliedmods.net/showthread.php?p=408500
It's easier to see id's in here.

Ex1ne 01-12-2013 09:36

Re: Getting spec info
 
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;



Xalus 01-12-2013 11:12

Re: Getting spec info
 
Normaly

PHP Code:

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



Ex1ne 01-12-2013 23:08

Re: Getting spec info
 
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);
        }
    } 
            



pokemonmaster 01-13-2013 15:46

Re: Getting spec info
 
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?


Xalus 01-13-2013 16:04

Re: Getting spec info
 
Nope,

Id = dead player, intTarget is the alive guy that ID is spectation.

Ex1ne 01-14-2013 05:29

Re: Getting spec info
 
Quote:

Originally Posted by Xalus (Post 1872997)
Nope,

Id = dead player, intTarget is the alive guy that ID is spectation.

Which means I did it correct? But it ain't working..


All times are GMT -4. The time now is 13:40.

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