I found a copy of Take13's killcam and tried to modify it so it'd only take a screenshot when someone makes a kill, once.
I wanted to be able to type into the console, amx_ss <player>, and have it disabled after they make a kill.
This is like the 4th hack into the code I did, the first hack worked out really well for me, when I loaded it onto my listen server, and amx_ss'd myself and got a couple screenshots, the results were as I expected.
However, when I uploaded it to the pub server, it wouldn't work, something about the id being 0 (further investigation indicates an index of 0 when using set_user_info is the server itself), which is clearly not the result I wanted.
I did some looking at some other code and tried to mash some codes together to make things work, but alas, no matter what I throw at the script, it keeps returning 0, and causing a runtime error on the script.
Code:
#include <amxmodx>
#include <amxmisc>
public killevent() {
new kinfo[8];
new kid = read_data (1);
new vid = read_data (2);
new msg[128];
get_user_info (kid, "killcam", kinfo, sizeof(kinfo));
if (equal (kinfo, "on", 0)) {
if ((kid != vid) && (kid != 0)) {
set_hudmessage(255, 200, 000, 0.05, 0.7, 2, 0.02, 12.0, 0.0, 0.2, 4);
format (msg, sizeof(msg), "Killcam took snapshot");
show_hudmessage (kid, msg);
client_cmd (kid, "snapshot");
set_user_info (kid, "killcam", "off");
}
}
return PLUGIN_HANDLED
}
public plugin_init(){
register_plugin("Take13 KillCam", "0.1a", "GIR");
register_event("DeathMsg", "killevent", "a");
register_concmd("amx_ss", "cmdScreenShot", ADMIN_IMMUNITY, "<name>");
return PLUGIN_CONTINUE
}
public cmdScreenShot(id, level, cid)
{
new arg[32];
new msg[128];
read_argv(1, arg, 31)
if (!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED
new player = cmd_target(id, arg, 1)
if (!player)
{
console_print (id, "AMXX_SS %L not valid!", id)
return PLUGIN_HANDLED
}
set_user_info (player, "killcam", "on");
set_hudmessage(255, 200, 000, 0.05, 0.7, 2, 0.02, 12.0, 0.0, 0.2, 4);
format (msg, sizeof(msg), "Killcam Enabled!");
return PLUGIN_HANDLED
}
Am I at least going in the right direction?
lailoken