Raised This Month: $ Target: $400
 0% 

[TF2]How to do text in the chat


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
onv
Senior Member
Join Date: Feb 2011
Old 04-18-2011 , 04:22   [TF2]How to do text in the chat
Reply With Quote #1

Hi

I see on few servers , in the chat like each 3 min , a "recall" text appears in the chat with different colors .

And i really want to do it for my server.(I dont have Mani admin plugin , only SM)
And i am wondering if i can write the text myself.

Thanks.
onv is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 04-18-2011 , 04:30   Re: [TF2]How to do text in the chat
Reply With Quote #2

http://wiki.alliedmods.net/Category:SourceMod_Scripting

Create a timer with the flag TIMER_REPEAT and use the PrintToChatAll function.
__________________
Silvers is offline
onv
Senior Member
Join Date: Feb 2011
Old 04-18-2011 , 08:06   Re: [TF2]How to do text in the chat
Reply With Quote #3

Sorry , i dont really understand .

I am a Beginer , there is a command to do this ?

If no , where do i put the code TIMER_REPEAT ?

Code:
DoMessage() { 	CreateTimer(3.0, PrintMsg, _, TIMER_REPEAT) }   public Action:PrintMsg(Handle:timer) { 	static NumPrinted = 0 	if (NumPrinted++ >= 5) 	{ 		PrintToServer("Warning! This is a message.") 		NumPrinted = 0   		return Plugin_Stop 	}   	return Plugin_Continue }
Thanks

Last edited by onv; 04-18-2011 at 08:11.
onv is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 04-18-2011 , 08:20   Re: [TF2]How to do text in the chat
Reply With Quote #4

Yeah thats it.

Using round_start event from a few posts below (http://forums.alliedmods.net/showthread.php?t=155108) is where I would create the timer. Note: the interval is in seconds, so 3 minutes would be 180.0 but for testing purposes it's set to 10.0.

I added a couple color codes into the chat prints. \x0 is a color code followed by 1-6 but not all work. Use the colors include if you want to use team colors for example: http://forums.alliedmods.net/showthread.php?t=96831


PHP Code:
public OnPluginStart()
{
    
HookEvent("round_start"MyCallBackName_roundstart);
}

public 
MyCallBackName_roundstart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
CreateTimer(10.0PrintMsg_TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE)
}

public 
Action:PrintMsg(Handle:timer
{
    static 
NumPrinted 0
    
if (NumPrinted++ >= 5)
    {
        
PrintToChatAll("\x03Warning! This is a message.")
        
NumPrinted 0
        
return Plugin_Stop
    
}

    
PrintToChatAll("\x05Message count = %d"NumPrinted);
    return 
Plugin_Continue


EDIT: I'm not sure if TIMER_FLAG_NO_MAPCHANGE will destroy the timer when the round ends but doesn't change the map.
__________________

Last edited by Silvers; 04-18-2011 at 08:25.
Silvers is offline
onv
Senior Member
Join Date: Feb 2011
Old 04-18-2011 , 09:04   Re: [TF2]How to do text in the chat
Reply With Quote #5

Ok , i think i understand , but , where do i put the PHP ?

So , i just have to copy/paste this to a .smx and open/edit it with pawno ?

I can rename the .smx by what i want or a thing exaclty ?

Another question (sorry ) :
Can you say me the code of all colors ?
ex: x01 = ?


Thanks for your help .
onv is offline
onv
Senior Member
Join Date: Feb 2011
Old 04-18-2011 , 12:19   Re: [TF2]How to do text in the chat
Reply With Quote #6

Anyone ?
onv is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 04-18-2011 , 13:09   Re: [TF2]How to do text in the chat
Reply With Quote #7

The language is Sourcepawn not PHP... I put the code in PHP tags so it would be displayed with color highlighting.

You can copy and paste into here to compile: http://www.sourcemod.net/compiler.php or save it as a .sp in your sourcemod/scripting folder and run the compiler.exe.

Color codes.. google.
__________________
Silvers is offline
Monkeys
Veteran Member
Join Date: Jan 2010
Old 04-18-2011 , 14:21   Re: [TF2]How to do text in the chat
Reply With Quote #8

If a map has several rounds, this'll create multiple timers.

No need for an event hook, simply put it in OnMapStart.

If you want colors in your chat, I suggest you use the Colors include with CPrintToChatAll, like Silvers said.
__________________
Get a lid on that zombie,
he's never gonna be alri-i-ight.
Oooh get a lid on that zombie,
or he's gonna feed all night.
Monkeys is offline
onv
Senior Member
Join Date: Feb 2011
Old 04-18-2011 , 16:09   Re: [TF2]How to do text in the chat
Reply With Quote #9

Today , 13:09 Re: [TF2]How to do text in the chat
#7 The language is Sourcepawn not PHP... I put the code in PHP tags so it would be displayed with color highlighting.

You can copy and paste into here to compile: http://www.sourcemod.net/compiler.php or save it as a .sp in your sourcemod/scripting folder and run the compiler.exe.

Color codes.. google.

--------------------------------------------------------------------------------------------------

OK thanks , so , i put the script in the large espace ?

For the name of the .sp , want should i put ?

Thanks for all your help

EDIT : It is normal when i put the code in the large espace , and compile , it's give me a .smx file ?

Last edited by onv; 04-18-2011 at 16:12.
onv is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 04-18-2011 , 16:16   Re: [TF2]How to do text in the chat
Reply With Quote #10

Quote:
Originally Posted by onv View Post
OK thanks , so , i put the script in the large espace ?

For the name of the .sp , want should i put ?

Thanks for all your help

EDIT : It is normal when i put the code in the large espace , and compile , it's give me a .smx file ?

yes, anything, ok, yes smx. SMX goes in your plugins folder.
__________________
Silvers 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 11:50.


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