Raised This Month: $ Target: $400
 0% 

Capturing user's clcmds


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 03-06-2010 , 01:13   Capturing user's clcmds
Reply With Quote #1

Was wondering how to go about doing this. What I have is a plugin that when a user says keywords, such as: nfs, stfu, or lag it ultimately plays a cooresponding sound (nfs.wav, stfu.wav, or lag.wav)..

As it is now, I have (eleven of each type):
11=> _clcmd("say COMMAND")
11=> _clcmd("say_team COMMAND")
11=> _concmd("COMMAND")

The script itself gets very messy and redundant and I'm a bit weak on using and capturing strings and needed a little help ..

Ultimately I wanted one public play(id) function rather than a function for each sound (so it's easier for users and I to add new sounds with releases)

Here's the script so you can get an idea.

Code:
#include <amxmodx> #include <amxmisc> #define PLUGINNAME  "Type Sounds" #define VERSION     "1.4" #define AUTHOR      "Dizzy" #define CVAR_PLUGIN "amx_typesounds" #define CVAR_USES   "amx_typesounds_uses" #define CVAR_ADMIN  "amx_typesounds_ao" new uses[33] = "CVAR_USES"; public plugin_init() {     register_plugin("PLUGINNAME","VERSION","AUTHOR");         register_cvar("CVAR_PLUGIN","1");     register_cvar("CVAR_USES","5");     register_cvar("CVAR_ADMIN","0");     register_clcmd("say holyshit","holyshit");     register_clcmd("say lag","lag");     register_clcmd("say please","please");     register_clcmd("say nfs","nfs");     register_clcmd("say stfu","stfu");     register_clcmd("say english","english");     register_clcmd("say hugebitch","hugebitch");     register_clcmd("say haha","haha");     register_clcmd("say who","who");     register_clcmd("say hacks","hacks");     register_clcmd("say fag","fag");     register_clcmd("say_team holyshit","holyshit");     register_clcmd("say_team lag","lag");     register_clcmd("say_team please","please");     register_clcmd("say_team nfs","nfs");     register_clcmd("say_team stfu","stfu");     register_clcmd("say_team english","english");     register_clcmd("say_team hugebitch","hugebitch");     register_clcmd("say_team haha","haha");     register_clcmd("say_team who","who");     register_clcmd("say_team hacks","hacks");     register_clcmd("say_team fag","fag");     register_concmd("holyshit","holyshit");     register_concmd("lag","lag");     register_concmd("please","please");     register_concmd("nfs","nfs");     register_concmd("stfu","stfu");     register_concmd("english","english");     register_concmd("hugebitch","hugebitch");     register_concmd("haha","haha");     register_concmd("who","who");     register_concmd("hacks","hacks");     register_concmd("fag","fag");     register_event("ResetHUD","roundchange","b"); } public plugin_precache() {     precache_sound("misc/holyshit.wav");     precache_sound("misc/lag.wav");     precache_sound("misc/please.wav");     precache_sound("misc/nfs.wav");     precache_sound("misc/stfu.wav");     precache_sound("misc/english.wav");     precache_sound("misc/hugebitch.wav");     precache_sound("misc/haha.wav");     precache_sound("misc/who.wav");     precache_sound("misc/hacks.wav");     precache_sound("misc/fag.wav"); } public holyshit(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)     {         client_print (id, print_chat, "[Type Sounds]: The plugin is off!");         return PLUGIN_HANDLED;     }         if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))         {             client_print (id, print_chat, "[Type Sounds]: Sorry, you are not an Administrator!");             return PLUGIN_HANDLED;         }         return PLUGIN_CONTINUE;     }     if (uses[id] != 0)     {         client_cmd(0, "spk misc/holyshit");         uses[id]--;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     client_print (id, print_chat, "[Type Sounds]: Sorry, 0 sound left, wait until next round!");     return PLUGIN_HANDLED; } public lag(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)     {         client_print (id, print_chat, "[Type Sounds]: The plugin is off!");         return PLUGIN_HANDLED;     }         if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))         {             client_print (id, print_chat, "[Type Sounds]: Sorry, you are not an Administrator!");             return PLUGIN_HANDLED;         }         return PLUGIN_CONTINUE;     }     if (uses[id] != 0)     {         client_cmd(0, "spk misc/lag");         uses[id]--;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     client_print (id, print_chat, "[Type Sounds]: Sorry, 0 sound left, wait until next round!");     return PLUGIN_HANDLED; } public please(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)     {         client_print (id, print_chat, "[Type Sounds]: The plugin is off!");         return PLUGIN_HANDLED;     }         if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))         {             client_print (id, print_chat, "[Type Sounds]: Sorry, you are not an Administrator!");             return PLUGIN_HANDLED;         }         return PLUGIN_CONTINUE;     }     if (uses[id] != 0)     {         client_cmd(0, "spk misc/please");         uses[id]--;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     client_print (id, print_chat, "[Type Sounds]: Sorry, 0 sound left, wait until next round!");     return PLUGIN_HANDLED; } public nfs(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)     {         client_print (id, print_chat, "[Type Sounds]: The plugin is off!");         return PLUGIN_HANDLED;     }         if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))         {             client_print (id, print_chat, "[Type Sounds]: Sorry, you are not an Administrator!");             return PLUGIN_HANDLED;         }         return PLUGIN_CONTINUE;     }     if (uses[id] != 0)     {         client_cmd(0, "spk misc/nfs");         uses[id]--;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     client_print (id, print_chat, "[Type Sounds]: Sorry, 0 sound left, wait until next round!");     return PLUGIN_HANDLED; } public stfu(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)     {         client_print (id, print_chat, "[Type Sounds]: The plugin is off!");         return PLUGIN_HANDLED;     }         if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))         {             client_print (id, print_chat, "[Type Sounds]: Sorry, you are not an Administrator!");             return PLUGIN_HANDLED;         }         return PLUGIN_CONTINUE;     }     if (uses[id] != 0)     {         client_cmd(0, "spk misc/stfu");         uses[id]--;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     client_print (id, print_chat, "[Type Sounds]: Sorry, 0 sound left, wait until next round!");     return PLUGIN_HANDLED; } public english(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)     {         client_print (id, print_chat, "[Type Sounds]: The plugin is off!");         return PLUGIN_HANDLED;     }         if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))         {             client_print (id, print_chat, "[Type Sounds]: Sorry, you are not an Administrator!");             return PLUGIN_HANDLED;         }         return PLUGIN_CONTINUE;     }     if (uses[id] != 0)     {         client_cmd(0, "spk misc/english");         uses[id]--;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     client_print (id, print_chat, "[Type Sounds]: Sorry, 0 sound left, wait until next round!");     return PLUGIN_HANDLED; } public hugebitch(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)     {         client_print (id, print_chat, "[Type Sounds]: The plugin is off!");         return PLUGIN_HANDLED;     }         if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))         {             client_print (id, print_chat, "[Type Sounds]: Sorry, you are not an Administrator!");             return PLUGIN_HANDLED;         }         return PLUGIN_CONTINUE;     }     if (uses[id] != 0)     {         client_cmd(0, "spk misc/hugebitch");         uses[id]--;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     client_print (id, print_chat, "[Type Sounds]: Sorry, 0 sound left, wait until next round!");     return PLUGIN_HANDLED; } public haha(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)     {         client_print (id, print_chat, "[Type Sounds]: The plugin is off!");         return PLUGIN_HANDLED;     }         if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))         {             client_print (id, print_chat, "[Type Sounds]: Sorry, you are not an Administrator!");             return PLUGIN_HANDLED;         }         return PLUGIN_CONTINUE;     }     if (uses[id] != 0)     {         client_cmd(0, "spk misc/haha");         uses[id]--;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     client_print (id, print_chat, "[Type Sounds]: Sorry, 0 sound left, wait until next round!");     return PLUGIN_HANDLED; } public who(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)     {         client_print (id, print_chat, "[Type Sounds]: The plugin is off!");         return PLUGIN_HANDLED;     }         if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))         {             client_print (id, print_chat, "[Type Sounds]: Sorry, you are not an Administrator!");             return PLUGIN_HANDLED;         }         return PLUGIN_CONTINUE;     }     if (uses[id] != 0)     {         client_cmd(0, "spk misc/who");         uses[id]--;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     client_print (id, print_chat, "[Type Sounds]: Sorry, 0 sound left, wait until next round!");     return PLUGIN_HANDLED; } public hacks(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)     {         client_print (id, print_chat, "[Type Sounds]: The plugin is off!");         return PLUGIN_HANDLED;     }         if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))         {             client_print (id, print_chat, "[Type Sounds]: Sorry, you are not an Administrator!");             return PLUGIN_HANDLED;         }         return PLUGIN_CONTINUE;     }     if (uses[id] != 0)     {         client_cmd(0, "spk misc/hacks");         uses[id]--;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     client_print (id, print_chat, "[Type Sounds]: Sorry, 0 sound left, wait until next round!");     return PLUGIN_HANDLED; } public fag(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)     {         client_print (id, print_chat, "[Type Sounds]: The plugin is off!");         return PLUGIN_HANDLED;     }         if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))         {             client_print (id, print_chat, "[Type Sounds]: Sorry, you are not an Administrator!");             return PLUGIN_HANDLED;         }         return PLUGIN_CONTINUE;     }     if (uses[id] != 0)     {         client_cmd(0, "spk misc/fag");         uses[id]--;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     client_print (id, print_chat, "[Type Sounds]: Sorry, 0 sound left, wait until next round!");     return PLUGIN_HANDLED; } public roundchange(id) {     if (get_cvar_num(CVAR_PLUGIN) == 0)         return PLUGIN_HANDLED;     if (get_cvar_num(CVAR_ADMIN) == 1)     {         if (!is_user_admin(id))             return PLUGIN_HANDLED;         uses[id] = CVAR_USES;         client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);         return PLUGIN_HANDLED;     }     uses[id] = CVAR_USES;     client_print (id, print_chat, "[Type Sounds]: %d sound(s) left!", uses[id]);     return PLUGIN_HANDLED; }

Yeah, I know, if I had it use one function it would be x11 smaller

Thanks in advance guys, you're always great help!
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
 



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 08:46.


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