i want to store song path and song from ini file play when i want. Me tried to make helped taken from ZE 2.5. But it is not working plz some one fix this plzzz her eis code and ini and error
PHP Code:
/* Sublime AMXX Editor v2.2 */
#include <amxmodx>
#include <amxmisc>
// #include <cstrike>
// #include <engine>
// #include <fakemeta>
// #include <hamsandwich>
// #include <fun>
// #include <xs>
// #include <sqlx>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Author"
#define CONFIG_FILE "song.ini"
new Array: ready_sound
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /t1", "play")
}
public plugin_precache()
{
ready_sound = ArrayCreate(64, 1)
new i, buffer[128], temp_string[256]
for(i = 0; i < ArraySize(ready_sound); i++)
{
ArrayGetString(ready_sound, i, temp_string, sizeof(temp_string))
if(equal(temp_string[strlen(temp_string) - 4], ".mp3"))
{
format(buffer, charsmax(buffer), "sound/%s", temp_string)
precache_generic(buffer)
} else {
precache_sound(temp_string)
}
}
}
public load_config_file()
{
// Build customization file path
new path[64]
get_configsdir(path, charsmax(path))
format(path, charsmax(path), "%s/%s", path, CONFIG_FILE)
// File not present
if (!file_exists(path))
{
new error[100]
formatex(error, charsmax(error), "error")
set_fail_state(error)
return;
}
// Set up some vars to hold parsing info
new linedata[1024], key[64], value[960]
// Open customization file for reading
new file = fopen(path, "rt")
while (file && !feof(file))
{
// Read one line at a time
fgets(file, linedata, charsmax(linedata))
// Replace newlines with a null character to prevent headaches
replace(linedata, charsmax(linedata), "^n", "")
// Blank line or comment
if (!linedata[0] || linedata[0] == ';') continue;
// Get key and value(s)
strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
// Trim spaces
trim(key)
trim(value)
if (equal(key, "START"))
{
// Parse weapons
while (value[0] != 0 && strtok(value, key, charsmax(key), value, charsmax(value), ','))
{
// Trim spaces
trim(key)
trim(value)
// Add to weapons array
ArrayPushString(ready_sound, key)
}
}
}
}
public play()
{
static temp_string[128]
ArrayGetString(ready_sound, random_num(0, ArraySize(ready_sound) - 1), temp_string, sizeof(temp_string))
PlaySound(0, temp_string)
}
stock PlaySound(id, const sound[])
{
if(id == 0)
{
if (equal(sound[strlen(sound)-4], ".mp3"))
client_cmd(0, "mp3 play ^"sound/%s^"", sound)
else
client_cmd(0, "spk ^"%s^"", sound)
} else {
if(is_user_connected(id)&& is_user_alive(id))
{
if (equal(sound[strlen(sound)-4], ".mp3"))
client_cmd(id, "mp3 play ^"sound/%s^"", sound)
else
client_cmd(id, "spk ^"%s^"", sound)
}
}
}
PHP Code:
L 08/11/2018 - 11:19:43: Start of error session.
L 08/11/2018 - 11:19:43: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20180811.log")
L 08/11/2018 - 11:19:43: Invalid array handle provided (0)
L 08/11/2018 - 11:19:43: [AMXX] Displaying debug trace (plugin "Dynamic_array.amxx", version "unknown")
L 08/11/2018 - 11:19:43: [AMXX] Run time error 10: native error (native "ArrayPushString")
L 08/11/2018 - 11:19:43: [AMXX] [0] Dynamic_array.sma::load_config_file (line 97)
L 08/11/2018 - 11:19:43: [AMXX] [1] Dynamic_array.sma::plugin_precache (line 34)
L 08/11/2018 - 11:39:57: Start of error session.
L 08/11/2018 - 11:39:57: Info (map "de_airstrip") (file "addons/amxmodx/logs/error_20180811.log")
L 08/11/2018 - 11:39:57: Invalid array handle provided (0)
L 08/11/2018 - 11:39:57: [AMXX] Displaying debug trace (plugin "Dynamic_array.amxx", version "unknown")
L 08/11/2018 - 11:39:57: [AMXX] Run time error 10: native error (native "ArrayPushString")
L 08/11/2018 - 11:39:57: [AMXX] [0] Dynamic_array.sma::load_config_file (line 97)
L 08/11/2018 - 11:39:57: [AMXX] [1] Dynamic_array.sma::plugin_precache (line 34)
L 08/11/2018 - 12:00:02: Start of error session.
L 08/11/2018 - 12:00:02: Info (map "cs_havana") (file "addons/amxmodx/logs/error_20180811.log")
L 08/11/2018 - 12:00:02: Invalid array handle provided (0)
L 08/11/2018 - 12:00:02: [AMXX] Displaying debug trace (plugin "Dynamic_array.amxx", version "unknown")
L 08/11/2018 - 12:00:02: [AMXX] Run time error 10: native error (native "ArrayPushString")
L 08/11/2018 - 12:00:02: [AMXX] [0] Dynamic_array.sma::load_config_file (line 97)
L 08/11/2018 - 12:00:02: [AMXX] [1] Dynamic_array.sma::plugin_precache (line 34)
PHP Code:
START = sound/enf_misc2/enf_knife_4.mp3