Raised This Month: $ Target: $400
 0% 

Making TK plugin, got stuck.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
allenwr
Veteran Member
Join Date: Jan 2006
Location: The place where the karm
Old 08-31-2008 , 18:57   Making TK plugin, got stuck.
Reply With Quote #1

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.
__________________
Don't ever place an order with Vee Servers. This is why.
allenwr is offline
Send a message via ICQ to allenwr Send a message via Yahoo to allenwr
allenwr
Veteran Member
Join Date: Jan 2006
Location: The place where the karm
Old 08-31-2008 , 19:04   Re: Making TK plugin, got stuck.
Reply With Quote #2

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>
__________________
Don't ever place an order with Vee Servers. This is why.
allenwr is offline
Send a message via ICQ to allenwr Send a message via Yahoo to allenwr
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 08-31-2008 , 19:09   Re: Making TK plugin, got stuck.
Reply With Quote #3

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).
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
allenwr
Veteran Member
Join Date: Jan 2006
Location: The place where the karm
Old 08-31-2008 , 19:35   Re: Making TK plugin, got stuck.
Reply With Quote #4

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?
__________________
Don't ever place an order with Vee Servers. This is why.
allenwr is offline
Send a message via ICQ to allenwr Send a message via Yahoo to allenwr
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 08-31-2008 , 20:11   Re: Making TK plugin, got stuck.
Reply With Quote #5

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.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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