AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugin/Gameplay Ideas and Requests (https://forums.alliedmods.net/forumdisplay.php?f=60)
-   -   [vip menu plugin] (https://forums.alliedmods.net/showthread.php?t=328000)

lemmon_cs 10-20-2020 12:06

[vip menu plugin]
 
I want a plugin for vip , a gunmenu like this
flag needed CUSTOM1 , can be opened only on 3th round and the menu guns are AWP , AK , M4A4 , once you selected a weapon from menu you can't open the menu until the next round starts , and a chat message "You used VIP menu this round" , and for nonvip users chat message "You are not vip" and "This menu can be oppened only on 3th round" , thanks

SSheriFF 10-20-2020 14:25

Re: [vip menu plugin]
 
Quote:

Originally Posted by lemmon_cs (Post 2722015)
I want a plugin for vip , a gunmenu like this
flag needed CUSTOM1 , can be opened only on 3th round and the menu guns are AWP , AK , M4A4 , once you selected a weapon from menu you can't open the menu until the next round starts , and a chat message "You used VIP menu this round" , and for nonvip users chat message "You are not vip" and "This menu can be oppened only on 3th round" , thanks

PHP Code:

#pragma semicolon 1

#define DEBUG

#include <sourcemod>
#include <sdktools>

#pragma newdecls required
int g_iRounds 0;
bool g_bAlreadyUsed[MAXPLAYERS 1] =  { false };
public 
Plugin myinfo 
{
    
name "VIP Gun Menu",
    
author "SheriF",
    
description "",
    
version "1.0",
    
url ""
};

public 
void OnPluginStart()
{
    
HookEvent("round_start"OnRoundStart);
    
RegAdminCmd("sm_vipguns"Command_VIPADMFLAG_CUSTOM1);
}
public 
void OnMapEnd()
{
    
g_iRounds 0;
}
public 
Action OnRoundStart(Event eventchar[] namebool dontBroadcast)
{
    
g_iRounds++;
    for(
int i 1<= MaxClients;i++)
    {
        if(
IsClientInGame(i)&&!IsFakeClient(i))
            
g_bAlreadyUsed[i] = false;
    }    
}
public 
Action Command_VIP(int clientint args)
{
    if(
IsClientInGame(client) && !IsFakeClient(client))
    {
        if(
g_iRounds<3)
            
PrintToChat(client"This menu can be oppened only on 3th round");
        else if(!
IsPlayerAlive(client))
            
PrintToChat(client"This menu can be oppened only when you are alive");
        else if(
g_bAlreadyUsed[client])
            
PrintToChat(client"You used VIP menu this round");
        else
        {
            
g_bAlreadyUsed[client] = true;
            
VIPMenu(client);
        }
    }
}
void VIPMenu(int client)
{
    
Menu menu = new Menu(menuHandler_VipMenu);
    
menu.SetTitle("Choose a weapon");
    
menu.AddItem("weapon_awp","Awp");
    
menu.AddItem("weapon_ak47","Ak47");
    
menu.AddItem("weapon_m4a1","M4A4");
    
menu.ExitButton true;
    
menu.Display(clientMENU_TIME_FOREVER);
}
public 
int menuHandler_VipMenu(Menu menuMenuAction actionint clientint itemNUM)
{
    if (
action == MenuAction_Select)
    {
        
char sWeapon[32];
        
menu.GetItem(itemNUMsWeaponsizeof(sWeapon));
        
GivePlayerItem(clientsWeapon);
        if(
StrContains(sWeapon,"m4a1")!=-1)
            
PrintToChat(client"You got a M4A4");
        else
            
PrintToChat(client"You got an A%s"sWeapon[8]);
    }



lemmon_cs 10-20-2020 15:03

Re: [vip menu plugin]
 
One problem , if i open the menu and then close it without choosing a weapon i can't open it again and it says i already chose a weapon , i want the open to be open as many times as you want , only when you select and get a weapon you can't open it again and the message popup in chat

Drixevel 10-21-2020 01:57

Re: [vip menu plugin]
 
Code:

#pragma semicolon 1

#define DEBUG

#include <sourcemod>
#include <sdktools>

#pragma newdecls required
int g_iRounds = 0;
bool g_bAlreadyUsed[MAXPLAYERS + 1] =  { false };
public Plugin myinfo =
{
    name = "VIP Gun Menu",
    author = "SheriF",
    description = "",
    version = "1.0",
    url = ""
};

public void OnPluginStart()
{
    HookEvent("round_start", OnRoundStart);
    RegAdminCmd("sm_vipguns", Command_VIP, ADMFLAG_CUSTOM1);
}
public void OnMapEnd()
{
    g_iRounds = 0;
}
public Action OnRoundStart(Event event, char[] name, bool dontBroadcast)
{
    g_iRounds++;
    for(int i = 1; i <= MaxClients;i++)
    {
        if(IsClientInGame(i)&&!IsFakeClient(i))
            g_bAlreadyUsed[i] = false;
    }   
}
public Action Command_VIP(int client, int args)
{
    if(IsClientInGame(client) && !IsFakeClient(client))
    {
        if(g_iRounds<3)
            PrintToChat(client, "This menu can be oppened only on 3th round");
        else if(!IsPlayerAlive(client))
            PrintToChat(client, "This menu can be oppened only when you are alive");
        else if(g_bAlreadyUsed[client])
            PrintToChat(client, "You used VIP menu this round");
        else
            VIPMenu(client);
    }
}
void VIPMenu(int client)
{
    Menu menu = new Menu(menuHandler_VipMenu);
    menu.SetTitle("Choose a weapon");
    menu.AddItem("weapon_awp","Awp");
    menu.AddItem("weapon_ak47","Ak47");
    menu.AddItem("weapon_m4a1","M4A4");
    menu.ExitButton = true;
    menu.Display(client, MENU_TIME_FOREVER);
}
public int menuHandler_VipMenu(Menu menu, MenuAction action, int client, int itemNUM)
{
    if (action == MenuAction_Select)
    {
        char sWeapon[32];
        menu.GetItem(itemNUM, sWeapon, sizeof(sWeapon));
        GivePlayerItem(client, sWeapon);
        if(StrContains(sWeapon,"m4a1")!=-1)
            PrintToChat(client, "You got a M4A4");
        else
            PrintToChat(client, "You got an A%s", sWeapon[8]);
        g_bAlreadyUsed[client] = true;
    }
}

You can just move the g_bAlreadyUsed[client] = true; to the menu callback then.

lemmon_cs 10-21-2020 14:42

Re: [vip menu plugin]
 
Now it's ok , but i have one more problem , works only on first half , on second half i can open the vipmenu from pistol round , not from 3 round , you can get weapon on pistol round from second half


All times are GMT -4. The time now is 02:41.

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