Hi,
I make this code where players can request new maps by typing "requestmap mapname" in console and it write the mapname , players name and steamid to a maprequests.ini file in data folder.
But i'm kinda new to read_argv, so if you guys could check if i can improve it.
Thanks
PHP Code:
#include <amxmodx>
#include <colorchat>
new g_szFile[64]
new cvar_advert
public plugin_init()
{
register_plugin("Map requests", "1.0", "Drekes")
register_concmd("requestmap", "addmap")
cvar_advert = register_cvar("amx_mapreq_advert", "1")
register_cvar("amx_mapreq_advertdelay", "400.0") // Advert delay MUST BE A FLOAT
new datadir[64]
get_localinfo("amxx_datadir", datadir, 63)
format(g_szFile, 63, "%s/maprequests.ini", datadir)
if(!file_exists(g_szFile))
log_amx("maprequests.ini not found, creating new file.")
set_task(get_cvar_float("amx_mapreq_advertdelay"), "advert", 0) // Thanks to GHW_Chronic
}
public advert()
{
if(get_pcvar_num(cvar_advert) != 1)
{
remove_task()
return PLUGIN_HANDLED
}
ColorChat(0, NORMAL, "[AMXX]: Want a map that isn't on the server? Typ ^x03requestmap mapname ^x01in console")
return PLUGIN_HANDLED
}
public addmap(id)
{
new szData[35], szWrite[128]
new szName[33], szSteamID[35]
read_argv(1, szData, charsmax(szData))
get_user_name(id, szName, 32)
get_user_authid(id, szSteamID, 34)
formatex(szWrite, 127, "%s ID: %s requests map: %s", szName, szSteamID, szData)
write_file(g_szFile, szWrite)
console_print(id, "Your map request has been succesfully added. We will add it to the server soon.")
}
Maprequests.ini:
Code:
Angel_Killer -*CF*- ID: STEAM_ID_LAN requests map: de_test
If this code is bad, please don't post like "I lolled at this code...", instead tell me what's wrong
__________________