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

[Help] Respawns in VIP Menu!


Post New Thread Reply   
 
Thread Tools Display Modes
ITGurra
Junior Member
Join Date: Nov 2015
Old 11-24-2015 , 12:46   Re: [Help] Respawns in VIP Menu!
Reply With Quote #11

Quote:
Originally Posted by VsX View Post
can You show me Your code?
Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>

#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;

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

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, "VIP Menu");
		AddMenuItem(VMenu, "GRAVON", "Gravity On");
		AddMenuItem(VMenu, "GRAVOFF", "Gravity Off");
		SetMenuExitButton(VMenu, true);
		DisplayMenu(VMenu, client, 0);
			
		return Plugin_Handled;
	}
	else
	{
		PrintToChat(client, "You are not a VIP member");
		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, "GRAVOFF"))
		{
			SetEntityGravity(client, 0.0);
			return;
		}	
		if(StrEqual(item, "GRAVON"))
		{
			SetEntityGravity(client, 0.5);
			return;
		}	
	}
	else if(action == MenuAction_End)
	{
		CloseHandle(VMenu)
	}
}
new g_PlayerRespawn[MAXPLAYERS+1];

public bool:OnClientConnect(client, String:Reject[], Len)
{

    if (IsPlayerGenericAdmin(client))
      g_PlayerRespawn[client] = 3
    else 
      g_PlayerRespawn[client] = 0;

}  

public Action:VipRespawn(client, args)
{
	if (IsPlayerGenericAdmin(client))
    {
			if (g_PlayerRespawn[client] > 0)
			{
				CS_RespawnPlayer(client);
				g_PlayerRespawn[client]--;
			}
			else
			{
				PrintToChat(client, "You have no respawns left.");
			}
		}
    }
public Action:PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	if(IsPlayerGenericAdmin(client))
	{
		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));
	}
	else
	{
		return Plugin_Handled;
	}
	return Plugin_Handled;
}
bool:IsPlayerGenericAdmin(client)
{
        return CheckCommandAccess(client, "generic_admin", ADMFLAG_RESERVATION, false);
}
ITGurra is offline
tommie113
AlliedModders Donor
Join Date: Oct 2013
Old 11-24-2015 , 13:34   Re: [Help] Respawns in VIP Menu!
Reply With Quote #12

Quote:
Originally Posted by VsX View Post
Code:
new g_PlayerRespawn[MAXPLAYERS+1];

public bool:OnClientConnect(client, String:Reject[], Len)
{

    if (IsPlayerGenericAdmin(client))
      g_PlayerRespawn[client] = 3
    else 
      g_PlayerRespawn[client] = 0;

}  

public Action:VipRespawn(client, args)
{
	if (IsPlayerGenericAdmin(client))
    {
			if (g_PlayerRespawn[client] > 0)
			{
				CS_RespawnPlayer(client);
				g_PlayerRespawn[client]--;
			}
			else
			{
				PrintToChat(client, "You have no respawns left.");
			}
		}
    }
Your code is quite odd in my opinion.
I would use OnClientConnected() rather then bool:OnClientConnect as you are not making use of it's functionality.
Also instead of checking everywhere if the player is generic admin just make sure it's a regadmcmd with generic flag.
No need to set respawn amount to 0 if player is not admin, cause if the player is not admin this value is processed nowhere.
Just set everyone's respawn amount to 3 without checks.

What you are doing is not wrong, these are just tips.
__________________
No longer taking requests due to lack of time and interrest.
Only helping out with minor things through forum.
tommie113 is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 11-24-2015 , 16:48   Re: [Help] Respawns in VIP Menu!
Reply With Quote #13

You need to return true the forward OnClientConnect. Otherwise connection will be rejected.
akcaliberg is offline
ITGurra
Junior Member
Join Date: Nov 2015
Old 11-30-2015 , 05:50   Re: [Help] Respawns in VIP Menu!
Reply With Quote #14

Quote:
Originally Posted by akcaliberg View Post
You need to return true the forward OnClientConnect. Otherwise connection will be rejected.
How do i do that?
ITGurra is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 11-30-2015 , 09:51   Re: [Help] Respawns in VIP Menu!
Reply With Quote #15

add:

return true;

at the end of your OnClientConnect function.
akcaliberg is offline
ITGurra
Junior Member
Join Date: Nov 2015
Old 12-01-2015 , 06:13   Re: [Help] Respawns in VIP Menu!
Reply With Quote #16

Quote:
Originally Posted by akcaliberg View Post
add:

return true;

at the end of your OnClientConnect function.
"You have no respawns left" is the only thing it says now. Restarted and reloaded, No respawns :/

I am admin, I have the flag :/

Last edited by ITGurra; 12-01-2015 at 06:14.
ITGurra is offline
akcaliberg
Senior Member
Join Date: Nov 2011
Location: Istanbul
Old 12-01-2015 , 09:40   Re: [Help] Respawns in VIP Menu!
Reply With Quote #17

Quote:
Originally Posted by ITGurra View Post
"You have no respawns left" is the only thing it says now. Restarted and reloaded, No respawns :/

I am admin, I have the flag :/
Make sure you have access to the command "generic_admin". (I am not sure if this command even exists.)

Make sure you have ADMFLAG_RESERVATION admin flag.

Also readjust your code as tommie113 said.
akcaliberg is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 12-01-2015 , 11:22   Re: [Help] Respawns in VIP Menu!
Reply With Quote #18

Think you need to do that check in OnClientPostAdminCheck

edit: and you might want to save steamid/respawns pairs, so people can't rejoin to get 3 respawns again once they've used them all

Last edited by Miu; 12-01-2015 at 11:24.
Miu 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 00:23.


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