| AntagonistForHire |
02-04-2007 01:44 |
DM Counter help
Basically my question is, how do I get the actions in the switch case 0 to actually work. It won't compile as is because the variable "killer" in the switch is not defined, I get that. But how do I get the value from the event_deathmsg to the function that has the switch in it?
PHP Code:
#include <amxmodx> #include <amxmisc>
#define PLUGIN "Pluginr" #define VERSION "1.0" #define AUTHOR "Author"
new playerKills[33] = {0,...}; new maxKills = 3;
public plugin_init() { register_event("DeathMsg","death_msg","a") set_task(150.0,"minusdm",0,"",0,"b") }
public death_msg() {
new killerd = read_data(1); new victim = read_data(2); new menu[1024] new key = (1<<0|1<<1)
if(!killerd || killerd == victim) return; killer = read_data(1);
format(menu,sizeof(menu),"DM Menu") add(menu,sizeof(menu)," ^n^n ") add(menu,sizeof(menu),"Were you DMed?^n^n ") add(menu,sizeof(menu),"1. Yes^n ") add(menu,sizeof(menu),"2. No^n ") show_menu(victim, key, menu)
}
public DMMenu(victim,key) { switch(key) { case 0: { if (playerKills[killer] < 3){ playerKills[killer] += 1; client_print(killer, print_chat, "[DM Counter] DM points increased (%i/%i)", playerKills[killer], maxKills) } if (playerKills[killer] == maxKills) { server_cmd("banid 30 #%d kick^"[DM Counter] You were banned for deathmatching excessively^"", get_user_userid(killer)) } } case 1: { } } return PLUGIN_HANDLED; }
public minusdm(id){ if (playerKills[id] > 0) { client_print(id, print_chat, "[DM Counter] One DM point has been subtracted (%i/%i)", playerKills[id], maxKills) playerKills[id] -= 1; } }
|