AlliedModders

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

ƒa†es™ 06-26-2009 11:41

Show Info
 
Does anyone know what happen to my Show_Info it doesn't show :

PHP Code:

client_print(idprint_chat"[AMX] Say '/menu' to display AMX Menu."

Every 20 second.

PHP Code:

#include <amxmodx>
 
#define ADMIN_LEVEL ADMIN_KICK

new bool:Admin[33]
 
public 
plugin_init() 
{
 
register_plugin("Sub-Menu","1.0","ƒa†es™")
}
 
public 
client_putinserver(id)
{
        
Admin[id] = bool:(get_user_flags(id) & ADMIN_LEVEL)
        
set_task(20.0"show_info"id)
}
 
public 
show_info(id)
{
 if( 
is_user_connected(id) && Admin[id])
      return 
PLUGIN_CONTINUE

 client_print
(idprint_chat"[AMX] Say '/menu' to display AMX Menu.")
      return 
PLUGIN_CONTINUE



stupok 06-26-2009 11:45

Re: Show Info
 
Quote:

Originally Posted by ƒa†es™ (Post 857666)
Code:
#include <amxmodx>   #define ADMIN_LEVEL ADMIN_KICK new bool:Admin[33]   public plugin_init() {  register_plugin("Sub-Menu","1.0","ƒa†es™") }   public client_putinserver(id) {         Admin[id] = bool:(get_user_flags(id) & ADMIN_LEVEL)         set_task(20.0, "show_info", id) }   public show_info(id) {  if( is_user_connected(id) && Admin[id])       return PLUGIN_CONTINUE  client_print(id, print_chat, "[AMX] Say '/menu' to display AMX Menu.")       return PLUGIN_CONTINUE }


zacky 06-26-2009 12:01

Re: Show Info
 
Try this:
PHP Code:

#include <amxmodx>
 
#define ADMIN_LEVEL ADMIN_KICK
 
public plugin_init() 
{
    
register_plugin("Sub-Menu","1.0","ƒa†es™")
}
 
public 
client_putinserver(id)
{
    
set_task(20.0"show_info"id)
}
 
public 
show_info(id)
    if (
is_user_connected(id) && get_user_flags(id) & ADMIN_LEVEL)
        
client_print(idprint_chat"[AMX] Say '/menu' to display AMX Menu."


ƒa†es™ 06-26-2009 12:10

Re: Show Info
 
Quote:

Originally Posted by zacky (Post 857689)
Try this:
PHP Code:

#include <amxmodx>
 
#define ADMIN_LEVEL ADMIN_KICK
 
public plugin_init() 
{
    
register_plugin("Sub-Menu","1.0","ƒa†es™")
}
 
public 
client_putinserver(id)
{
    
set_task(20.0"show_info"id)
}
 
public 
show_info(id)
    if (
is_user_connected(id) && get_user_flags(id) & ADMIN_LEVEL)
        
client_print(idprint_chat"[AMX] Say '/menu' to display AMX Menu."



can't it be this way :

PHP Code:

&& get_user_flags(id) && ADMIN_LEVEL

Rather then :

PHP Code:

&& get_user_flags(id) & ADMIN_LEVEL


zacky 06-26-2009 12:16

Re: Show Info
 
No it can't.

stupok 06-26-2009 12:17

Re: Show Info
 
&& is a boolean operator, page 109 in the pawn manual
& is a bitwise operator, page 107 in the pawn manual

They are not the same, so they are not interchangeable.

ƒa†es™ 06-26-2009 15:04

Re: Show Info
 
Quote:

Originally Posted by zacky (Post 857689)
Try this:
PHP Code:

#include <amxmodx>
 
#define ADMIN_LEVEL ADMIN_KICK
 
public plugin_init() 
{
    
register_plugin("Sub-Menu","1.0","ƒa†es™")
}
 
public 
client_putinserver(id)
{
    
set_task(20.0"show_info"id)
}
 
public 
show_info(id)
    if (
is_user_connected(id) && get_user_flags(id) & ADMIN_LEVEL)
        
client_print(idprint_chat"[AMX] Say '/menu' to display AMX Menu."


This mean :

PHP Code:

if (is_user_connected(id) && get_user_flags(id) & ADMIN_LEVEL

Admin is connected ?

Or

user is connected and get user flags and admin level ?

I want to show the client_print to everyone every 20 second.

zacky 06-26-2009 15:06

Re: Show Info
 
Then just change this:
PHP Code:

set_task(20.0"show_info"id

to this:
PHP Code:

set_task(20.0"show_info"id__"b"


Hunter-Digital 06-26-2009 22:37

Re: Show Info
 
Quote:

Originally Posted by ƒa†es™ (Post 857836)
This mean :
PHP Code:

if (is_user_connected(id) && get_user_flags(id) & ADMIN_LEVEL

Admin is connected ?
Or
user is connected and get user flags and admin level ?

That means that the user is connected AND the user has ADMIN_LEVEL access

also, in your first post, you're checking if the admin is connected and the variable admin on ID... if that's true, then return (finish the function...) so it can't possibly work if you are checking if the user is connected and if he is you're just closing the function with a return :lol:


for the 20 seconds to everyone thing... it's NOT a good think to add a task every time a user connects ... image what would happen after 1000 connects...

this is a better way (not the best though)
PHP Code:

#include <amxmodx>
 
#define TIME_DELAY 20.0
#define ACCESS ADMIN_KICK
#define TEXT_SAY "[AMX] Say '/menu' to display AMX Menu."
 
new g_iMaxPlayers
 
public plugin_init() 
{
    
register_plugin("Inform admins about /menu""0.1""-")
 
    
set_task(TIME_DELAY"inform"___"b")
 
    
g_iMaxPlayers get_maxplayers()
}
 
public 
inform()
{
    for(new 
id 1id <= g_iMaxPlayersid++)
    {
        if(
is_user_connected(id) && get_user_flags(id) & ACCESS)
            
client_print(idprint_chatTEXT_SAY)
    }


or if you want all players to see that... it's much more simple:
PHP Code:

#include <amxmodx>
 
#define TIME_DELAY 20.0
#define TEXT_SAY "[AMX] Say '/menu' to display AMX Menu."
 
public plugin_init() 
{
    
register_plugin("Inform about /menu""0.1""-")
 
    
set_task(TIME_DELAY"inform"0__"b")
}
 
public 
inform()
    
client_print(0print_chatTEXT_SAY

(non-tested codes... I hope I didn't got rusty :lol: )

ƒa†es™ 06-27-2009 04:32

Re: Show Info
 
Quote:

Originally Posted by Hunter-Digital (Post 858144)
That means that the user is connected AND the user has ADMIN_LEVEL access

also, in your first post, you're checking if the admin is connected and the variable admin on ID... if that's true, then return (finish the function...) so it can't possibly work if you are checking if the user is connected and if he is you're just closing the function with a return :lol:


for the 20 seconds to everyone thing... it's NOT a good think to add a task every time a user connects ... image what would happen after 1000 connects...

this is a better way (not the best though)
PHP Code:

#include <amxmodx>
 
#define TIME_DELAY 20.0
#define ACCESS ADMIN_KICK
#define TEXT_SAY "[AMX] Say '/menu' to display AMX Menu."
 
new g_iMaxPlayers
 
public plugin_init() 
{
    
register_plugin("Inform admins about /menu""0.1""-")
 
    
set_task(TIME_DELAY"inform"___"b")
 
    
g_iMaxPlayers get_maxplayers()
}
 
public 
inform()
{
    for(new 
id 1id <= g_iMaxPlayersid++)
    {
        if(
is_user_connected(id) && get_user_flags(id) & ACCESS)
            
client_print(idprint_chatSAY_TEXT)
    }


or if you want all players to see that... it's much more simple:
PHP Code:

#include <amxmodx>
 
#define TIME_DELAY 20.0
#define TEXT_SAY "[AMX] Say '/menu' to display AMX Menu."
 
public plugin_init() 
{
    
register_plugin("Inform about /menu""0.1""-")
 
    
set_task(TIME_DELAY"inform"0__"b")
}
 
public 
inform()
    
client_print(0print_chatSAY_TEXT

(non-tested codes... I hope I didn't got rusty :lol: )

There a mistake i think ?

PHP Code:

client_print(0print_chatSAY_TEXT

It should be :

PHP Code:

client_print(0print_chatTEXT_SAY 

?


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

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