Raised This Month: $ Target: $400
 0% 

Registering cl_cmd


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mankind
Member
Join Date: Jun 2009
Old 06-26-2011 , 19:35   Re: Registering cl_cmd
Reply With Quote #1

Thanks, works fine, but how do can i set the function client_print, so when the ct writes /toss, it shows %s turned on gun toss distance? I think it goes something like this, but im not completly sure :

PHP Code:
{
new 
name[32];
get_user_name(idname31);
client_print(0print_chat"%s  turned on gun toss distance."name);

Also I tried to do the same with spray stats but it gave me error on line 27 and 57 :

PHP Code:
#include <amxmodx>
#include <engine>
#include <cstrike>

new g_bEnabled true

public plugin_init()
{
      
/* SVC_TEMPENTITY (event #23) event, trigger if parameter 1 is equal to 112 (TE_PLAYERDECAL) */
      
register_event("23""player_spray""a""1=112")

      
register_clcmd("say /spray""cmdToggleState")
}

public 
cmdToggleState(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_CT )
    {
        if( 
g_bEnabled )
        {
            
// Plugin is currently enabled.
            
g_bEnabled false // Disable plugin.
        
}
        else
        {
            
// Plugin is currently disabled.
            
g_bEnabled ture // Enable plugin.
        
}
    }
}

public 
player_spray()
{
      if( 
g_bEnabled // Perform action only if plugin is enabled.
      
{
{
      new 
id read_data(2/* as seen in the include, player index is the second parameter */
      
new iOrigin[3]

      
iOrigin[0] = read_data(3/* and of course, the coordinates... */
      
iOrigin[1] = read_data(4)
      
iOrigin[2] = read_data(5)

      
/* you can get the rest of parameters too if you need them */

      /* now, what you needed... distance... */

      
new iPlayerOrigin[3]

      
get_user_origin(idiPlayerOrigin)

      new 
iDistance get_distance(iPlayerOriginiOrigin)

      
client_print(idprint_chat"You sprayed your spray %d units far."iDistance)

And how can i do the same when you write /spray it shows %s turned on spray stats.

Big thanks for helping me.
Mankind is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-27-2011 , 02:48   Re: Registering cl_cmd
Reply With Quote #2

Quote:
Originally Posted by Mankind View Post
Thanks, works fine, but how do can i set the function client_print, so when the ct writes /toss, it shows %s turned on gun toss distance? I think it goes something like this, but im not completly sure :

PHP Code:
{
new 
name[32];
get_user_name(idname31);
client_print(0print_chat"%s  turned on gun toss distance."name);

That looks correct. You would put that in the code (without the braces) right after it is enabled.

Quote:
Originally Posted by Mankind View Post
Also I tried to do the same with spray stats but it gave me error on line 27 and 57 :
The first error is obvious, look at line 27 and see (I'm assuming you speak english here). The second error shows that you need to close all your braces. You should always check that ever { had a } to match it before posting errors.
__________________
fysiks is online now
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 23:33.


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