/* AMX Mod X * Healthkit * * (c) Copyright 2006 by VEN * * This file is provided as is (no warranties) * * Description: * This plugin basically provides an ability to spawn HL healthkits. * If healthkit is collected it would appear again later like in HL. * Note: Engine module required. * * Commands: * healthkit_spawn [save] - spawns a healthkit at the origin of a player who typed that command * if "save" argument is specified then origin would be added to the end of the file * $configsdir/maps/.cfg (file would be created if it is not exists) * that would allow to spawn saved healthkits every specific map load * Note: to avoid error create $configsdir/maps folder if it is not exists. * * healthkit_load - spawns a healthkit at the specified origin * * healthkit_clear - removes all spawned healthkits * * Commands access level is ADMIN_CFG (falg "h") can be redefined (#define ACCESS_LEVEL) */ #include #include #include #include #include #define ACCESS_LEVEL ADMIN_CFG new CLASSNAME[] = "item_healthkit" new FILE[96] new ADD_HEALTH = 30; public plugin_init() { register_plugin("Healthkit", "0.1", "VEN") register_clcmd("healthkit_spawn", "cmd_healthkit_spawn", ACCESS_LEVEL, "[save]") register_concmd("healthkit_load", "cmd_healthkit_load", ACCESS_LEVEL, " ") register_concmd("healthkit_clear", "cmd_healthkit_clear", ACCESS_LEVEL) register_forward(FM_Touch, "fmtouch") new configs_dir[64], map[32] get_configsdir(configs_dir, 63) get_mapname(map, 31) format(FILE, 95, "%s/maps/%s.cfg", configs_dir, map) } public plugin_precache() { precache_model("models/w_medkit.mdl") precache_sound("items/smallmedkit1.wav") } public cmd_healthkit_spawn(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED new origin[3]; get_user_origin(id, origin) healthkit_spawn(origin) new arg1[6] read_argv(1, arg1, 5) if (!equali(arg1, "save")) return PLUGIN_HANDLED new command[48] format(command, 47, "healthkit_load %d %d %d", origin[0], origin[1], origin[2]) write_file(FILE, command) return PLUGIN_HANDLED } public cmd_healthkit_load(id, level, cid) { if (!cmd_access(id, level, cid, 4)) return PLUGIN_HANDLED new arg1[8], arg2[8], arg3[8], origin[3] read_argv(1, arg1, 7) read_argv(2, arg2, 7) read_argv(3, arg3, 7) origin[0] = str_to_num(arg1) origin[1] = str_to_num(arg2) origin[2] = str_to_num(arg3) healthkit_spawn(origin) return PLUGIN_HANDLED } public cmd_healthkit_clear(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED new healthkit = -1 while ((healthkit = find_ent_by_class(healthkit, CLASSNAME))) remove_entity(healthkit) return PLUGIN_HANDLED } healthkit_spawn(origin[3]) { new healthkit = create_entity(CLASSNAME) if (!healthkit) return new Float:vec[3] IVecFVec(origin, vec) entity_set_origin(healthkit, vec) DispatchSpawn(healthkit) } public fmtouch(ent, id) { if( !is_user_alive( id ) ) return FMRES_IGNORED; if( !pev_valid( ent ) ) return FMRES_IGNORED; static classname_h[32]; pev( ent, pev_classname, classname_h, 31 ); if( !equali( classname_h, CLASSNAME ) ) return FMRES_IGNORED; fm_set_user_health( id, get_user_health( id ) + ADD_HEALTH ); remove_entity(ent); return FMRES_IGNORED; }