AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   PrintToChatAll help (https://forums.alliedmods.net/showthread.php?t=113007)

jasonbourn48 12-22-2009 17:27

PrintToChatAll help
 
A little introduction of myself first. My name is Vu and I'm new to this scripting thing. So I decided to start by editing some other people's codes. I downloaded AtomicStryker's laser plugin for L4D2. I was able to do some editing with it and it worked. It wasn't much. Now, I need to know how to make a chat announcement to all clients in server that they can use it. This is what I got:

stock PrintToChatAll(const String:format[])
{
PrintToChatAll("\x011[SM] You can type !laseron to get laser and !laseroff to turn laser off");
}

When I compiled it, i got the error that says "fatal error 021: symbol already defined: "PrintToChatAll". I wanna know what I did wrong here and I wanna know what "format" goes there. Thanks in advanced for any help.

meng 12-22-2009 17:44

Re: PrintToChatAll help
 
like the error suggests, your creating a function with the same name as an already defined SM native. simply renaming it something unique should fix the error. also, if your just going to use that hard-coded message, there is no need for the String parameter.

PHP Code:

stock PrintMyMessage()
{
    
PrintToChatAll("\x011[SM] You can type !laseron to get laser and !laseroff to turn laser off");


if you wanted a more flexible function, you would include the String parameter.
PHP Code:

stock PrintMyMessage(String:MyString[])
{
    
PrintToChatAll("\x011[SM] %s"MyString);    



Dragonshadow 12-22-2009 17:58

Re: PrintToChatAll help
 
^ what he said.

Secondarily, what color does \x011 come out to be?

jasonbourn48 12-22-2009 19:21

Re: PrintToChatAll help
 
Thanks for the help guys...but how can I get it to show up when some1 joins my server?

jackpf 12-22-2009 20:27

Re: PrintToChatAll help
 
OnClientPutInServer() ?

jasonbourn48 12-22-2009 20:56

Re: PrintToChatAll help
 
explain a bit more, sir?

Dragonshadow 12-22-2009 21:54

Re: PrintToChatAll help
 
Use OnClientPostAdminCheck() instead

pheadxdll 12-22-2009 22:11

Re: PrintToChatAll help
 
Quote:

Originally Posted by jasonbourn48 (Post 1027715)
explain a bit more, sir?

Those are both functions that are ran when a user joins the server. Its easy to use them:

Code:

public OnClientPutInServer(client)
{
    // code here
}
public OnClientPostAdminCheck(client)
{
    // code here
}

It seems like the text you want to print, you want the user to see. So the trick is to use a function that is executed when the user can see the chat area. Between the above two functions, I'd go with OnClientPostAdminCheck.

It might turn out that the functions are ran too early and the player never sees the text. Then you might have to use a timer and wait 30 seconds, then show the message.

jasonbourn48 12-22-2009 22:44

Re: PrintToChatAll help
 
so i put

public OnClientPostAdminCheck(client)
{
PrintToChatAll("\x011[SM] You can type !laseron to get laser and !laseroff to turn laser off");
}

Does that look about right to you guys? Sorry I'm reallllyy reeallly newww

nevermind, it works brilliantly. Thank you guys

FaTony 12-23-2009 06:31

Re: PrintToChatAll help
 
That code will print message to everyone, if you want only 1 player, you should use PrintToChat instead.


All times are GMT -4. The time now is 14:46.

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