#include <amxmodx>
#include <engine>
#include <fakemeta>
#define PLUGIN "NPC"
#define VERSION "1.0"
#define AUTHOR "DeRoiD"
#define NPCMDL "models/npc/npc.mdl"
new bool:hozzanyult[33]
public plugin_precache()
precache_model(NPCMDL)
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
npc_betolt()
register_touch("npc","player","npc_erint")
}
public npc_erint(ent, id)
{
if(hozzanyult[id])
return PLUGIN_HANDLED
client_print(id, print_chat, "Hozzanyultal az NPChez!")
hozzanyult[id] = true
npc_menu(id)
set_task(10.0, "npc_ujra", id)
return PLUGIN_HANDLED
}
public npc_ujra(id)
hozzanyult[id] = false
public npc_betolt()
{
new Float:origin[3]
new file[192], map[32]
get_mapname(map, 31)
formatex(file, charsmax(file), "addons/amxmodx/configs/npc/%s.cfg", map)
new elsopoz[8], masodikpoz[8], harmadikpoz[8]
new lines = file_size(file, 1)
if(lines > 0)
{
new buff[256], len
read_file(file, random(lines), buff, charsmax(buff), len)
parse(buff, elsopoz, 7, masodikpoz, 7, harmadikpoz, 7)
origin[0] = str_to_float(elsopoz)
origin[1] = str_to_float(masodikpoz)
origin[2] = str_to_float(harmadikpoz)
new ent = create_entity("info_target")
set_pev(ent, pev_classname, "npc")
entity_set_model(ent, NPCMDL)
set_pev(ent,pev_solid, SOLID_BBOX)
set_pev(ent, pev_movetype, MOVETYPE_TOSS)
engfunc(EngFunc_SetOrigin, ent, origin)
engfunc(EngFunc_SetSize, ent, Float:{-10.0,-10.0,0.0}, Float:{10.0,10.0,25.0})
engfunc(EngFunc_DropToFloor, ent)
}
else
log_amx("Nem talalhato a betoltendo fajl")
}
public client_putinserver(id)
hozzanyult[id] = false
public npc_menu(id)
{
new menu = menu_create("NPC \d(By DeRoiD)", "npc_menuh" )
menu_additem(menu,"Szerver szabalyzat","1",0)
menu_additem(menu,"Elerhetosegek","2",0)
menu_additem(menu,"Online adminok","3",0)
menu_display(id, menu, 0)
}
public npc_menuh(id, menu, item) {
if(item == MENU_EXIT)
{
menu_destroy(menu)
return
}
new data[9], szName[64];
new access, callback;
menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
new key = str_to_num(data);
switch(key)
{
case 1 : {
show_motd(id, "addons/amxmodx/configs/npc/szabalyzat.txt", "Szerver szabalyzat")
}
case 2 : {
show_motd(id, "addons/amxmodx/configs/npc/elerhetosegek.txt", "Elerhetosegek")
}
case 3 : {
new szoveg[512];
new bool:elso=false;
format(szoveg, 511, "")
new p[32],n;
get_players(p,n,"ch")
for(new i=0;i<n;i++)
{
if(get_user_flags(p[i]) & ADMIN_BAN)
{
new name[33];
get_user_name(p[i], name, 32)
if(!elso)
{
format(szoveg, 511, "Online adminok: %s", name)
elso=true;
}
else
{
format(szoveg, 511, "%s, %s", szoveg, name)
}
}
}
if(!elso)
format(szoveg, 511, "Nincs online admin.");
client_print(id, print_chat, szoveg);
}
}
}