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

[CS:GO] Respawn Players Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
andrept4
Senior Member
Join Date: Dec 2012
Location: Portugal
Old 07-13-2018 , 08:22   [CS:GO] Respawn Players Menu
Reply With Quote #1

Hello guys, I made a plugin that creates a menu for admins that respawns players, I can't really test it so I would like to take advantage of your knowledge to tell me if you think that it works or even test it, thank you anyway

Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <menus>
#include <adminmenu>

public Plugin myinfo = {
  name = "[PUNT] Respawn Menu",
  author = "GelaPT",
  description = "Reviver um jogador ou enviar um jogador vivo para o spawn",
  version = "1.0",
  url = ""
}

public OnPluginStart() {
  RegAdminCmd("sm_reviver", sm_reviver, ADMFLAG_SLAY)
}

public Action sm_reviver(int client, int args) {
  openMenu(client);

  return Plugin_Handled;
}

public void openMenu(int client) {
  Menu menu = new Menu(RespawnMenuHandler, MENU_ACTIONS_ALL);

  menu.SetTitle("Reviver jogador:");
  AddTargetsToMenu(menu, 0, true, false);
  menu.ExitButton = true;
  menu.Display(client, 0);

}

public int RespawnMenuHandler(Menu menu, MenuAction action, int client, int param2) {
  switch(action) {
    case MenuAction_Start:{}
    case MenuAction_Display:
    {
      Panel panel = view_as<Panel>(param2);
      panel.SetTitle("Reviver Jogador");
    }
    case MenuAction_Select:
    {
      openMenu(client);
      char info[MAX_NAME_LENGTH];
      if(menu.GetItem(param2, info, sizeof(info))) {
        int target = GetClientOfUserId(StringToInt(info));

        CS_RespawnPlayer(target);
      }
    }
    case MenuAction_End:
    {
      delete menu;
    }
    case MenuAction_Cancel:
    {
      delete menu;
    }
    case MenuAction_DrawItem:
    {
      int style;
      char info[32];
      menu.GetItem(param2, info, sizeof(info), style);

      return style;
    }
  }

  return 0;
}
__________________

Last edited by andrept4; 07-13-2018 at 08:23.
andrept4 is offline
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 07-13-2018 , 17:57   Re: [CS:GO] Respawn Players Menu
Reply With Quote #2

My notes:
1) This is menus.inc and adminmenu.inc are included by sourcemod.inc
sourcemod.inc are included by compiler by default
2) Don't mix syntax
Code:
public OnPluginStart() // Old syntax
public void OnPluginStart()
3) Menus have exitbutton true by default
Code:
menu.ExitButton = true;
4) Remove it?
Code:
case MenuAction_Start:{}
5) Just use menu.SetTitle(), but for that you need to update it? You can just set it on creation like you did.
Code:
case MenuAction_Display:
{
    Panel panel = view_as<Panel>(param2);
    panel.SetTitle("Reviver Jogador");
}
6) This will cause error (invalid handle) when menu canceled.
Close menu only in End action.
PHP Code:
case MenuAction_Cancel:
{
    
delete menu;
}
case 
MenuAction_End:
{
    
delete menu;

7) you can pass NULL_STRING and 0 for info buffer. (Again, why you use this callback action and why 'MENU_ACTIONS_ALL', may be just remove?)
PHP Code:
case MenuAction_DrawItem:
{
    
int style;
    
menu.GetItem(param2NULL_STRING0style);

    return 
style;

Kailo is offline
andrept4
Senior Member
Join Date: Dec 2012
Location: Portugal
Old 07-13-2018 , 18:09   Re: [CS:GO] Respawn Players Menu
Reply With Quote #3

Quote:
Originally Posted by Kailo View Post
My notes:
1) This is menus.inc and adminmenu.inc are included by sourcemod.inc
sourcemod.inc are included by compiler by default
2) Don't mix syntax
Code:
public OnPluginStart() // Old syntax
public void OnPluginStart()
3) Menus have exitbutton true by default
Code:
menu.ExitButton = true;
4) Remove it?
Code:
case MenuAction_Start:{}
5) Just use menu.SetTitle(), but for that you need to update it? You can just set it on creation like you did.
Code:
case MenuAction_Display:
{
    Panel panel = view_as<Panel>(param2);
    panel.SetTitle("Reviver Jogador");
}
6) This will cause error (invalid handle) when menu canceled.
Close menu only in End action.
PHP Code:
case MenuAction_Cancel:
{
    
delete menu;
}
case 
MenuAction_End:
{
    
delete menu;

7) you can pass NULL_STRING and 0 for info buffer. (Again, why you use this callback action and why 'MENU_ACTIONS_ALL', may be just remove?)
PHP Code:
case MenuAction_DrawItem:
{
    
int style;
    
menu.GetItem(param2NULL_STRING0style);

    return 
style;

Thank you alot for the help
__________________
andrept4 is offline
Reply


Thread Tools
Display Modes

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 20:46.


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