AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [CS] Chat commands with argument? *SOLVED* (https://forums.alliedmods.net/showthread.php?t=98608)

MrOpposite 07-27-2009 06:09

[CS] Chat commands with argument? *SOLVED*
 
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)

Xellath 07-27-2009 07:05

Re: [CS] Chat commands with argument?
 
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. :crab:

MrOpposite 07-27-2009 16:08

Re: [CS] Chat commands with argument?
 
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 :P)

MrOpposite 07-27-2009 16:13

Re: [CS] Chat commands with argument?
 
-- Accidental double click on "Post Reply" --


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

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