AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Print function to chat (https://forums.alliedmods.net/showthread.php?t=232475)

Estland 12-31-2013 01:40

Print function to chat
 
How to print function to chat with public client_putinserver(id)?

fysiks 12-31-2013 01:51

Re: Print function to chat
 
That question doesn't make sense. You can print to chat with client_print() but if you use it in client_putinserver(), the person that just joined won't be able to see it.

You should explain, in detail, what you are trying to do with your plugin to get better advice.

Estland 12-31-2013 01:56

Re: Print function to chat
 
I want to print information about a guy who just joined (if he/she has flags I'm searching).

fysiks 12-31-2013 02:56

Re: Print function to chat
 
Flags are not given until after client_authorized() is executed. So, to guarantee that flags have been given where needed, you need to use that forward. Then, you need to do a delay with set_task() if you want that person to have a chance to see it.

Estland 12-31-2013 04:49

Re: Print function to chat
 
So something like that?

Code:

public client_putinserver(id)
{
    set_task(2.0, "Function")
}

public Function(id)

    if(is_user_connected(id)) {
        new Name[33]
        get_user_name(id,Name,32);
     
        if(get_user_flags(id) & ADMIN_LEVEL_E) {
            ColorChat(0, NORMAL, "Master^4 %s^1 joined the server!", Name);
            return PLUGIN_HANDLED;
        }


Black Rose 12-31-2013 07:13

Re: Print function to chat
 
authorized can be called after putinserver, so use that function like fysiks said.

Or combine them. Use a variable to enable the message when authorized was called and when the putinserver is called, show the message. If they are out of sync you can create a task on putinserver to repeat until authorized has cleared.

Something like:
Code:
new is_authorized[33]; public client_authorized(id) {     is_authorized[id] = true; } public client_disconnect(id) {     is_authorized[id] = false; } public client_putinserver(id) {     set_task(2.0, "Function") } public Function(id) {     if(is_authorized[id] & is_user_connected(id)) {         new Name[33]         get_user_name(id,Name,32);                 if(get_user_flags(id) & ADMIN_LEVEL_E)             ColorChat(0, NORMAL, "Master^4 %s^1 joined the server!", Name);     }     else         set_task(1.0, "Function") }

Estland 12-31-2013 08:04

Re: Print function to chat
 
Function should return a value. Still gives me that error.

Black Rose 12-31-2013 08:34

Re: Print function to chat
 
Quote:

Originally Posted by Estland (Post 2078963)
Function should return a value. Still gives me that error.

Sorry, fixed.

Estland 01-01-2014 12:29

Re: Print function to chat
 
Hmm, still isn't working. No errors, though.

Code:

public client_authorized(id)
{
    is_authorized[id] = true;
}

public client_disconnect(id)
{
    is_authorized[id] = false;
}

public client_putinserver(id)
{
    set_task(2.0, "Tervitus")
}

public Tervitus(id)
{
    if(is_authorized[id] & is_user_connected(id)) {
        new Name[33]
        get_user_name(id,Name,32);
       
        if(get_user_flags(id) & OMANIK) {
            ColorChat(0, NORMAL, "Omanik^4 %s^1 liitus serveriga!", Name);
            return PLUGIN_HANDLED;
        }
        if(get_user_flags(id) & KORRAHOIDJA) {
            ColorChat(0, NORMAL, "Korrahoidja^4 %s^1 liitus serveriga!", Name);
            return PLUGIN_HANDLED;
        }
        if(get_user_flags(id) & IMM_ACCESS) {
            ColorChat(0, NORMAL, "Immunity Admin^4 %s^1 liitus serveriga!", Name);
            return PLUGIN_HANDLED;
        }
        if(get_user_flags(id) & ADMIN_ACCESS) {
            ColorChat(0, NORMAL, "Admin^4 %s^1 liitus serveriga!", Name);
            return PLUGIN_HANDLED;
        }
        if(get_user_flags(id) & VIP_ACCESS) {
            ColorChat(0, NORMAL, "VIP^4 %s^1 liitus serveriga!", Name);
            return PLUGIN_HANDLED;
    }
        else
        set_task(1.0, "Tervitus")
    }

I've got things like ADMIN_ACCESS defined. new is_authorized[33]; is added, too.

fysiks 01-01-2014 16:40

Re: Print function to chat
 
This is all pointless, just put the code in client_authorized(). It will do exactly the same thing.


All times are GMT -4. The time now is 10:04.

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