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

Change line after each player


Post New Thread Reply   
 
Thread Tools Display Modes
ecca
Sexy Santa
Join Date: Jan 2011
Old 05-27-2012 , 10:39   Re: Change line after each player
Reply With Quote #11

I have a timer that updates every seconds so i cant use chat because it will overflood
ecca is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 05-27-2012 , 14:13   Re: Change line after each player
Reply With Quote #12

Okay I understand the concept, here you go:

PHP Code:
// Original message
new String:szText[512] = "hello:\n\n";
// Loop throw all players
for(new 1<= MaxClientsi++) 
{
    if(
IsClientInGame(i))
    {
        
GetClientName(iAdminNamessizeof(AdminNames));
        
// Format the admin name + the next line (\n)
        
decl String:szTextAppend[512];
        
Format(szTextAppendsizeof(szTextAppend), "%s\n"AdminNames);
        
// Append szTextAppend to the original message (szText) to get it update
        
StrCat(szTextsizeof(szText), szTextAppend);
        
// Send the message
        
BfWriteByte(hBuffer1);
        
BfWriteString(hBufferszText);
        
EndMessage(); 
    }


Last edited by Mathias.; 05-27-2012 at 14:15. Reason: Indentation of brackets fix
Mathias. is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 05-27-2012 , 14:50   Re: Change line after each player
Reply With Quote #13

A few things I want to point out:

1) Why is AdminNames being used when it's clearly looping through all players?
2) No point using GetClientName when %N (paired with i) works in the Format function.
2) Messages can only go up to 192 characters I think.
4) You have not assigned hBuffer (including other variables), nor even started the usermessage. Why leave scripts incomplete?
5) You have not used the right format for usermessage.
6) Unless he wants team-colored chat, why is this even being used?
7) Why is ecca so woefully laconic when trying to describe what he wants?

One or more of these points may be inaccurate, so apologies for any misunderstandings.
__________________

Last edited by 11530; 05-27-2012 at 14:52.
11530 is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 05-27-2012 , 15:10   Re: Change line after each player
Reply With Quote #14

What's against using a panel like the l4drdyup-plugin does?
Dr. Greg House is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 05-27-2012 , 23:24   Re: Change line after each player
Reply With Quote #15

11530 is right on some points so here the updated code:

PHP Code:
// Original message
new String:szText[192] = "hello:\n\n";
// Loop throw all players
for(new 1<= MaxClientsi++) 
{
    if(
IsClientInGame(i))
    {
        
decl String:szTextAppend[192];
        
Format(szTextAppendsizeof(szTextAppend), "%N\n"i);
        
// Append szTextAppend to the original message (szText) to get it update
        
StrCat(szTextsizeof(szText), szTextAppend);
        
// Send the message
        
BfWriteByte(hBuffer1);
        
BfWriteString(hBufferszText);
        
EndMessage(); 
    }

For the usermessage style, he's probaly writing a keyhintmessage and start it before the loop. That why he is using usermessage style instead of chat, hud, topleft, or center message.

He only show a part of the script because is there where he got a problem with the script and he told us it work, just the part of the format overwrite always the old one instead of appending it to the original message. It is more clean and we do not need the rest of the code to help him out.

Thank you 11530 to point out those facts.

Ecca please give us news about it and if everything is alright.

Last edited by Mathias.; 05-27-2012 at 23:26.
Mathias. is offline
KyleS
SourceMod Plugin Approver
Join Date: Jul 2009
Location: Segmentation Fault.
Old 05-28-2012 , 00:34   Re: Change line after each player
Reply With Quote #16

Could be a bit crazy, but...

PHP Code:
#pragma semicolon 1
#include <sourcemod>

#define ISCLIENTREADY (1<<0)

new g_iClientStates[MAXPLAYERS+1];

public 
OnPluginStart()
{
    
PrintToFun();
}

public 
PrintToFun()
{
    
decl iPlayerArray[MAXPLAYERS+1];
    new 
iNumPlayers;
    
    
decl String:szText[512];
    
strcopy(szTextsizeof(szText), "Waiting for Players");
    
    for (new 
1<= MaxClientsi++)
    {
        if ((
g_iClientStates[i] & ISCLIENTREADY) || !IsClientInGame(i))
        {
            continue;
        }
        
        
Format(szTextsizeof(szText), "%s\n%N"szTexti);
    }
    
    for (new 
1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i))
        {
            continue;
        }
        
        
iPlayerArray[iNumPlayers] = i;
        
iNumPlayers++;
    }
    
    new 
Handle:hBuffer StartMessage("KeyHintText"iPlayerArrayiNumPlayers);
    
BfWriteByte(hBuffer1);
    
BfWriteString(hBufferszText);
    
EndMessage(); 


Last edited by KyleS; 05-28-2012 at 00:37.
KyleS 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