Quote:
Originally Posted by Sylwester
You can store rules for different maps in separate files.
|
PHP Code:
#include <amxmodx>
#include <amxmisc>
public plugin_init(){
register_plugin("Test","1.0","We think about it")
}
public plugin_cfg() {
new mapname[64];
get_mapname(mapname,63)
// Here I dont know how to do it -.-"
new curent_map_file[] = (%s_rules.txt, mapname)
if (!file_exists(curent_map_file)) {
write_file(curent_map_file, "; Text your map rules below")
console_print(0, "%s file not found. Creating new", curent_map_file)
}
}
public client_authorized ( id ) set_task(1.0, "showrules",id,tmp,1)
public showrules (pid[]) {
new id = pid[0]
if ( get_user_team(id) != 1 && get_user_team(id) != 2 ) {
if (id) {
new tmp[1]
tmp[0] = id
set_task(2.0, "showrules",id,tmp,1) // not yet in server
}
return PLUGIN_HANDLED
}
new tmp[1]
tmp[0] = id
set_task(3.0, "printrules", id, tmp, 1) // not yet in server
return PLUGIN_HANDLED
}
public printrules(pid[])
{
new id = pid[0]
if (file_exists(curent_map_file))
{
console_print(0, "[user] printing rules for user %d", id)
for(i=0; read_file(curent_map_file, i, text, 127, num); i++) {
if (num > 0 && text[0] != ';') {
client_print(0,print_chat,"%s", text)
}
}
}
return PLUGIN_HANDLED
}
And also how could I print rules each one by one, randomly.
I guess this will print the whole text at once