Hi im trying to make a fun mod for half life where you kill monsters and see who can kill the most for a set period of time.
There are three thing i need help with.First is how can i spawn the on specific points on the map and the second is how to see which player killed the monster and give him a frag and the third and final is how to monitor the monster count and if they are below a certain amount spawn some more.
Code:
/***************************************************************************************************
AMX Monster
Version: 0.3
Author: KRoTaL (Translated from AMX to AMXX by ^Bend3R
You have to install Monster Mod.
Commands:
amx_monster <name, #userid, authid, @TERRORIST, @CT, * (all)> <monster> <number>
monster: name of the monster you want to spawn (must be precached in the monster_precache.cfg file)
number: number of monsters you want to spawn
amx_findmonsters - displays in the console all the monsters which are on the map
amx_removemonsters <monster> <number>
name: name of the monster you want to remove (zombie, islave, agrunt...)
number: number of monsters you want to remove (type 0 to remove all the monsters with this name)
amx_monstermodel <model>
Changes the models of all the monsters alive.
model: path of the model without "models/" (droide.mdl, cow.mdl, ...)
You have to precache the models in the plugin_precache function (at the bottom of this file).
Use Half-Life models else monsters will be stuck in the ground.
Examples:
amx_monster joe snark 10
amx_monster @CT zombie 3
amx_removemonsters zombie 5
amx_monstermodel droide.mdl (droide.mdl is here: models/droide.mdl)
You must have ADMIN_SLAY flag to use these commands.
***************************************************************************************************/
#include <amxmodx>
#include <amxmisc>
#include <Vexd_Utilities>
#define INTERVAL 0.3
public plugin_init()
{
register_plugin("AMX Monster","0.3","KRoTaL")
register_concmd("amx_monster","admin_monster",ADMIN_SLAY,"<name/id/authid/@CT/@TERRORIST/ * (all)> <monster> <number>")
register_concmd("amx_findmonsters","find_monsters", ADMIN_SLAY, "displays all the monsters")
register_concmd("amx_removemonsters","remove_monsters", ADMIN_SLAY, "amx_removemonsters <name> <number (0 for all)>")
register_concmd("amx_monstermodel","monstermodel", ADMIN_SLAY, "<model>")
return PLUGIN_CONTINUE
}
public admin_monster(id,level,cid)
{
if (!cmd_access(id,level,cid,4))
{
return PLUGIN_HANDLED
}
new arg1[32], monster[32], arg3[9]
read_argv(1,arg1,31)
read_argv(2,monster,31)
read_argv(3,arg3,8)
new num_monsters
num_monsters = str_to_num(arg3)
if(num_monsters<1)
num_monsters=1
new i
new admin_name[33]
get_user_name(id, admin_name, 32)
if(arg1[0] == '@')
{
new users[32], inum
get_players(users, inum, "ae", arg1[1])
if(inum == 0)
{
console_print(id, "No users in such team")
return PLUGIN_HANDLED
}
for(i = 0; i < inum; ++i)
{
new param[34]
copy(param,33,monster)
param[32]=users[i]
set_task(INTERVAL, "spawn_monster", 124512+users[i], param, 33, "a", num_monsters-1)
}
switch(get_cvar_num("amx_show_activity"))
{
case 2: client_print(0,print_chat,"ADMIN %s: spawned %d %s%s on %s Team.",admin_name,num_monsters,monster,(num_monsters>1)?"s":"",arg1[1])
case 1: client_print(0,print_chat,"ADMIN: spawned %d %s%s on %s Team.",num_monsters,monster,(num_monsters>1)?"s":"",arg1[1])
}
console_print(id,"You spawned %d %s%s on %s Team.",num_monsters,monster,(num_monsters>1)?"s":"",arg1[1])
}
else if(arg1[0] == '*')
{
new users[32], inum
get_players(users, inum)
if(inum == 0)
{
console_print(id, "No users in such team")
return PLUGIN_HANDLED
}
for(i = 0; i < inum; ++i)
{
new param[34]
copy(param,33,monster)
param[32]=users[i]
set_task(INTERVAL, "spawn_monster", 124512+users[i], param, 33, "a", num_monsters-1)
}
switch(get_cvar_num("amx_show_activity"))
{
case 2: client_print(0,print_chat,"ADMIN %s: spawned %d %s%s on everybody.",admin_name,num_monsters,monster,(num_monsters>1)?"s":"")
case 1: client_print(0,print_chat,"ADMIN: spawned %d %s%s on everybody.",num_monsters,monster,(num_monsters>1)?"s":"")
}
console_print(id,"You spawned %d %s%s on everybody.",num_monsters,monster,(num_monsters>1)?"s":"")
}
else
{
new victim = cmd_target(id,arg1,6)
if (!victim)
return PLUGIN_HANDLED
new victim_name[33]
get_user_name(victim, victim_name, 32)
new param[34]
copy(param,33,monster)
param[32]=victim
set_task(INTERVAL, "spawn_monster", 124512+victim, param, 33, "a", num_monsters-1)
switch(get_cvar_num("amx_show_activity"))
{
case 2: client_print(0,print_chat,"ADMIN %s: spawned %d %s%s on %s.",admin_name,num_monsters,monster,(num_monsters>1)?"s":"",victim_name)
case 1: client_print(0,print_chat,"ADMIN: spawned %d %s%s on %s.",num_monsters,monster,(num_monsters>1)?"s":"",victim_name)
}
console_print(id,"You spawned %d %s%s on %s.",num_monsters,monster,(num_monsters>1)?"s":"",victim_name)
}
return PLUGIN_HANDLED
}
public spawn_monster(param[])
{
new monster[32]
copy(monster,31,param)
server_cmd("monster %s #%d", monster, param[32])
}
public find_monsters(id,level,cid)
{
if (!cmd_access(id,level,cid,1))
{
return PLUGIN_HANDLED
}
new monsters_num = 0
new monster = find_ent_by_class(-1, "func_wall")
while(monster > 0)
{
if(entity_get_int(monster, EV_INT_movetype) == 4)
{
monsters_num++
new model[32]
entity_get_string(monster, EV_SZ_model, model, 31)
while(replace(model, 31, "models/", "") && replace(model, 31, ".mdl", "")) {}
console_print(id, "Monster #%i: %s", monsters_num, model)
}
monster = find_ent_by_class(monster, "func_wall")
}
return PLUGIN_HANDLED
}
public remove_monsters(id,level,cid)
{
if (!cmd_access(id,level,cid,3))
{
return PLUGIN_HANDLED
}
new arg1[32]
read_argv(1, arg1, 31)
new arg2[32]
read_argv(2, arg2, 31)
new num_to_remove = str_to_num(arg2)
new monsters_num = 0
new bool:remove = true
new monster = find_ent_by_class(-1, "func_wall")
while(monster > 0 && remove)
{
new monster_model[32]
entity_get_string(monster, EV_SZ_model, monster_model, 31)
if(containi(monster_model, arg1) != -1)
{
monsters_num++
remove_entity(monster)
if(monsters_num == num_to_remove)
remove = false
monster = find_ent_by_class(-1, "func_wall")
}
else
{
monster = find_ent_by_class(monster, "func_wall")
}
}
if(monsters_num > 0)
{
if(num_to_remove < 1)
console_print(id, "All the %ss have been removed.", arg1)
else
console_print(id, "%d %s%s ha%s been removed.", num_to_remove, arg1, (num_to_remove>1)?"s":"", (num_to_remove>1)?"ve":"s")
}
else
{
console_print(id, "There are no %ss.", arg1)
}
return PLUGIN_HANDLED
}
public monstermodel(id,level,cid)
{
if (!cmd_access(id,level,cid,2))
{
return PLUGIN_HANDLED
}
new arg1[64]
read_argv(1, arg1, 63)
format(arg1, 63, "models/%s", arg1)
new monster = find_ent_by_class(-1, "func_wall")
while(monster > 0)
{
if(entity_get_int(monster, EV_INT_movetype) == 4)
{
entity_set_model(monster, arg1)
}
monster = find_ent_by_class(monster, "func_wall")
}
console_print(id, "You changed the models of all the monsters.")
return PLUGIN_HANDLED
}
public plugin_precache()
{
precache_model("models/hgrunt.mdl")
precache_model("models/agrunt.mdl")
precache_model("models/zombie.mdl")
precache_model("models/houndeye.mdl")
}
i can also give you the source of the monster mod dll file.