Raised This Month: $ Target: $400
 0% 

Get command name player has typed.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
solidsnake
Member
Join Date: Jul 2006
Old 05-28-2007 , 05:39   Get command name player has typed.
Reply With Quote #1

Hello,
I use this register :

register_cmd("func1","doFunc")
register_cmd("func2","doFunc")

is there a way to display typed command when the code is in the forwarded function doFunc ?

^^
Best regards.

Last edited by solidsnake; 05-28-2007 at 05:42.
solidsnake is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 05-28-2007 , 05:53   Re: Get command name player has typed.
Reply With Quote #2

http://wiki.amxmodx.org/Intro_to_AMX_Mod_X_Scripting

Code:
public cmd_hp(id, level, cid) {      if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED        new Arg1[24]      new Arg2[4]        //Get the command arguments from the console      read_argv(1, Arg1, 23)      read_argv(2, Arg2, 3)        //Convert the health from a string to a number      new Health = str_to_num(Arg2)        //Is the first character the @ symbol?      if (Arg1[0] == '@')      {           new Team = 0           //Check which team was specified.           //Note that we start from [1], this is okay           // it just means the @ isn't included           if (equali(Arg1[1], "CT"))           {                Team = 2           } else if (equali(Arg1[1], "T")) {                Team = 1           }           new players[32], num           //This function will fill the players[32] variable           // with valid player ids.  num will contain the number           // of players that are valid.           get_players(players, num)           new i           for (i=0; i<num; i++)           {                if (!Team)                {                     //Set this player's health                     set_user_health(players[i], Health)                } else {                     if (get_user_team(players[i]) == Team)                     {                          set_user_health(players[i], Health)                     }                }           }      } else {           //finds a player id that matches the partial name given           //the 1 means that it will not target the player if he           // has immunity access           new player = cmd_target(id, Arg1, 1)           if (!player)           {                //this will print a message to the user who tried the command                //The format for this command is called "format()" style,                // where the first string formats the message according                // to any number of following parameters.                //  %s means a string                //  %d or %i means an integer                //  %f means a float                // so "Hello %s, I am %d years old" will                //  require a string and integer to follow                console_print(id, "Sorry, player %s could not be found or targetted!", Arg1)                return PLUGIN_HANDLED           } else {                set_user_health(player, Health)           }      }        return PLUGIN_HANDLED }
Lee is offline
solidsnake
Member
Join Date: Jul 2006
Old 05-28-2007 , 06:56   Re: Get command name player has typed.
Reply With Quote #3

Thanks, but i'ts not my request, you give me how to display arguments for a command, i want to catch the called command name that trig doFunc.

Exemple :

Player type func1 in console, calling the doFunc function, the result will be

client_print(id,print_chat,"Player has typed %s function",function_name)

best regards.
solidsnake is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 05-28-2007 , 07:20   Re: Get command name player has typed.
Reply With Quote #4

http://forums.alliedmods.net/showthread.php?t=55657
_Master_ is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 05-28-2007 , 07:27   Re: Get command name player has typed.
Reply With Quote #5

Code:
new command[20] read_argv(0, command, 19)
Arguments start from 1.
Lee is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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