Raised This Month: $51 Target: $400
 12% 

Player Death Menu Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mr.Freeman
Senior Member
Join Date: Nov 2013
Location: Canada
Old 02-04-2014 , 20:23   Player Death Menu Help
Reply With Quote #1

Hey making a private plugin for someone and hit a roadblock. I'm looking to open a menu when the player dies it opens a menu with the Title "Was that a nice kill" "Yes" or "No" options. If the player selects yes it informs the killer that they have made a nice kill and no acts the same as MenuAction_End.

Here is what I have so far, willing to donate to the person who completes this task first!

PHP Code:

public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
    new 
killer GetClientOfUserId(GetEventInt(event"attacker"));
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    
    
GetClientName(killerkiller_namesizeof(killer_name));
    
    if(
killer == victim)
    {
        return;
    }
    else
    {
        new 
Handle:PlayerDeathMenu CreateMenu(PlayerDeathMenu_Handler);
        
SetMenuTitle(PlayerDeathMenu"Was that a nice kill?");
        
        
AddMenuItem(PlayerDeathMenu"1""Yes");
        
AddMenuItem(PlayerDeathMenu"2""No");
        
        
SetMenuExitBackButton(PlayerDeathMenutrue);
        
DisplayMenu(PlayerDeathMenuvictim30);
    }
    
    return 
Plugin_Continue
}

public 
PlayerDeathMenu_Handler(Handle:menuMenuAction:actionvictimkiller)
{
    switch (
action)
    {
        case 
MenuAction_End:
        {
            
CloseHandle(menu);
        }
        if (
action == MenuAction_Select)
        {
            case 
0:
            {
                
CPrintToChat(killer"{mediumorchid}[Kill Info]{default} You have made a nice kill");                
            }
            case 
1:
            {
                
//
            
}
        }
    }

Hope to hear from you guys soon,
Matt
Mr.Freeman is offline
Pyro_
Senior Member
Join Date: Oct 2013
Old 02-04-2014 , 23:11   Re: Player Death Menu Help
Reply With Quote #2

Quote:


Select. An item on the menu has been selected. The item position given will be the position in the menu, rather than the key pressed (unless the menu is a raw panel).
  • OnMenuSelect() in C++. A client index and item position are passed.
  • MenuAction_Select in SourcePawn. This action is always triggerable, whether requested or not.
    • param1: A client index.
    • param2: An item position.
From the wiki: https://wiki.alliedmods.net/Menu_API_(SourceMod)

You are using victim instead of param1 and killer instead of param2,
You would want to get the killer from StringToInt(info) and make "Yes" option to a string of the player index.

PHP Code:
new String:info[32];
new 
bool:found GetMenuItem(menuparam2infosizeof(info));
 
new 
killer StringToInt(info); 
PHP Code:
decl String:temp[16];
IntToString(killertempsizeof(temp));
AddMenuItem(PlayerDeathMenutemp"Yes"); 

Last edited by Pyro_; 02-04-2014 at 23:13.
Pyro_ is offline
Mr.Freeman
Senior Member
Join Date: Nov 2013
Location: Canada
Old 02-05-2014 , 00:32   Re: Player Death Menu Help
Reply With Quote #3

New to menus if you write it and it works Ill donate to you
Mr.Freeman is offline
Pyro_
Senior Member
Join Date: Oct 2013
Old 02-05-2014 , 01:11   Re: Player Death Menu Help
Reply With Quote #4

Untested:
PHP Code:
public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast

     
    new 
killer GetClientOfUserId(GetEventInt(event"attacker")); 
    new 
victim GetClientOfUserId(GetEventInt(event"userid")); 
     
    
GetClientName(killerkiller_namesizeof(killer_name)); 
     
    if(
killer == victim
    { 
        return; 
    } 
    else 
    { 
        new 
Handle:PlayerDeathMenu CreateMenu(PlayerDeathMenu_Handler); 
        
SetMenuTitle(PlayerDeathMenu"Was that a nice kill?"); 
        
        
decl String:temp[16];
        
IntToString(killertempsizeof(temp));

        
AddMenuItem(PlayerDeathMenutemp"Yes"); 
        
AddMenuItem(PlayerDeathMenu"no""No"); 
         
        
SetMenuExitBackButton(PlayerDeathMenutrue); 
        
DisplayMenu(PlayerDeathMenuvictim30); 
    } 
     
    return 
Plugin_Continue;


public 
PlayerDeathMenu_Handler(Handle:menuMenuAction:actionparam1param2

    switch (
action
    { 
        case 
MenuAction_End
        { 
            
CloseHandle(menu); 
        } 
        case 
MenuAction_Select:
        { 
            new 
String:info[32];
            new 
bool:found GetMenuItem(menuparam2infosizeof(info));

            if(!
StrEqual(info"no"))
            {
                new 
killer StringToInt(info);
                
CPrintToChat(killer"{mediumorchid}[Kill Info]{default} You have made a nice kill");
            }             
        } 
    } 

Pyro_ is offline
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 02:01.


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