AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   modified killcam help (https://forums.alliedmods.net/showthread.php?t=46159)

lailoken 10-20-2006 00:35

modified killcam help
 
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

Emp` 10-20-2006 00:41

Re: modified killcam help
 
instead of using user_info, you should just make a global array (ex. bool:KillCam[33]) and use that instead. (there are problems with user_info)

lailoken 10-20-2006 12:08

Re: modified killcam help
 
I'm not even sure how to go about doing that.

This pretty much is my experience with pawn. My only other experience with pawn is modifying some runes for runemod 2 (more or less changing certain values, hehe)

Other than that, my coding experience is pretty much limited to mIRC scripts, php, some visual basic (pre- .net) and some C (took a class, can't remember much of it...)

Maybe an example line involving that Bool::KillCam[33] so I can try?

lailoken

Zenith77 10-20-2006 12:11

Re: modified killcam help
 
If you took a class in C you should remeber what a global variable is or if you don't you should read the basic tutorials for AMXX.

Code:
// Declare global vars out side of functions, prefeably under the header and before plugin_init() #include <amxmodx> new bool:gKillCam[33]; public plugin_init() {      // Code... }

Emp` 10-20-2006 17:48

Re: modified killcam help
 
Code:

    //set_user_info (player, "killcam", "on")
    gKillCam[id] = true

    //set_user_info (player, "killcam", "off")
    gKillCam[id] = false



All times are GMT -4. The time now is 04:52.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.