AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help edit ad_manager.amxx (make advertise only for dead and spec) (https://forums.alliedmods.net/showthread.php?t=162303)

Mofforg 07-17-2011 10:22

Help edit ad_manager.amxx (make advertise only for dead and spec)
 
Hello all.


I want to make ad_manager show advertise only for dead and spectators.

I did this thing, but i fail and chat is disabled for players, who dead. What`s my mistake?

PHP Code:

public displayAd(params[])


Code:

        if(!is_user_alive(id))
        return PLUGIN_HANDLED;

PHP Code:

    //Get the string that is going to be displayed
    
new message[128];
    
getString(STOREparams[1], message127params[0], params[1]);
    
    
//If its enabled by cvar and id is set, display to person who triggered message only
    
if(get_cvar_num("ad_react_all") == && params[2] != 0)
    {
        
message_begin(MSG_ONEgmsgSayText, {0,0,0}, params[2]);
        
write_byte(params[2]);
        
write_string(message);
        
message_end();
    
    } else
    {
        
//Display the message to everyone
        
new plist[32], playernumplayer;
        
        
get_players(plistplayernum"c");
    
        for(new 
0playernumi++)
        {
            
player plist[i];
            
            
message_begin(MSG_ONEgmsgSayText, {0,0,0}, player);
            
write_byte(player);
            
write_string(message);
            
message_end();
        }
    }
    
    return 
PLUGIN_HANDLED;



Thanks in advance.

hornet 07-17-2011 10:33

Re: Help edit ad_manager.amxx (make advertise only for dead and spec)
 
If I'm understanding you correctly, I'd remove your current alive check code, and change this:
PHP Code:

//Display the message to everyone
new plist[32], playernumplayer;
        
get_players(plistplayernum"c");
    
for(new 
0playernumi++)
{
    
player plist[i];
            
    
message_begin(MSG_ONEgmsgSayText, {0,0,0}, player);
    
write_byte(player);
    
write_string(message);
    
message_end();


to --->

PHP Code:

//Display the message to everyone
new plist[32], playernumplayer;
        
get_players(plistplayernum"c");
    
for(new 
0playernumi++)
{
    
player plist[i];
            
    if( 
is_user_aliveplayer ) || get_user_teamplayer ) != CS_TEAM_SPECTATOR )
        continue;
        
    
message_begin(MSG_ONEgmsgSayText, {0,0,0}, player);
    
write_byte(player);
    
write_string(message);
    
message_end();


Try that.

Mofforg 07-17-2011 10:37

Re: Help edit ad_manager.amxx (make advertise only for dead and spec)
 
* testing *

Mofforg 07-17-2011 10:40

Re: Help edit ad_manager.amxx (make advertise only for dead and spec)
 
PHP Code:

ad_manager.sma(278) : error 017undefined symbol "id" 

PHP Code:

278:  if( is_user_aliveid ) || get_user_teamid ) != CS_TEAM_SPECTATOR 


fysiks 07-17-2011 14:30

Re: Help edit ad_manager.amxx (make advertise only for dead and spec)
 
Quote:

Originally Posted by Mofforg (Post 1512483)
PHP Code:

ad_manager.sma(278) : error 017undefined symbol "id" 

PHP Code:

278:  if( is_user_aliveid ) || get_user_teamid ) != CS_TEAM_SPECTATOR 


"id" is undefined. Use the code posted by hornet.

Mofforg 07-17-2011 21:14

Re: Help edit ad_manager.amxx (make advertise only for dead and spec)
 
Quote:

Originally Posted by fysiks (Post 1512603)
"id" is undefined. Use the code posted by hornet.

I do!

With his code, ID is undefined.

Quote:

public displayAd(params[])
Here`s no ID.

fysiks 07-17-2011 21:19

Re: Help edit ad_manager.amxx (make advertise only for dead and spec)
 
Quote:

Originally Posted by Mofforg (Post 1512751)
I do!

No you don't. His code is copy/paste-able.

Mofforg 07-17-2011 21:31

Re: Help edit ad_manager.amxx (make advertise only for dead and spec)
 
Quote:

Originally Posted by fysiks (Post 1512754)
No you don't. His code is copy/paste-able.

I dont understand you.

It`s my current part of code, i use.

PHP Code:

public displayAd(params[])
{
    
//Get the string that is going to be displayed
    
new message[128];
    
getString(STOREparams[1], message127params[0], params[1]);
    
    
//If its enabled by cvar and id is set, display to person who triggered message only
    
if(get_cvar_num("ad_react_all") == && params[2] != 0)
    {
        
message_begin(MSG_ONEgmsgSayText, {0,0,0}, params[2]);
        
write_byte(params[2]);
        
write_string(message);
        
message_end();
    
    } else
    {
    
//Display the message to everyone
    
new plist[32], playernumplayer;
        
    
get_players(plistplayernum"c");
    
    for(new 
0playernumi++)
    {
    
player plist[i];
            
    if( 
is_user_aliveid ) || get_user_teamid ) != CS_TEAM_SPECTATOR )
        continue;
        
    
message_begin(MSG_ONEgmsgSayText, {0,0,0}, player);
    
write_byte(player);
    
write_string(message);
    
message_end();
    }  
    }
    
    return 
PLUGIN_HANDLED;



fysiks 07-17-2011 23:31

Re: Help edit ad_manager.amxx (make advertise only for dead and spec)
 
who told you to use "id"????? Nobody. Use his code as is.

gamer99 07-18-2011 00:31

Re: Help edit ad_manager.amxx (make advertise only for dead and spec)
 
Mofforg if you are not sure what your doing whats the harm in listening to experienced coder like fysiks and hornet .Do not think that ID is there by default in any fucntion .


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

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