AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Making TK plugin, got stuck. (https://forums.alliedmods.net/showthread.php?t=76848)

allenwr 08-31-2008 18:57

Making TK plugin, got stuck.
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <dodx>

#define PLUGIN "TKC"
#define VERSION "0.1"
#define AUTHOR "Joker"

#define TKCKeys (1<<0)|(1<<1)

new g_params[32][2]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_menucmd(register_menuid("TKC Menu"),TKCKeys,"TKCMenuSelect")
}

public 
client_death(killervictimwpnindexhitplaceTK) {
    if(!
TK || (killer == victim))
        return 
PLUGIN_HANDLED;
    
    
g_params[victim][0] = killer
    g_params
[victim][1] = victim
    
    TKCMenu
(victim,g_params)
    return 
PLUGIN_CONTINUE
}

public 
TKCMenu(victim,g_params[][]) {
    new 
KillerName[32],MenuMessage[64]
    
get_user_name(g_params[victim][0],KillerName,31)    
    
    
format(MenuMessage,63,"'%s' TK'd you:^n^n1. Forgive^n2. Slay",KillerName)
    
show_menu(g_params[victim][1],TKCKeys,MenuMessage,-1,"TKC Menu")
}

public 
TKCMenuSelect(victimg_params[][], key) {
    switch(
key) {
        case 
0: {
            
client_print(victim,print_chat,"forgiven")
            return 
PLUGIN_CONTINUE
        
}
        case 
1: {
            
user_kill(g_params[victim][1], 1)
            
client_print(victim,print_chat,"killed")
        }
    }
    return 
PLUGIN_HANDLED


As I am relearning I got stuck between TKCMenu and TKCMenuSelect, I do not know how to transfer the player ids over.

allenwr 08-31-2008 19:04

Re: Making TK plugin, got stuck.
 
Actually I think I solved my problem. But Mods please leave thread open till I verify.

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <dodx>

#define PLUGIN "TKC"
#define VERSION "0.1"
#define AUTHOR "Joker"

#define TKCKeys (1<<0)|(1<<1)

new g_params[32][2]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_menucmd(register_menuid("TKC Menu"),TKCKeys,"TKCMenuSelect")
}

public 
client_death(killervictimwpnindexhitplaceTK) {
    if(!
TK || (killer == victim))
        return 
PLUGIN_HANDLED;
    
    
g_params[victim][0] = killer
    g_params
[victim][1] = victim
    
    TKCMenu
(victim,g_params)
    return 
PLUGIN_CONTINUE
}

public 
TKCMenu(victim,g_params[][]) {
    new 
KillerName[32],MenuMessage[64]
    
get_user_name(g_params[victim][0],KillerName,31)    
    
    
format(MenuMessage,63,"'%s' TK'd you:^n^n1. Forgive^n2. Slay",KillerName)
    
show_menu(g_params[victim][1],TKCKeys,MenuMessage,-1,"TKC Menu")
}

public 
TKCMenuSelect(victimkey) {
    switch(
key) {
        case 
0: {
            
client_print(victim,print_chat,"forgiven")
            return 
PLUGIN_CONTINUE
        
}
        case 
1: {
            
user_kill(g_params[victim][1], 1)
            
client_print(victim,print_chat,"killed")
        }
    }
    return 
PLUGIN_HANDLED 

</span>

Emp` 08-31-2008 19:09

Re: Making TK plugin, got stuck.
 
you'll probably want to do
Code:

user_kill(g_params[victim][0], 1)
to kill the person that killed them.

also, you don't really need to pass the victim as you know the id of the victim already. and you really shouldn't be passing a global (g_params) into another function (TKCMenu).

allenwr 08-31-2008 19:35

Re: Making TK plugin, got stuck.
 
Thanks Emp`

I had fixed that user_kill part before I uploaded and the g_params is so I can get the killers name.

Anyhow the plugin is working now.


Edit:
Actually for the final part of the plugin, MenuSelect, is it better to end the plugin with a PLUGIN_CONTINUE or HANDLED?

Emp` 08-31-2008 20:11

Re: Making TK plugin, got stuck.
 
The return doesn't matter.

And the point of a global variable is so you can use it in any function without passing it to those functions.


All times are GMT -4. The time now is 03:13.

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