Yeah the server_frame part is true CPU-Rape, but it works fine.
often it will be called. Only on placement and explosion/removal,
EDIT: Okay got it working the (much) better way. ^^
Code:
// This Plugin is designed for fast networks like 100 Mb/s LAN only
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <fakemeta>
#include <engine>
const MAXENTS=4096;
new VERSION[]="0.4";
new bool:g_game_running;
new g_mines[33];
new g_all_mines;
new g_i_am_owned[MAXENTS];
public plugin_precache() {
register_forward(FM_SetModel,"tmr_maybemine",0);
register_forward(FM_Think,"tmr_minethink",0);
}
public plugin_init() {
register_plugin("Tripmine Race",VERSION,"Silencer");
register_forward(FM_PlayerPreThink,"tmr_prethink",0);
register_cvar("mp_minerace","0");
set_task(0.2,"tmr_checkstatus",1,"",0,"b");
}
public tmr_minethink(ent) {
new class[32];
pev(ent,pev_classname,class,31);
//new owner=pev(ent,pev_owner); //The one who tripped
new Float:health=float(pev(ent,pev_health));
new iuser4=pev(ent,pev_iuser4);
if(equal(class,"monster_tripmine")&&health<=0.0&&iuser4<33) {
if(!iuser4) {
g_all_mines--;
}
else {
if(g_i_am_owned[ent]==iuser4) {
g_mines[iuser4]--;
g_all_mines--;
}
}
set_pev(ent,pev_iuser4,33);
g_i_am_owned[ent]=0;
}
}
public tmr_maybemine(ent,const model[]) {
new class[32];
pev(ent,pev_classname,class,31);
new owner=pev(ent,pev_owner);
if(equal(class,"monster_tripmine")) {
if(!owner) {
g_all_mines++;
}
else {
if(!g_i_am_owned[ent]) {
g_mines[owner]++;
g_all_mines++;
}
}
g_i_am_owned[ent]=owner;
set_pev(ent,pev_iuser4,owner);
}
}
public tmr_prethink(id) {
if(g_game_running&&is_user_connected(id)) {
if(is_user_alive(id)) {
new clip,ammo;
get_user_ammo(id,13,clip,ammo);
if(ammo<5) {
give_item(id,"weapon_tripmine");
}
}
set_hudmessage(128,172,132,0.03,0.8,0,1.0,255.0,0.0,0.0,4);
show_hudmessage(id,"Your Mines: %i^nAll Mines: %i",g_mines[id],g_all_mines);
}
}
public tmr_checkstatus() {
if(get_cvar_num("mp_minerace")) {
g_game_running=true;
}
else {
set_hudmessage(128,172,132,0.03,0.8,0,1.0,0.0,0.0,0.0,4);
show_hudmessage(0,"");
g_game_running=false;
}
}
I also know why getting the owner failed. The problem is, that in order to display that the player killed/damaged himself with the tripmine, the tripmines owner is changed to 0 for a moment. A very gay workaround. If there are multiple players getting killed by the same mine, it will probably work through all the players, adjusting the mines pev_owner to either 0 or to the original owner, depending on who is going to be logged as dead and who triggered the tripmine. Weirdtastic!