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

Quick Question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jsands
Junior Member
Join Date: Mar 2009
Old 03-28-2009 , 22:07   Quick Question
Reply With Quote #1

Not well versed in scripting, but I want to change a PrintToChatAll to only go to the survivors. How would I accomplish this?

PrintToChatAll("%s blah blah blah.", targetName);
jsands is offline
ANTiCHRiST
Member
Join Date: Mar 2009
Location: Vienna, Austria
Old 03-28-2009 , 22:44   Re: Quick Question
Reply With Quote #2

Code:
    new maxClients = GetMaxClients();
    new clients[maxClients];
    new total = 0;
    
    for (new i=1; i<=maxClients; i++)
    {
        if (IsClientInGame(i))
        {
            clients[total++] = i;
        }
    }
    
    if (!total)
    {
        return;
    }

    PrintToChat(clients,"%s blah blah blah.", targetName)
that should u help, a bit. u must modify it a bit
__________________
ANTiCHRiST is offline
Send a message via ICQ to ANTiCHRiST Send a message via MSN to ANTiCHRiST
jsands
Junior Member
Join Date: Mar 2009
Old 03-28-2009 , 22:57   Re: Quick Question
Reply With Quote #3

I think I know well enough to see how that it is close to what I want, but it seems to me, and correct me if I'm wrong, that it will send the message individually to every player.

If I am correct in this assumption, how do I make it send it to only the 4 players on the survivor team (I didn't see anything in there that differentiated between survivor and infected)?
jsands is offline
ANTiCHRiST
Member
Join Date: Mar 2009
Location: Vienna, Austria
Old 03-28-2009 , 22:59   Re: Quick Question
Reply With Quote #4

Quote:
Originally Posted by jsands View Post
I think I know well enough to see how that it is close to what I want, but it seems to me, and correct me if I'm wrong, that it will send the message individually to every player.

If I am correct in this assumption, how do I make it send it to only the 4 players on the survivor team (I didn't see anything in there that differentiated between survivor and infected)?
hmm what for a mod?
__________________
ANTiCHRiST is offline
Send a message via ICQ to ANTiCHRiST Send a message via MSN to ANTiCHRiST
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 03-28-2009 , 23:10   Re: Quick Question
Reply With Quote #5

You will need to get the clients team, and if they are on survivor print to them, if not dont print. Like...

Code:
    #define TEAM_SURVIVOR 2
    #define TEAM_INFECTED 3
    
    for (new i=1; i<=MaxClients; i++)
    {
        if (i != 0 && IsClientInGame(i))
        {
            new team = GetClientTeam(client);

            if(team == TEAM_SURVIVOR)
                PrintToChat(client, "Your a Survivor");
        }
    }
__________________
CrimsonGT is offline
jsands
Junior Member
Join Date: Mar 2009
Old 03-29-2009 , 11:59   Re: Quick Question
Reply With Quote #6

Hmm, still not quite working this out properly. I am trying to modify a suggested plugin I saw that was not complete. I want to send a message to other survivors when one of them is nearly dead, or Black & White, as it was called.
Code:
#pragma semicolon 1
#include <sourcemod>

#define TEAM_SURVIVOR 2
#define TEAM_INFECTED 3

public Plugin:myinfo =
{
    name = "",
    author = "",
    description = "",
    version = "1.0",
    url = ""
};

public OnPluginStart()
{
    HookEvent("revive_success", EventReviveSuccess);
}

public EventReviveSuccess(Handle:event, const String:name[], bool:dontBroadcast)
{
    if (GetEventBool(event, "lastlife"))
    {

        new target = GetClientOfUserId(GetEventInt(event, "subject"));
        decl String:targetName[64];
        GetClientName(target, targetName, sizeof(targetName));
        
        for (new i=1; i<=MaxClients; i++)
        {
            if (i != 0 && IsClientInGame(i))
            {
                new team = GetClientTeam(clients);
                if(team == TEAM_SURVIVOR)
                PrintToChat(clients, "%s is near death.", targetName);
                }        

        }
    
    }
}
I get two errors, undefined symbol (clients).
jsands is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 03-29-2009 , 12:26   Re: Quick Question
Reply With Quote #7

"clients" should be "i"
__________________
CrimsonGT is offline
jsands
Junior Member
Join Date: Mar 2009
Old 03-29-2009 , 13:33   Re: Quick Question
Reply With Quote #8

Thank you all for your assistance. I've done scripting before for other games but Sourcemod is a little too close to something like a C/C++ language for me to really grasp.
jsands 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 08:51.


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