Raised This Month: $ Target: $400
 0% 

[CS] Chat commands with argument? *SOLVED*


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MrOpposite
Junior Member
Join Date: Jul 2009
Location: Sverige FTW
Old 07-27-2009 , 06:09   [CS] Chat commands with argument? *SOLVED*
Reply With Quote #1

Hello, I was trying to create a betting script. I figured it was a good place to start. I'm not completely new into coding, I've done some c++ before.

The plugin is for Counter-Strike

Okay, now to the problem. I was thinking that the player would say "/bet <TEAM> <AMOUNT>" (Yes, this is a replica of something I've seen in the past).

This is my current code:
PHP Code:
#include <amxmodx>
#include <fun>
#include <cstrike
#include <fakemeta>

new bool:hasbet[32]; // Inits the bool:array hasbet.

public plugin_init() //Init plugin...
{
    
register_plugin("Betmod","0.1","MrOpposite"//I created this :P
    //-----------------------------------------
    //CVARS
    //-----------------------------------------
    
register_cvar("sv_bet","1"); //Is betting enabled?
    //-----------------------------------------
    //CLIENT COMMANDS
    //-----------------------------------------
    
register_clcmd("say /bet * *","bet"); //Trying to trigger the function bet when a message begins with /bet
    //-----------------------------------------
    //EVENTS
    //-----------------------------------------
    
register_event("ResetHUD","roundchange","b"); // Found this, will use it later when I get further in development.
    //-----------------------------------------
}

public 
client_connect(id)
{
    
hasbet[id] = false//Reset the hasbet for the connecting player.
}
public 
client_disconnect(id)
{
    
hasbet[id] = false//Reset the hasbet for the disconnecting player.
}

public 
bet(id//When a player bets...
{
    
console_print(id"betted");

Now how can I get whenever a message begins with "/bet" and get what the player wrote after that?

Final note:
This is my first post, feel free to ask for more info and such. (I cant figure out more to say)

Last edited by MrOpposite; 07-27-2009 at 18:23. Reason: Added *solved* tag
MrOpposite is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 07-27-2009 , 07:05   Re: [CS] Chat commands with argument?
Reply With Quote #2

PHP Code:
public plugin_init( )
{
    
register_clcmd"say""checkSay" );
}

public 
checkSay( )
{
    new 
szSaid32 ];

    
read_argsszSaid31 );
    
remove_quotesszSaid );

    if ( 
equalszSaid], '/' ) && equalszSaid], 'b' ) );
    {
        
// Player said '/b'
        // Call a func 
    
}

I think you should use something like this.

If you want too hook round start, you shouldn't use resetHUD, use the HLTV event or logevent.

Please cut me some slack, I wrote this on my phone.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Xellath; 07-27-2009 at 07:08.
Xellath is offline
MrOpposite
Junior Member
Join Date: Jul 2009
Location: Sverige FTW
Old 07-27-2009 , 16:08   Re: [CS] Chat commands with argument?
Reply With Quote #3

GREAT! This code works:
PHP Code:
#include <amxmodx>
#include <fun>
#include <cstrike>
#include <fakemeta>
new bool:hasbet[32]; // Inits the bool:array hasbet.

public plugin_init() //This is the public that starts the plugin registration
//This is The Bracket To Start A Plugin Public
    
register_plugin("Betmod","0.1","MrOpposite"//I created this :P
    //-----------------------------------------
    //CVARS
    //-----------------------------------------
    
register_cvar("sv_bet","1"); //Is betting enabled?
    //-----------------------------------------
    //CLIENT COMMANDS
    //-----------------------------------------
    
register_clcmd"say""bet" );
    
//-----------------------------------------
    //EVENTS
    //-----------------------------------------
    //register_event("HLTV","roundchange","b"); // Found this, will use it later when I get further in development.
    //-----------------------------------------
//The Closing Bracket

public client_connect(id)
{
    
hasbet[id] = false//Reset the hasbet for the connecting player.
}
public 
client_disconnect(id)
{
    
hasbet[id] = false//Reset the hasbet for the disconnecting player.
}

public 
bet(id//This is The Start Of Our Money Public (Above We put register_clcmd("say /loanmoney","money") The Money States To Go To The public money
{
    new 
szSaid32 ]; 

    
read_argsszSaid31 ); 
    
remove_quotesszSaid ); 

    if ( 
szSaid] == '/' && szSaid] == 'b' )
    { 
        
// Player said '/b' 
        
console_print(id"betted");
    }

Thanks alot ^^ (I got argument type missmatch when using the equal() function, so i changed that to double equal signs )
MrOpposite is offline
MrOpposite
Junior Member
Join Date: Jul 2009
Location: Sverige FTW
Old 07-27-2009 , 16:13   Re: [CS] Chat commands with argument?
Reply With Quote #4

-- Accidental double click on "Post Reply" --

Last edited by MrOpposite; 07-28-2009 at 06:10.
MrOpposite 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 18:18.


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