Raised This Month: $ Target: $400
 0% 

read_argv emty


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Multe
Junior Member
Join Date: Mar 2006
Old 03-05-2006 , 05:44   read_argv emty
Reply With Quote #1

Hi,

my first post, my first question.

I tried to change the script psychosounds.sma which ich found here. It works fine and know i tried to add admin detection to seperate some sounds form public players.

Code:
#include <amxmodx> #include <amxmisc> #include <engine> #define MODE_ALIVE_HEAR_DEAD    1 #define MODE_ALIVE_CAN_TRIGGER  2 #define MODE_ONLY_ADMINS        4 #define MODE_NO_DISPLAY         8 #define MODE_PARTIAL            16 #define MAX_WORDS               320 #define MAX_SOUNDS              320 #define MAX_SOUNDTYPE           320 #define MAX_STR_LENGTH          32 #define SOUND_TYPE_LENGTH       1 new words[MAX_WORDS][MAX_STR_LENGTH];   // legt Array fuer Woerter an new sounds[MAX_SOUNDS][MAX_STR_LENGTH]; // legt Array fuer die Sounds an, new sound_type[MAX_SOUNDS][SOUND_TYPE_LENGTH]; // legt Array fuer die Soundtypen an, new num_sounds[MAX_WORDS] = {0,...};    // legt Array fuer Anzahl der Sounds an (pro Wort sind mehrere Sounds drin) new word2sound[MAX_WORDS][MAX_SOUNDS];  // legt Array fuer die Zuordung wortzusound an new word_count; new sound_count; new sound_use[33] = {0,...}; new muted[33] = {0,...}; new gmsgSayText; //..... spared some code public new_sound() {     if (read_argc() == 1) {         list_sounds();         return PLUGIN_HANDLED;     }     if (read_argc() != 4) {         server_print("Usage: pd_sound <keyword> <soundfile> <soundtype>");         return PLUGIN_HANDLED;     }     new keyword[MAX_STR_LENGTH];     new snd1[MAX_STR_LENGTH];     new sndtype[SOUND_TYPE_LENGTH];     read_argv(1, keyword, MAX_STR_LENGTH);     read_argv(2, snd1, MAX_STR_LENGTH);     read_argv(3, sndtype, SOUND_TYPE_LENGTH);     new debugline[256];     format(debugline, 255, "Debug: %s ", keyword);     add(debugline, 255, snd1);     add(debugline, 255, " ");     add(debugline, 255, sndtype);     server_print(debugline);     if (! add_sound(keyword, snd1, sndtype)) {         log_message("[PD] Too many sounds or words.");     }     return PLUGIN_HANDLED; } //... spared some code public plugin_init() {     register_plugin("PsychoSounds", "3.0b", "PsychoGuard)");     register_srvcmd("pd_sound", "new_sound", 0, "<keyword> <sound> <soundtype> [flags]");     register_concmd("pd_sound_mute", "mute", ADMIN_LEVEL_A, "<authid, nick or #userid>");     register_concmd("pd_sound_unmute", "mute", ADMIN_LEVEL_A, "<authid, nick or #userid>");     register_clcmd("say", "handle_say");     register_cvar("mb_sound_file", "addons/amxmodx/configs/sounds.cfg");     register_cvar("mb_sound_join", "");     register_cvar("mb_sound_leave", "");     register_cvar("mb_sound_warn", "25");     register_cvar("mb_sound_max", "30");     register_cvar("mb_sound_mode", "b");     gmsgSayText = get_user_msgid("SayText");     server_cmd("exec addons/amxmodx/configs/sounds.cfg");     return PLUGIN_CONTINUE; }

My problem:
I tried to add a new sound on comand line with:
pd_sound "LALA" "test.wav" "1"
As you see, i added a debug print out to the original code and there i see only
"Debug: LALA 1"
Argument 2 is emty.

What is wrong here?

Regards
Malte
Multe is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-05-2006 , 07:19  
Reply With Quote #2

I added comments and fixed that
Code:
#include <amxmodx> #include <amxmisc> #include <engine> #define MODE_ALIVE_HEAR_DEAD    1 #define MODE_ALIVE_CAN_TRIGGER  2 #define MODE_ONLY_ADMINS        4 #define MODE_NO_DISPLAY         8 #define MODE_PARTIAL            16 #define MAX_WORDS               320 #define MAX_SOUNDS              320 #define MAX_SOUNDTYPE           320 #define MAX_STR_LENGTH          32 #define SOUND_TYPE_LENGTH       2 // AT LEAST 1 + 1 in other case you'll get 1 - 1 == 0 later (see below for details) new words[MAX_WORDS][MAX_STR_LENGTH];   // legt Array fuer Woerter an new sounds[MAX_SOUNDS][MAX_STR_LENGTH]; // legt Array fuer die Sounds an, new sound_type[MAX_SOUNDS][SOUND_TYPE_LENGTH]; // legt Array fuer die Soundtypen an, new num_sounds[MAX_WORDS] = {0,...};    // legt Array fuer Anzahl der Sounds an (pro Wort sind mehrere Sounds drin) new word2sound[MAX_WORDS][MAX_SOUNDS];  // legt Array fuer die Zuordung wortzusound an new word_count; new sound_count; new sound_use[33] = {0,...}; new muted[33] = {0,...}; new gmsgSayText; //..... spared some code public new_sound() {     if (read_argc() == 1) { // FUNCTION list_sounds not found! //        list_sounds();         return PLUGIN_HANDLED;     }     if (read_argc() != 4) {           server_print("Usage: pd_sound <keyword> <soundfile> <soundtype>");         return PLUGIN_HANDLED;     }     new keyword[MAX_STR_LENGTH];     new snd1[MAX_STR_LENGTH];     new sndtype[SOUND_TYPE_LENGTH];     read_argv(1, keyword, MAX_STR_LENGTH - 1); // STRINGS ends with a null terminator so do at least LEN - 1     read_argv(2, snd1, MAX_STR_LENGTH - 1);     read_argv(3, sndtype, SOUND_TYPE_LENGTH - 1);     new debugline[256];     format(debugline, 255, "Debug: %s ", keyword);     add(debugline, 255, snd1);     add(debugline, 255, " ");     add(debugline, 255, sndtype);     server_print("%s", debugline);  // READ topic "CODERS: Use format correctly!" or something like that // FUNCTION add_sound not found! //    if (! add_sound(keyword, snd1, sndtype)) { //        log_message("[PD] Too many sounds or words."); //    }     return PLUGIN_HANDLED; } //... spared some code public plugin_init() {     register_plugin("PsychoSounds", "3.0b", "PsychoGuard)");     register_srvcmd("pd_sound", "new_sound", 0, "<keyword> <sound> <soundtype> [flags]"); // FUNCTIONS mute and handle_say not found! //    register_concmd("pd_sound_mute", "mute", ADMIN_LEVEL_A, "<authid, nick or #userid>"); //    register_concmd("pd_sound_unmute", "mute", ADMIN_LEVEL_A, "<authid, nick or #userid>"); //    register_clcmd("say", "handle_say");     register_cvar("mb_sound_file", "addons/amxmodx/configs/sounds.cfg");     register_cvar("mb_sound_join", "");     register_cvar("mb_sound_leave", "");     register_cvar("mb_sound_warn", "25");     register_cvar("mb_sound_max", "30");     register_cvar("mb_sound_mode", "b");     gmsgSayText = get_user_msgid("SayText");     server_cmd("exec addons/amxmodx/configs/sounds.cfg");     return PLUGIN_CONTINUE; }
VEN is offline
Multe
Junior Member
Join Date: Mar 2006
Old 03-06-2006 , 04:12  
Reply With Quote #3

Thanks a lot!

That was the solution.

Gruß Malte
Multe is offline
Reply


Thread Tools
Display Modes

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 20:18.


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