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

[CS:GO] VIP menu spawn problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
andrept4
Senior Member
Join Date: Dec 2012
Location: Portugal
Old 06-23-2016 , 07:39   [CS:GO] VIP menu spawn problem
Reply With Quote #1

So i find this plugin in AlliedModders and i decided to correct it myself, but i found a problem that i can't find the solution.

The plugin is a VIP menu which has 5 choices, to have an m4a4+deagle in the round start, m4a1-S+deagle, awp+deagle or ak47+deagle. the 5th choice is to use the command !vipres for respawn.

The problem is that when vip's respawn, they can use the menu again, and they can respawn all the time.

Code:

Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>
#pragma tabsize 0
#define VERSION    "1.0"
#define SPEC        1
#define TEAM1        2
#define TEAM2        3

new g_VipStatus[MAXPLAYERS+1] = 0;
new Handle:g_Health;
new Handle:g_Money;
new Handle:g_Armor;
new g_PlayerRespawn[MAXPLAYERS+1] = 0;

public Plugin:myinfo =
{
    name = "VIP Plugin",
    author = "ITGurra",
    description = "Vip Plugin that gives access to gravity and respawn!",
    version = "2.0",
    url = ""
}

public OnPluginStart()
{
    HookEvent("player_spawn", PlayerSpawn);
    CreateConVar("sm_vip_version", VERSION, "VIP Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    g_Health = CreateConVar("sm_vip_health", "120", "HP On Spawn");
    g_Money = CreateConVar("sm_vip_money", "1200", "Money On Spawn");
    g_Armor = CreateConVar("sm_vip_armor", "120", "Armor On Spawn");
    RegConsoleCmd("sm_vip", VIP);
    RegConsoleCmd("sm_vipres", VipRespawn, "VIP Respawn");
    
    AutoExecConfig(true, "sm_vip");
}

public OnClientDisconnect(client)
{
    g_VipStatus[client] = 0;
}
public Action:VIP(client, args)
{
    if (IsPlayerGenericAdmin(client) )
    {

        new Handle:VMenu = CreateMenu(VipMenu);
        SetMenuTitle(VMenu, "[ HouseGaming ]\n.::VIP MENU::.");
        AddMenuItem(VMenu, "M4A4", "m4a4");
        AddMenuItem(VMenu, "M4A1", "m4a1")
        AddMenuItem(VMenu, "AK47", "ak47");
        AddMenuItem(VMenu, "AWP", "awp");
        AddMenuItem(VMenu, "RESPAWN", "+1 respawn");
        SetMenuExitButton(VMenu, true);
        DisplayMenu(VMenu, client, 0);
            
        return;
        
        return Plugin_Handled;
    }
    else
    {
        PrintToChat(client, "\x04[ HouseGaming ]\x01 Tu não es \x03VIP\x01.");
        return Plugin_Handled;
    }
}

public VipMenu(Handle:VMenu, MenuAction:action, client, position)
{
    if(action == MenuAction_Select)
    {
        decl String:item[20];
        GetMenuItem(VMenu, position, item, sizeof(item));
        
        if(StrEqual(item, "M4A4"))
        {
            GivePlayerItem(client, "weapon_m4a1");
            GivePlayerItem(client, "weapon_deagle");
            return;
        }   
        else if(StrEqual(item, "M4A1"))
        {
            GivePlayerItem(client, "weapon_m4a1_silencer");
            GivePlayerItem(client, "weapon_deagle");
            return;
        }
        else if(StrEqual(item, "AK47"))
        {
            GivePlayerItem(client, "weapon_ak47");
            GivePlayerItem(client, "weapon_deagle");
            return;
        }
        else if(StrEqual(item, "AWP"))
        {
            GivePlayerItem(client, "weapon_awp");
            GivePlayerItem(client, "weapon_deagle");
            return;
        }
        else if(StrEqual(item, "RESPAWN"))
        {
            g_PlayerRespawn[client] == 1;
            return;
        }
    }
    else if(action == MenuAction_End)
    {
        CloseHandle(VMenu)
    }
}


public Action:VipRespawn(client, args)
{
    if (IsPlayerGenericAdmin(client))
    {
        if (g_PlayerRespawn[client] > 0)
        {
            CS_RespawnPlayer(client);
            g_PlayerRespawn[client] == 0;
        }
        else
        {
            PrintToChat(client, "\x04[ HouseGaming ]\x01 Não tens mais \x04respawn's\x01 , espera te ao proximo mapa.");
        }
    }
}
public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"));

    if(GetClientTeam(client) > CS_TEAM_SPECTATOR && IsPlayerGenericAdmin(client))
    {
        if(GameRules_GetProp("m_totalRoundsPlayed") > 0) // show menu on third round ?
        {
            VIP(client, 0); // Use console command callback
        }

        SetEntProp(client, Prop_Data, "m_iHealth", GetConVarInt(g_Health));
        SetEntProp(client, Prop_Send, "m_iAccount", GetConVarInt(g_Money));
        SetEntProp(client, Prop_Send, "m_ArmorValue", GetConVarInt(g_Armor));
    }
    return Plugin_Handled;
}
bool:IsPlayerGenericAdmin(client)
{
    return CheckCommandAccess(client, "generic_admin", ADMFLAG_RESERVATION, false);
}
__________________

Last edited by andrept4; 06-23-2016 at 07:41.
andrept4 is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 06-23-2016 , 19:06   Re: [CS:GO] VIP menu spawn problem
Reply With Quote #2

We talked privately, but I'll post what I did for him here for others to learn from:
PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>
#pragma tabsize 0
#define VERSION    "1.0"
#define SPEC        1
#define TEAM1        2
#define TEAM2        3

new Handle:g_Health;
new 
Handle:g_Money;
new 
Handle:g_Armor;
new 
bool:g_VipStatus[MAXPLAYERS+1] = {true, ... };
new 
bool:g_PlayerRespawn[MAXPLAYERS+1] = {true, ... };
new 
bool:g_VipMenu[MAXPLAYERS 1] = { true, ... };

public 
Plugin:myinfo =
{
    
name "VIP Plugin",
    
author "ITGurra",
    
description "Vip Plugin that gives access to gravity and respawn!",
    
version "2.0",
    
url ""
}

public 
OnPluginStart()
{
    
HookEvent("player_spawn"PlayerSpawn);
    
CreateConVar("sm_vip_version"VERSION"VIP Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
g_Health CreateConVar("sm_vip_health""120""HP On Spawn");
    
g_Money CreateConVar("sm_vip_money""1200""Money On Spawn");
    
g_Armor CreateConVar("sm_vip_armor""120""Armor On Spawn");
    
RegConsoleCmd("sm_vip"VIP);
    
RegConsoleCmd("sm_vipres"VipRespawn"VIP Respawn");
   
    
AutoExecConfig(true"sm_vip");
}

public 
OnClientPostAdminCheck(client)
{
    
g_VipStatus[client] = true;
    
g_VipMenu[client] = true;
    
g_PlayerRespawn[client] = true;
}

public 
Action:VIP(clientargs)
{
    if (
IsPlayerGenericAdmin(client) )
    {

        new 
Handle:VMenu CreateMenu(VipMenu);
        
SetMenuTitle(VMenu"[ HouseGaming ]\n.::VIP MENU::.");
        
AddMenuItem(VMenu"M4A4""m4a4");
        
AddMenuItem(VMenu"M4A1""m4a1")
        
AddMenuItem(VMenu"AK47""ak47");
        
AddMenuItem(VMenu"AWP""awp");
        
AddMenuItem(VMenu"RESPAWN""+1 respawn");
        
SetMenuExitButton(VMenutrue);
        
DisplayMenu(VMenuclient0);
           
        return;
       
        return 
Plugin_Handled;
    }
    else
    {
        
PrintToChat(client"\x04[ HouseGaming ]\x01 Tu não es \x03VIP\x01.");
        return 
Plugin_Handled;
    }
}

public 
VipMenu(Handle:VMenuMenuAction:actionclientposition)
{
    if(
action == MenuAction_Select)
    {
        
decl String:item[20];
        
GetMenuItem(VMenupositionitemsizeof(item));
       
        if(
StrEqual(item"M4A4"))
        {
            
GivePlayerItem(client"weapon_m4a1");
            
GivePlayerItem(client"weapon_deagle");
            return;
        }  
        else if(
StrEqual(item"M4A1"))
        {
            
GivePlayerItem(client"weapon_m4a1_silencer");
            
GivePlayerItem(client"weapon_deagle");
            return;
        }
        else if(
StrEqual(item"AK47"))
        {
            
GivePlayerItem(client"weapon_ak47");
            
GivePlayerItem(client"weapon_deagle");
            return;
        }
        else if(
StrEqual(item"AWP"))
        {
            
GivePlayerItem(client"weapon_awp");
            
GivePlayerItem(client"weapon_deagle");
            return;
        }
        else if(
StrEqual(item"RESPAWN"))
        {
            
CS_RespawnPlayer(client);
            
g_PlayerRespawn[client] = false;
            return;
        }
    }
    else if(
action == MenuAction_End)
    {
        
CloseHandle(VMenu)
    }
}

public 
Action:VipRespawn(clientargs)
{
    if (
IsPlayerGenericAdmin(client))
    {
        if (
g_PlayerRespawn[client] == true)
        {
            
CS_RespawnPlayer(client);
            
g_PlayerRespawn[client] = false;
        }
        else
        {
            
PrintToChat(client"\x04[ HouseGaming ]\x01 Não tens mais \x04respawn's\x01 , espera te ao proximo mapa.");
        }
    }
}

public 
Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));

    if(
GetClientTeam(client) > CS_TEAM_SPECTATOR && IsPlayerGenericAdmin(client))
    {
        if((
g_VipMenu[client] == true) && (GameRules_GetProp("m_totalRoundsPlayed") > 0)) // show menu on third round ?
        
{
            
g_VipMenu[client] = false;
            
VIP(client0); // Use console command callback
        
}

        
SetEntProp(clientProp_Data"m_iHealth"GetConVarInt(g_Health));
        
SetEntProp(clientProp_Send"m_iAccount"GetConVarInt(g_Money));
        
SetEntProp(clientProp_Send"m_ArmorValue"GetConVarInt(g_Armor));
    }
    return 
Plugin_Handled;
}

bool:IsPlayerGenericAdmin(client)
{
    return 
CheckCommandAccess(client"generic_admin"ADMFLAG_RESERVATIONfalse);


Last edited by Maxximou5; 06-23-2016 at 19:21. Reason: fixed some errors
Maxximou5 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 16:53.


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