AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register_concmd help (DISPLAYING RULES) (https://forums.alliedmods.net/showthread.php?t=105761)

lordshiva 10-08-2009 04:43

register_concmd help (DISPLAYING RULES)
 
i ve made this plugin....but it only works sometimes....but i wanted to work this when i type....whn i type amx_rules or /rules than sometimes it works sometimes dont can u correct it
PHP Code:

#include <amxmodx>
#include <colorchat>

public plugin_init() 

    
register_plugin("RULES","1.0","LORDSHIVA")
    
register_concmd("amx_rules""Rules"ADMIN_SLAY"Shows Rules")
    
register_concmd("say /rules""Rules"ADMIN_SLAY"Shows Rules")
}

public 
Rules(id)
{
     if(
is_user_alive(id))
    {
        new 
name[32];
        
get_user_name(idname31);
        
set_hudmessage(2551000, -1.00.3)
        
show_hudmessage(id"%s^rRead Clan Rules"name);
    
set_task5.0"rule"id );  
    }

public 
rule(id)
{
  
ColorChat(0RED"[KR] KNIFEROUND !!!")
  
ColorChat(0BLUE"[TC] TEAM CHOOSING")
  
ColorChat(0GREY"[PR] PISTOLROUND !!! ")
  
ColorChat(0GREEN"CLAN STARTED RACE TO 15 TEAM WINS")
  
set_task6.0"rule1"id ); 
}

public 
rule1()
{
   
ColorChat(0GREEN"LIVE !!!  LIVE !!!  LIVE !!!")
   
ColorChat(0GREEN"LIVE LIVE LIVE !!! ")
   
ColorChat(0GREEN"LIVE !!!  LIVE !!!  LIVE !!!")
   
ColorChat(0GREEN"LIVE LIVE LIVE !!! ")
   
ColorChat(0GREEN"LIVE !!!  LIVE !!!  LIVE !!!")


:shock:

vitorrd 10-08-2009 07:28

Re: Plugin Help Correction
 
There are two flaws in your code.
For the first matter, whenever using a "say" command, you should use register_clcmd and not register_concmd (else you have to go to the console and type "say /rules" to get it working).
For the second one, whenever you create a task, the third parameter identifies the task with an ID. What you are doing right now is using the player's ID to identify the task, which is nothing but a common mistake. A correct use of set_task follows:

PHP Code:

#define TASK_SHOW_RULES   1234
 
public rule(id)
{
    
ColorChat(0RED"[KR] KNIFEROUND !!!")
    
ColorChat(0BLUE"[TC] TEAM CHOOSING")
    
ColorChat(0GREY"[PR] PISTOLROUND !!! ")
    
ColorChat(0GREEN"CLAN STARTED RACE TO 15 TEAM WINS")
    
set_task6.0"rule1"TASK_SHOW_RULES ); 


For more information, please check:

set_task @ funcwiki: http://www.amxmodx.org/funcwiki.php?go=func&id=253
register_clcmd @ funcwiki: http://www.amxmodx.org/funcwiki.php?go=func&id=259

Hope this helped, any further questions, please don't hesitate.

3Di 10-08-2009 09:31

Re: Plugin Help Correction
 
Edited for stupidity.

xPaw 10-08-2009 09:32

Re: Plugin Help Correction
 
Quote:

Originally Posted by 3Di (Post 955669)
vittord, why are you defining the index as 1234?

For all players: set_task( 6.0, "rule1", 0 );

For one player: set_task( 6.0, "rule1", index );

Thats wrong. its task id, and not players id.

3Di 10-08-2009 09:35

Re: Plugin Help Correction
 
Quote:

Originally Posted by xPaw (Post 955670)
Thats wrong. its task id, and not players id.

Wow, I'm sorry I completely read that wrong and wasn't thinking. Thanks for catching my mistake.

Arkshine 10-08-2009 10:03

Re: Plugin Help Correction
 
It happens often the the player's index is passed as TaskId for simplicity.

lordshiva 10-08-2009 10:31

Quote:

Originally Posted by xPaw (Post 955670)
Thats wrong. its task id, and not players id.

xPaw how to proceed with task id

is this correct
set_task( 5.0, "rule", id );



register_concmd("amx_rules","Rules", ADMIN_SLAY, "Shows Rules")-------THIS IS NOT WORKING :( :( :(
register_clcmd("say /rules","Rules", ADMIN_SLAY, "Shows Rules")-------THIS IS WORKING :) :) :)


EDIT:

When i type rcon amx_rules than nothing is displayed but when in console i type amx_rules than it is displaying

EDIT 2:

i want this in format like

when i type rcon amx_rules than it displays to ALL players...........
public Rules(id)
public rule(id)
public rule1()

and when i alone type /rules...than it displays TO ME ONLY
public Rules(id)
public rule(id)
public rule1()

Exolent[jNr] 10-08-2009 11:24

Re: Plugin Help Correction
 
Don't post again if you have the last post. Instead, edit your last post.

lordshiva 10-08-2009 11:27

Re: Plugin Help Correction
 
yeah will not post again but can u help me in correcting

vitorrd 10-08-2009 12:46

Re: Plugin Help Correction
 
@Arkshine: Leading to this kind of mistakes :P

@lordshiva: You should pass the player's ID to the task and then use the ColorChat prints on that ID (0 shows to everyone).


All times are GMT -4. The time now is 22:37.

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