Plugin mapfinder for all players

Started by repingayok
28/04/2009 08:26
Page 1 of 1
repingayok28/04/2009 08:26

Coderiz, can you remake this plugin because it works only for ADMINs.

Mapfinder AMXX Plugin by coderiz.
================================================================

USAGE ESAMPLE

say /mapfind dust
Will list such maps as de_dust, de_dust2, de_dust4....



#include
#include

#define PLUGIN "Map Finder"
#define AUTHOR "coderiz"
#define VERSION "1.0"

#define MENU_KEYS_ALL MENU_KEY_0 | MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9
#define MENU_KEYS_2 MENU_KEY_1 | MENU_KEY_2

new c_mapdir[] = "/maps"

new request[32]
new result[9][32], result_num, result_id
new changelevel[32], changelevel_id

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

register_clcmd("say", "cmd_say")
register_clcmd("say_team", "cmd_say")

register_menu("Map search result:", MENU_KEYS_ALL,"menu_result")
register_menu("Changelevel", MENU_KEYS_2,"menu_changelevel")
}

public cmd_say(id)
{
if(!access(id, ADMIN_MAP)) return PLUGIN_CONTINUE

new msg[64]
read_args(msg, 63)
remove_quotes(msg)
if(!equali(msg, "/findmap ", 9) && !equali(msg, "/mapfind ", 9)) return PLUGIN_CONTINUE

new str[32]
copy(str, 31, msg[9])

if(strlen(str) < 2) {
client_print(id, print_chat, "Usage example: /mapfind dust")
return PLUGIN_HANDLED
}
copy(request, 31, str)
client_print(id, print_chat, "Searching for maps containing '%s' ...", str)
set_task(0.1, "tsk_search", id)

return PLUGIN_HANDLED
}

public tsk_search(id)
{
result_id = id
result_num = 0

new dirh, filename[36], len
dirh = open_dir(c_mapdir, filename, 35)
if((len = map_match(filename, request)) > 0)
{
copy(result[result_num], len, filename)
result_num++
}

while(next_file(dirh, filename, 35))
{
if((len = map_match(filename, request)) > 0)
{
if(result_num <= 8)
{
copy(result[result_num], len, filename)
result_num++
}
client_print(id, print_console, filename)
}
}

close_dir(dirh)

if(result_num < 1)
{
client_print(id, print_chat, "No maps found matching the given pattern.")
return PLUGIN_HANDLED
}

if(result_num == 1)
client_print(id, print_chat, "Found one map matching the given pattern.")
else if(result_num < 8)
client_print(id, print_chat, "Found few maps matching the given pattern.")
else
client_print(id, print_chat, "Found many maps matching the given pattern.")

new str[64], menu[512]
add(menu, 511, "\yMap search result:^n")
for(new i=0; i {
formatex(str, 63, "\y0%i. \w%s^n", i+1, result)
add(menu, 511, str)
}
add(menu, 511, "\y00. Close")

client_print(id, print_console, "Request: %s", request)

show_menu(id, MENU_KEYS_ALL, menu, 30)

return PLUGIN_HANDLED
}

// menu for map search
public menu_result(id, key)
{
if(key == 9) return PLUGIN_CONTINUE
if(key >= result_num) return PLUGIN_HANDLED
if(id != result_id) {
client_print(id, print_chat, "Sorry, another admin is accessing this menu. Can not proceed.")
return PLUGIN_CONTINUE
}

changelevel = result[key]
changelevel_id = id

new menu[256]
formatex(menu, 255, "\yChangelevel to: \w%s \y?^n01. \wYes^n\y02. \wNo", changelevel)
show_menu(id, MENU_KEYS_2, menu, 30)

return PLUGIN_CONTINUE
}

// menu for confirming a map change
public menu_changelevel(id, key)
{
if(key == 1) return PLUGIN_CONTINUE
if(id != changelevel_id) {
client_print(id, print_chat, "Sorry, another admin is accessing this menu. Can not proceed.")
return PLUGIN_CONTINUE
}

if(key == 0) {
client_print(0, print_chat, "Changing map to: %s", changelevel)
server_cmd("changelevel %s", changelevel)
}

return PLUGIN_CONTINUE
}

// checks if given filename matches *patter*.bsp and returns string lenght for mapname.
map_match(const filename[], const pattern[])
{
new len, mapname[32]

len = strlen(filename)

if(len-4 > 31) return 0
if(!equali(filename[len-4], ".bsp")) return 0

copy(mapname, len-4, filename)
if(contain(mapname, pattern) < 0) return 0

return len-4
}

DaFox28/04/2009 23:59(edited 29/04/2009 16:18)

Please use Code tags...

// edit schlumpf
_DONT_ use code tags sicne they bug the website, use blockquote instead

mhke29/04/2009 12:41

register_clcmd("say", "cmd_say")
register_clcmd("say_team", "cmd_say")

xPaw mapper29/04/2009 13:18

in public cmd_say

remove this line
if(!access(id, ADMIN_MAP)) return PLUGIN_CONTINUE

havocStorm29/04/2009 13:30

Originally posted by xPaw
in public cmd_say

remove this line
if(!access(id, ADMIN_MAP)) return PLUGIN_CONTINUE


Example for reping...


#include
#include

#define PLUGIN "Map Finder"
#define AUTHOR "coderiz"
#define VERSION "1.0"

#define MENU_KEYS_ALL MENU_KEY_0 | MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9
#define MENU_KEYS_2 MENU_KEY_1 | MENU_KEY_2

new c_mapdir[] = "/maps"

new request[32]
new result[9][32], result_num, result_id
new changelevel[32], changelevel_id

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

register_clcmd("say", "cmd_say")
register_clcmd("say_team", "cmd_say")

register_menu("Map search result:", MENU_KEYS_ALL,"menu_result")
register_menu("Changelevel", MENU_KEYS_2,"menu_changelevel")
}

public cmd_say(id)
{

new msg[64]
read_args(msg, 63)
remove_quotes(msg)
if(!equali(msg, "/findmap ", 9) && !equali(msg, "/mapfind ", 9)) return PLUGIN_CONTINUE

new str[32]
copy(str, 31, msg[9])

if(strlen(str) < 2) {
client_print(id, print_chat, "Usage example: /mapfind dust")
return PLUGIN_HANDLED
}
copy(request, 31, str)
client_print(id, print_chat, "Searching for maps containing '%s' ...", str)
set_task(0.1, "tsk_search", id)

return PLUGIN_HANDLED
}

public tsk_search(id)
{
result_id = id
result_num = 0

new dirh, filename[36], len
dirh = open_dir(c_mapdir, filename, 35)
if((len = map_match(filename, request)) > 0)
{
copy(result[result_num], len, filename)
result_num++
}

while(next_file(dirh, filename, 35))
{
if((len = map_match(filename, request)) > 0)
{
if(result_num <= 8)
{
copy(result[result_num], len, filename)
result_num++
}
client_print(id, print_console, filename)
}
}

close_dir(dirh)

if(result_num < 1)
{
client_print(id, print_chat, "No maps found matching the given pattern.")
return PLUGIN_HANDLED
}

if(result_num == 1)
client_print(id, print_chat, "Found one map matching the given pattern.")
else if(result_num < 8)
client_print(id, print_chat, "Found few maps matching the given pattern.")
else
client_print(id, print_chat, "Found many maps matching the given pattern.")

new str[64], menu[512]
add(menu, 511, "\yMap search result:^n")
for(new i=0; i{
formatex(str, 63, "\y0%i. \w%s^n", i+1, result)
add(menu, 511, str)
}
add(menu, 511, "\y00. Close")

client_print(id, print_console, "Request: %s", request)

show_menu(id, MENU_KEYS_ALL, menu, 30)

return PLUGIN_HANDLED
}

// menu for map search
public menu_result(id, key)
{
if(key == 9) return PLUGIN_CONTINUE
if(key >= result_num) return PLUGIN_HANDLED
if(id != result_id) {
client_print(id, print_chat, "Sorry, another USER is accessing this menu. Can not proceed.")
return PLUGIN_CONTINUE
}

changelevel = result[key]
changelevel_id = id

new menu[256]
formatex(menu, 255, "\yChangelevel to: \w%s \y?^n01. \wYes^n\y02. \wNo", changelevel)
show_menu(id, MENU_KEYS_2, menu, 30)

return PLUGIN_CONTINUE
}

// menu for confirming a map change
public menu_changelevel(id, key)
{
if(key == 1) return PLUGIN_CONTINUE
if(id != changelevel_id) {
client_print(id, print_chat, "Sorry, another USER is accessing this menu. Can not proceed.")
return PLUGIN_CONTINUE
}

if(key == 0) {
client_print(0, print_chat, "Changing map to: %s", changelevel)
server_cmd("changelevel %s", changelevel)
}

return PLUGIN_CONTINUE
}

// checks if given filename matches *patter*.bsp and returns string lenght for mapname.
map_match(const filename[], const pattern[])
{
new len, mapname[32]

len = strlen(filename)

if(len-4 > 31) return 0
if(!equali(filename[len-4], ".bsp")) return 0

copy(mapname, len-4, filename)
if(contain(mapname, pattern) < 0) return 0

return len-4
}

repingayok29/04/2009 23:16

senks, but when I don't compile it, 1 ERROR (AMX MOD X 1.81). Pls give me .amxx-plugin =)

SchlumPF30/04/2009 17:41

wait a few more days, i made a new mapfinder plugin which is a lot mroe optimized than coderiz ^^
ill release it as soon as emti finished some work for me... :D

repingayok27/05/2009 13:11

Originally posted by SchlumPF
wait a few more days, i made a new mapfinder plugin which is a lot mroe optimized than coderiz ^^
ill release it as soon as emti finished some work for me... :D


When you will finish it ? =)

Page 1 of 1

Please log in to post replies.