AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Media Kick/Ban Help (https://forums.alliedmods.net/showthread.php?t=28937)

allenwr 05-26-2006 00:22

Media Kick/Ban Help
 
Ok, I am at a loss...

I dont know where i am going wrong, there are not compiling errors/warnings and there are no errors in the server logs...

Code:
/* *******************************| *Media/Music Kick/Ban - Allenwr| *******************************| * ****** *When an admin kicks a player, its plays a sound... * *Kick/Ban = Random Files Placed in the mediakickban.ini file * *Commands *-------- *amx_mkick <name or #userid> [reason] *amx_mban <name or #userid> <minutes> [reason] *Same as regular kick/ban * *Changelog *--------- * -1.0 1st release- * -2.0 plugin now chooses random sounds to play when kicking or banning- * -3.0 Now Files can be chosen by user in the mediakickban.ini file- */ #include <amxmodx> #include <amxmisc> #define mkickbansounds 8 #define ini_file "addons/amxmodx/configs/mediakickban.ini" new soundlist[mkickbansounds][80] public read_ini() {     new txt[100],line=0,sound[65]     new fp=fopen(ini_file, "rt")     while(!feof(fp))     {         fgets(fp,txt,99)         parse(txt,sound,99)         format(soundlist[line],79,"%s",sound)         line++     } } public cmd_mkick(id, level, cid) {     if (!cmd_access(id, level, cid, 2))         return PLUGIN_HANDLED           new txt[80]     read_args(txt, 79)         new s  = random_num(0,mkickbansounds-1)         client_cmd(0, "stopsound")     client_cmd(0,"mp3 play ^"sound/misc/%s^"", soundlist[s])         set_task(10.0,"kick_timer",_,txt,strlen(txt))     return PLUGIN_HANDLED } public cmd_mban(id, level, cid) {     if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED           new txt[80]     read_args(txt, 79)         new s2 = random_num(0,mkickbansounds-1)         client_cmd(0, "stopsound")     client_cmd(0,"mp3 play ^"sound/misc/%s^"", soundlist[s2])         set_task(11.0,"ban_timer",_,txt,strlen(txt))     return PLUGIN_HANDLED } public kick_timer(txt[]) {     server_cmd("amx_kick %s",txt) } public ban_timer(txt[]) {     server_cmd("amx_ban %s",txt) } public plugin_precache() {     new sound[100]         for (new i=0;i<mkickbansounds;i++)     {         format(sound,99,"misc/%s",soundlist[i])         precache_sound(sound)     }         return PLUGIN_CONTINUE } public plugin_init() {     register_plugin("Media Kick/Ban", "3.0", "Allenwr")     register_concmd("amx_mkick", "cmd_mkick", ADMIN_KICK, "<name or #userid> [reason]")     register_concmd("amx_mban", "cmd_mban", ADMIN_BAN, "<name or #userid> <minutes> [reason]") }
this is the code from my plugin, and the new code i am trying does not work...

Code:

//*put sounds here*
//*8 different sounds max ( "#defined mkickbansounds 8" in mediakickban.sma)*
hittheroadjack.mp3
heyheyheygoodbye.mp3
kickedmusic.mp3
leavingonajetplane.mp3
//
//*sounds here just repeated (lack of 8 sounds "hehe" )*
//
hittheroadjack.mp3
heyheyheygoodbye.mp3
kickedmusic.mp3
leavingonajetplane.mp3

code from ini file

help will be appreciated.

Xanimos 05-26-2006 00:27

add the line
Code:
read_ini()
into public plugin_precache() before you check stuff....you never call that function.

And you need to check for the comments. They aren't auto skipped.

Also you should use get_configsdir() or other to get your file location.

KoST 05-26-2006 00:51

use this:

Code:
public plugin_precache() {     read_ini()     new sound[100]         for (new i=0;i<mkickbansounds;i++)     {         format(sound,99,"misc/%s",soundlist[i])         precache_sound(sound)     }         return PLUGIN_CONTINUE }



Code:
public read_ini() {     new txt[100],line=0,sound[65]     new fp=fopen(ini_file, "rt")     while(!feof(fp))     {         fgets(fp,txt,99)         parse(txt,sound,99)         if (sound[0]!="/" && line<mkickbansounds){             format(soundlist[line],79,"%s",sound)             line++         }     } }

then you can use the config file you have...

Greenberet 05-26-2006 03:52

and add
Code:
fclose(fp);
at the end of the read_ini function


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

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