AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   First plugin ever! (https://forums.alliedmods.net/showthread.php?t=97860)

realchamp 07-20-2009 15:00

First plugin ever!
 
Hello!

Well this is my first plugin ever. So I need some informations here, which I didn't find on the wiki.

1. How can I make the plugin print something in the MAIN console? (actual srcds.exe console)

2. How can I make it say something ingame?
as "omg it is working", without the "console:" infront of it?


- realchamp, any help is appreciated.

almcaeobtac 07-20-2009 15:45

Re: First plugin ever!
 
//to say to the server

PrintToServer(String:Message[], any formatting...);

//to say to someone's chat

PrintToChat(Client, String:Message[], any formatting...);

exvel 07-20-2009 16:08

Re: First plugin ever!
 
Another solution :)
PHP Code:

ServerCommand("say some_text"); 


bl4nk 07-20-2009 16:25

Re: First plugin ever!
 
@exvel: That would still put "Console: " in front of the text.

exvel 07-20-2009 16:38

Re: First plugin ever!
 
oh, right, I've just missed it

realchamp 07-20-2009 17:32

Re: First plugin ever!
 
Quote:

Originally Posted by almcaeobtac (Post 877240)
//to say to the server

PrintToServer(String:Message[], any formatting...);

//to say to someone's chat

PrintToChat(Client, String:Message[], any formatting...);

What does the "Any formatting" mean?

And "client", do I have to a name there or just leave it?

And when I run this:
Code:

#include <sourcemod>
 
public Plugin:myinfo =
{
        name = "My First Plugin",
        author = "realchamp.",
        description = "My first plugin ever",
        version = "1.0.0.0",
        url = "http://www.realchamp.dk"
};
 
public OnPluginStart()
{
        PrintToServer(String:Message[], LOADING);
}

I get errors.

exvel 07-20-2009 17:45

Re: First plugin ever!
 
PHP Code:

PrintToServer("LOADING"); 


realchamp 07-20-2009 18:05

Re: First plugin ever!
 
Thank you, it worked.

But how can I be sure the plugin is loaded? Even that I see the "LOADED" in my console.

Isn't there a SourceMod command for this?

And how can I send a message to all players on the server? With this:
Code:

PrintToChat(Client, String:Message[], any formatting...);

almcaeobtac 07-20-2009 18:22

Re: First plugin ever!
 
Woops, sorry for not explaining.

PrintToChat(Client ID, String:Message, Formatting)

Client ID: This is the number of the player it is printing to. I need more information on when this is being run to know how to get it.

String:Message: This is the message in quotes... "hello"

Formatting: This is for additional things, like variables. Leave it blank for now.

So basically, to print to the first player in the server, do...

PrintToChat(1, "hello");

To print to others, first tell me when it's being used.

realchamp 07-20-2009 18:29

Re: First plugin ever!
 
ohh okay. Thanks!

Well let's say that if some one is killed.
you were killed by $playername

Or is it possible to send that command to all players?

As instead of id = 1, what shall I use then to print that message to all people? like on round_start

If round_start:
Server running xxxxxx

and that message must go to all players.


Here I was improvising abit:
Code:

#include <sourcemod>
 
public Plugin:myinfo =
{
        name = "My First Plugin",
        author = "realchamp.",
        description = "My first plugin ever",
        version = "1.0.0.0",
        url = "http://www.realchamp.dk"
};

public OnPluginStart()
{
        PrintToServer("loading...");
}

public PlayerDeath()
{
// Trying to check if the weapon the user were killed with equals to a knife.
        if(string::weapon == weapon_knife) {
            PrintToChat(userid, "Congratulations! You're the new knife master!");
        }
}



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

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