AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem (https://forums.alliedmods.net/showthread.php?t=134311)

Vechta 08-03-2010 06:37

Problem
 
hey why i cant use commands like /bank or /zpstats with this code?

If i do mistake or forgot something please corrent it :oops:

plugins_init()
Code:

register_clcmd("say", "hook_say")
hook_say
Code:

public hook_say(id)
{
        // Process what he is speaking
        new chat[192]
        read_args(chat, 191)
        remove_quotes(chat)
       
        // Get his name
        new name[32]
        get_user_name(id, name, 31)

        // If he has written nothing then return
        if(equal(chat, ""))
                return PLUGIN_HANDLED
       
        // Check if he is alive
        if (is_user_alive(id))
        {
                if (!zp_get_user_zombie(id))
                {
                        // He is a Human
                        if (get_user_flags(id) && VIPACCES)
                        {
                                ColorChat(0, GREEN, "[VIP] ^x03%s^x01: ^x04%s", name, chat);
                        }
                }
               
                if (zp_get_user_zombie(id))
                {
                        // He is a Human
                        if (get_user_flags(id) && VIPACCES)
                        {
                                ColorChat(0, RED, "[VIP] ^x03%s^x01: ^x04%s", name, chat);
                        }
                }       
        }
        else
        {
                if (!zp_get_user_zombie(id))
                {
                        // He is a Human
                        if (get_user_flags(id) && VIPACCES)
                        {
                                ColorChat(0, GREY, "[VIP] ^x01%s^x01: ^x04%s", name, chat);
                        }
                }
               
                if (zp_get_user_zombie(id))
                {
                        // He is a Human
                        if (get_user_flags(id) && VIPACCES)
                        {
                                ColorChat(0, GREY, "[VIP] ^x01%s^x01: ^x04%s", name, chat);
                        }
                }
        }
        return PLUGIN_HANDLED
}


DarkGod 08-03-2010 07:06

Re: Problem
 
return PLUGIN_HANDLED_MAIN (second case)?

It's also if(get_user_flags(id) & VIPACCESS), not &&.

Vechta 08-03-2010 07:19

Re: Problem
 
Quote:

Originally Posted by DarkGod (Post 1260225)
return PLUGIN_HANDLED_MAIN (second case)?

It's also if(get_user_flags(id) & VIPACCESS), not &&.

fixed, but i do not think that its the bug :S

I can use commands like /rank fine but new plugins like /bank dont work

Vechta 08-03-2010 10:26

Re: Problem
 
So anyone can help me?

abdul-rehman 08-03-2010 14:40

Re: Problem
 
Try this maybe it will work:
Code:
public hook_say(id) {     // Process what he is speaking     new chat[192]     read_args(chat, 191)     remove_quotes(chat)         // Get his name     new name[32]     get_user_name(id, name, 31)     // If he has written nothing then return     if(equal(chat, ""))         return PLUGIN_CONTINUE         // Check if he is alive     if (is_user_alive(id))     {         if (!zp_get_user_zombie(id))         {             // He is a Human             if (get_user_flags(id) && VIPACCES)             {                 ColorChat(0, GREEN, "[VIP] ^x03%s^x01: ^x04%s", name, chat);             }         }                 if (zp_get_user_zombie(id))         {             // He is a Human             if (get_user_flags(id) && VIPACCES)             {                 ColorChat(0, RED, "[VIP] ^x03%s^x01: ^x04%s", name, chat);             }         }       }     else     {         // He is a Human         if (get_user_flags(id) && VIPACCES)         {             ColorChat(0, GREY, "[VIP] ^x01%s^x01: ^x04%s", name, chat);         }     }     return PLUGIN_CONTINUE }

Vechta 08-03-2010 14:44

Re: Problem
 
Quote:

Originally Posted by abdul-rehman (Post 1260573)
Try this maybe it will work:
Code:
public hook_say(id) {     // Process what he is speaking     new chat[192]     read_args(chat, 191)     remove_quotes(chat)         // Get his name     new name[32]     get_user_name(id, name, 31)     // If he has written nothing then return     if(equal(chat, ""))         return PLUGIN_CONTINUE         // Check if he is alive     if (is_user_alive(id))     {         if (!zp_get_user_zombie(id))         {             // He is a Human             if (get_user_flags(id) && VIPACCES)             {                 ColorChat(0, GREEN, "[VIP] ^x03%s^x01: ^x04%s", name, chat);             }         }                 if (zp_get_user_zombie(id))         {             // He is a Human             if (get_user_flags(id) && VIPACCES)             {                 ColorChat(0, RED, "[VIP] ^x03%s^x01: ^x04%s", name, chat);             }         }       }     else     {         // He is a Human         if (get_user_flags(id) && VIPACCES)         {             ColorChat(0, GREY, "[VIP] ^x01%s^x01: ^x04%s", name, chat);         }     }     return PLUGIN_CONTINUE }

Thanks, i'll test... (What did you changed xD)

PS: I looked at your Human chat code :D

Devil259 08-03-2010 15:17

Re: Problem
 
if (get_user_flags(id) && VIPACCES) should be if (get_user_flags(id) & VIPACCES) .

Vechta 08-04-2010 09:30

Re: Problem
 
Quote:

Originally Posted by Devil259 (Post 1260613)
if (get_user_flags(id) && VIPACCES) should be if (get_user_flags(id) & VIPACCES) .

I know that, but it dont help my bug :S

aaarnas 08-04-2010 10:08

Re: Problem
 
The most simple way of chat messages is this:
PHP Code:

public plugin_init() {
    
register_plugin("say /bank""call_function")
}

public 
call_function(id) {
        
    
// This will be called when you put in to the chat command /bank.


In previous scripts you haven't checked if player typed correct message. If you hooking say command, function will be called always, when everyone types something into chat.

Vechta 08-04-2010 10:14

Re: Problem
 
Quote:

Originally Posted by aaarnas (Post 1261444)
The most simple way of chat messages is this:
PHP Code:

public plugin_init() {
    
register_plugin("say /bank""call_function")
}

public 
call_function(id) {
        
    
// This will be called when you put in to the chat command /bank.


In previous scripts you haven't checked if player typed correct message. If you hooking say command, function will be called always, when everyone types something into chat.

I do not understand what you mean with the first code :S

The bank is a other sub plugin not included in the chat plugin :S


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

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