Raised This Month: $ Target: $400
 0% 

passing variables to a menu


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Mugsy
New Member
Join Date: Feb 2005
Old 03-05-2005 , 22:11   passing variables to a menu
Reply With Quote #1

Here is my plugin to give a menu to the victim of a team killer. In my handle_option() function I need to pass the variable vindex to it, how would I pass that variable to it?

Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>

#define MAX_NAME 33

//Declare three string variables
new PLUGIN[]="TK Revenge"
new AUTHOR[]="Shawn Wallis"
new VERSION[]="1.00"

public plugin_init()
{
     register_plugin(PLUGIN, VERSION, AUTHOR)
     new keys = MENU_KEY_1|MENU_KEY_2
     register_menucmd(register_menuid("Forgive?"), keys, "handle_option")
     register_event("DeathMsg", "event_tk", "a")

}

public event_tk(id)
{
  new kindex = read_data(1) //get the first message parameter
  new kteam = entity_get_int(kindex, EV_INT_team)
  new kname[MAX_NAME]
  get_user_name(kindex, kname, MAX_NAME)

  new vindex = read_data(2) //get the second message parameter
  new vteam = entity_get_int(vindex, EV_INT_team)
  new vname[MAX_NAME]
  get_user_name(kindex, vname, MAX_NAME)

  new weapon[32]
  read_data(3, weapon, 31)  //get the weapon name

  /* if killer is alive, not himself, and on same team */
 // if (kindex && (kindex != vindex) && (kteam == vteam)) {
    new params[2]
    params[0] = vindex
    params[1] = kindex
    set_task(0.2, "show_tkmenu", 0, params, 1)

    client_print(kindex, print_chat, "%s has team killed %s", kname, vname)
 // }

  return PLUGIN_HANDLED
}

public show_tkmenu(params[]) {
  new kname[MAX_NAME]
  get_user_name(params[1], kname, MAX_NAME)
  new tkmenu[192]
  new keys = MENU_KEY_1|MENU_KEY_2

//  format(tkmenu, 191, "You have been team killed by %s.^n^n1. Forgive^n2. Do not forgive", kname)
  format(tkmenu, 191, "Forgive?^n^n1. Forgive^n2. Do not forgive", kname)
  show_menu(params[0], keys, tkmenu)

  return PLUGIN_HANDLED
}

public handle_option(id, key) {
  new tkname[MAX_NAME]
  get_user_name(id, tkname, MAX_NAME)
  if (key == 0)
  {
    client_print(0, print_chat, "%s has forgiven", tkname)
  } else if (key == 1) {
    client_print(0, print_chat, "%s has not forgiven", tkname)
  }
}
Mugsy is offline
 



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 14:14.


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