Raised This Month: $ Target: $400
 0% 

ClientCommand


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 05-19-2012 , 11:22   ClientCommand
Reply With Quote #1

Hey, i meaning to release my Bunnyhop commands v2.5.0 Plugin.
and im stuck on 2 things before release.
1. Clientcommand does nothing:
Code:
ClientCommand(client, "sm_lg");
Im using clientcommand because i dont wanna make a HUGEE Code.

2. Its not working:
Code:
			DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
I mean that its not displaying the same menu again.

The full code:

*Note: i will release the full version with some changes.
Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#define PLUGIN_VERSION "2.5.0"

#pragma semicolon 1

new bool:allow[MAXPLAYERS+1];
new bool:tele_saved[MAXPLAYERS+1] = {false, ...};
new Float:checkpoint[MAXPLAYERS+1][3];
new bool:tele_saved2[MAXPLAYERS+1] = {false, ...};
new Float:checkpoint2[MAXPLAYERS+1][3];
new Handle:sm_bhopcommands_weapons = INVALID_HANDLE;
new Handle:sm_bhopcommands_version = INVALID_HANDLE;

 
public Plugin:myinfo =
{
	name = "Bunnyhop Commands",
	author = "TimeBomb",
	description = "Bunnyhop Commands.",
	version = PLUGIN_VERSION,
	url = ""
};
 
public OnPluginStart()
{
	RegConsoleCmd("sm_superlowgrav", Command_SuperLowgravity, "Super Low Gravity for Client.");
	RegConsoleCmd("sm_lowgrav", Command_Lowgravity, "Low Gravity for Client.");
	RegConsoleCmd("sm_highgrav", Command_Highgravity, "High Gravity for Client..");
	RegConsoleCmd("sm_normalgrav", Command_Normalgravity, "Normal Gravity for Client.");
	RegConsoleCmd("sm_superlowgravity", Command_SuperLowgravity, "Super Low Gravity for Client.");
	RegConsoleCmd("sm_lowgravity", Command_Lowgravity, "Low Gravity for Client.");
	RegConsoleCmd("sm_highgravity", Command_Highgravity, "High Gravity for Client.");
	RegConsoleCmd("sm_normalgravity", Command_Normalgravity, "Normal Gravity for Client.");
	RegConsoleCmd("sm_slg", Command_SuperLowgravity, "Super Low Gravity for Client.");
	RegConsoleCmd("sm_lg", Command_Lowgravity, "Low Gravity for Client.");
	RegConsoleCmd("sm_hg", Command_Highgravity, "High Gravity for Client.");
	RegConsoleCmd("sm_ng", Command_Normalgravity, "Normal Gravity for Client.");
	RegConsoleCmd("sm_r", Command_reviver, "Respawning Client, Usable for Restarting the Map.");
	RegConsoleCmd("sm_restart", Command_reviver, "Respawning Client, Usable for Restarting the Map.");
	RegConsoleCmd("sm_commands", Command_Commands, "Commands Menu.");
	RegConsoleCmd("sm_bhop", Command_Commands, "Commands Menu.");
	RegConsoleCmd("sm_comms", Command_Commands, "Commands Menu.");
	RegConsoleCmd("sm_guns", Command_Guns, "Guns Menu.");
	RegConsoleCmd("sm_w", Command_Guns, "Guns Menu.");
	RegConsoleCmd("sm_weapons", Command_Guns, "Guns Menu.");
	RegConsoleCmd("sm_knife", Command_knife, "Spawns a Knife, Usable to Maps without Knifes.");
	RegConsoleCmd("sm_kn", Command_knife, "Spawns a Knife, For a Fat lazy Man, Usable to Maps without Knifes.");
	RegConsoleCmd("sm_usp", Command_usp, "Spawns a Usp Pistol.");
	RegConsoleCmd("sm_awp", Command_awp, "Spawns a AWP Sniper Rifle.");
	RegConsoleCmd("sm_deagle", Command_deagle, "Spawns a Desert Eagle Pistol.");
	RegConsoleCmd("sm_scout", Command_scout, "Spawns a Scout Sniper Rifle.");
	RegConsoleCmd("sm_save1", Command_save1, "Saving a Checkpoint on The Client Position.");
	RegConsoleCmd("sm_tele1", Command_tele1, "Teleport to your Saved Checkpoint [1].");
	RegConsoleCmd("sm_s1", Command_save1, "Saving a Checkpoint on The Client Position [1].");
	RegConsoleCmd("sm_t1", Command_tele1, "Teleport to your Saved Checkpoint. [1]");
	RegConsoleCmd("sm_save2", Command_save2, "Saving a Checkpoint on The Client Position. [2]");
	RegConsoleCmd("sm_tele2", Command_tele2, "Teleport to your Saved Checkpoint. [2]");
	RegConsoleCmd("sm_s2", Command_save2, "Saving a Checkpoint on The Client Position. [2]");
	RegConsoleCmd("sm_t2", Command_tele2, "Teleport to your Saved Checkpoint. [2]");
	RegConsoleCmd("sm_cp", Command_cp, "CheckPoints Menu.");
	RegConsoleCmd("sm_checkpoints", Command_cp, "CheckPoints Menu.");
	RegConsoleCmd("sm_gravitycommands", Command_gravity, "Gravity Commands.");
	RegConsoleCmd("sm_grav", Command_gravity, "Gravity Commands.");
	sm_bhopcommands_weapons = CreateConVar("sm_bhopcommands_weapons", "1", "Enable Weapon Spawning? [1 - True] [0 - False].");
	sm_bhopcommands_version = CreateConVar("sm_bhopcommands_version", PLUGIN_VERSION, "Bunnyhop Commands Version.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
	SetConVarInt(FindConVar("sv_enablebunnyhopping"), 1);
	SetConVarInt(FindConVar("sv_enableboost"), 1);
	SetConVarInt(FindConVar("sv_airaccelerate"), 99999999);
	CreateTimer(60.0, ad, _, TIMER_REPEAT);
}
	
public OnMapStart()
{	
	for(new i = 1; i <= MaxClients; i++)
	{
		allow[i]=true;
	}
}	

public Action:ad(Handle:SuperTimer, any:data)
{
	decl String:version[16];
	GetConVarString(sm_bhopcommands_version, version, sizeof(version));
	PrintToChatAll("\x04[SM]\x01 This Server is Running Bunnyhop Commands %s.", version);
}

public Action:Command_Lowgravity(client, args)
{
	PrintToChat(client, "\x04[SM]\x01 You have Just Changed Your Gravity to Lower!");
	SetEntityGravity(client, 0.5);
	return Plugin_Handled;
}
	
public Action:Command_Highgravity(client, args)
{
	PrintToChat(client, "\x04[SM]\x01 You have Just Changed Your Gravity to Higher!");
	SetEntityGravity(client, 1.5);
	return Plugin_Handled;
}
	
public Action:Command_Normalgravity(client, args)
{
	PrintToChat(client, "\x04[SM]\x01 You have Just Changed Your Gravity to Normal!");
	SetEntityGravity(client, 1.0);
	return Plugin_Handled;
}
	
public Action:Command_SuperLowgravity(client, args)
{
	PrintToChat(client, "\x04[SM]\x01 You have Just Changed Your Gravity to \x03SUPERLOWGRAVITYYY!");
	SetEntityGravity(client, 0.2);
	return Plugin_Handled;
}
	
public Action:Command_Commands(client, args)
{
	new Handle:CommandsMenu = CreateMenu(MenuHandler_CommandsMenu);
	SetMenuTitle(CommandsMenu, "Commands:");
	AddMenuItem(CommandsMenu, "commands", "!commands / !commds / !bhop - This Menu", ITEMDRAW_DISABLED);
	AddMenuItem(CommandsMenu, "gravity", "!gravitycommands / !grav - Gravity Menu");
	AddMenuItem(CommandsMenu, "guns", "!guns - Guns/Weapons Menu");
	AddMenuItem(CommandsMenu, "revive", "!r / !restart - Respawning Yourself");
	AddMenuItem(CommandsMenu, "checkpoints", "!cp / !checkpoints - CheckPoints Menu");
	DisplayMenu(CommandsMenu, client, MENU_TIME_FOREVER);
	return Plugin_Handled;
}

public MenuHandler_CommandsMenu(Handle:CommandsMenu, MenuAction:action, iClient, iMenuItem)
{
	new client = iClient;
	if (action == MenuAction_Select)
	{
		decl String:strSelection[4];
		GetMenuItem(CommandsMenu, iMenuItem, strSelection, sizeof(strSelection));
		if(strcmp(strSelection, "gravity", false) == 0)
		{
			ClientCommand(client, "sm_grav");
		}
		else if(strcmp(strSelection, "guns", false) == 0)
		{
			ClientCommand(client, "sm_guns");
		}
		else if(strcmp(strSelection, "revive", false) == 0)
		{
			ClientCommand(client, "sm_r");
		}
		else if(strcmp(strSelection, "checkpoints", false) == 0)
		{
			ClientCommand(client, "sm_cp");
		}
	}
	else if (action == MenuAction_End)
	{
		CloseHandle(CommandsMenu);
	}
}

public Action:Command_reviver(client, args)
{
	PrintToChat(client, "\x04[SM]\x01 Have Fun!");
	CS_RespawnPlayer(client);
	return Plugin_Handled;
}

public Action:Command_Guns(client, args)
{
	new Handle:WeaponMenu = CreateMenu(MenuHandler_SelectWeapon);
	SetMenuTitle(WeaponMenu, "Choose Weapon");
	SetMenuExitButton(WeaponMenu, true);
	AddMenuItem(WeaponMenu, "scout", "Scout [!scout]");
	AddMenuItem(WeaponMenu, "awp", "AWP [!awp]");
	AddMenuItem(WeaponMenu, "deagle", "Deagle [!deagle]");
	AddMenuItem(WeaponMenu, "usp", "USP [!usp]");
	AddMenuItem(WeaponMenu, "knife", "Knife [!knife/!kn]");
	DisplayMenu(WeaponMenu, client, MENU_TIME_FOREVER);
	return Plugin_Handled;
}

public MenuHandler_SelectWeapon(Handle:WeaponMenu, MenuAction:action, iClient, iMenuItem)
{
	new client = iClient;
	if (action == MenuAction_Select)
	{
		decl String:strSelection[4];
		GetMenuItem(WeaponMenu, iMenuItem, strSelection, sizeof(strSelection));
		if(strcmp(strSelection, "scout", false) == 0)
		{
			ClientCommand(client, "sm_scout");
		}
		else if(strcmp(strSelection, "awp", false) == 0)
		{
			ClientCommand(client, "sm_awp");
		}
		else if(strcmp(strSelection, "deagle", false) == 0)
		{
			ClientCommand(client, "sm_deagle");
		}
		else if(strcmp(strSelection, "usp", false) == 0)
		{
			ClientCommand(client, "sm_usp");
		}
		else if(strcmp(strSelection, "knife", false) == 0)
		{
			ClientCommand(client, "sm_knife");
		}
	}
	else if (action == MenuAction_End)
	{
		CloseHandle(WeaponMenu);
	}
}

public Action:Command_cp(client, args)
{
	new Handle:CPMenu = CreateMenu(MenuHandler_CPMenu);
	SetMenuTitle(CPMenu, "Check Points");
	SetMenuExitButton(CPMenu, true);
	AddMenuItem(CPMenu, "save1", "Save 1 - [!save1]");
	AddMenuItem(CPMenu, "tele1", "Tele 1 - [!tele1]");
	AddMenuItem(CPMenu, "empty1", " ", ITEMDRAW_DISABLED);
	AddMenuItem(CPMenu, "empty2", " ", ITEMDRAW_DISABLED);
	AddMenuItem(CPMenu, "save2", "Save 2 - [!save2]");
	AddMenuItem(CPMenu, "tele2", "Tele 2 - [!tele2]");
	DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
	return Plugin_Handled;
}

public MenuHandler_CPMenu(Handle:CPMenu, MenuAction:action, iClient, iMenuItem)
{
	new client = iClient;
	if (action == MenuAction_Select)
	{
		decl String:strSelection[4];
		GetMenuItem(CPMenu, iMenuItem, strSelection, sizeof(strSelection));
		if(strcmp(strSelection, "save", false) == 0)
		{
			ClientCommand(client, "sm_save1");
			DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
		}
		else if(strcmp(strSelection, "tele", false) == 0)
		{
			ClientCommand(client, "sm_tele1");
			DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
		}
		else if(strcmp(strSelection, "save2", false) == 0)
		{
			ClientCommand(client, "sm_save2");
			DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
		}
		else if(strcmp(strSelection, "save2", false) == 0)
		{
			ClientCommand(client, "sm_tele2");
			DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
		}
	}
	else if (action == MenuAction_End)
	{
		CloseHandle(CPMenu);
	}
}

public Action:Command_gravity(client, args)
{
	new Handle:GravityMenu = CreateMenu(MenuHandler_SelectGravity);
	SetMenuTitle(GravityMenu, "Choose Gravity");
	SetMenuExitButton(GravityMenu, true);
	AddMenuItem(GravityMenu, "lowgrav", "Low Gravity [!lg/!lowgrav/!lowgravity]");
	AddMenuItem(GravityMenu, "highgrav", "High Gravity [!hg/!highgrav/!highgravity]");
	AddMenuItem(GravityMenu, "normalgrav", "Normal Gravity [!ng/!normalgrav/!normalgravity]");
	AddMenuItem(GravityMenu, "superlowgrav", "Super Low Gravity [!slg/!superlowgrav/!superlowgravity]");
	DisplayMenu(GravityMenu, client, MENU_TIME_FOREVER);
	return Plugin_Handled;
}

public MenuHandler_SelectGravity(Handle:GravityMenu, MenuAction:action, iClient, iMenuItem)
{
	new client = iClient;
	if (action == MenuAction_Select)
	{
		decl String:strSelection[4];
		GetMenuItem(GravityMenu, iMenuItem, strSelection, sizeof(strSelection));
		if(strcmp(strSelection, "lowgrav", false) == 0)
		{
			ClientCommand(client, "sm_lg");
		}
		else if(strcmp(strSelection, "highgrav", false) == 0)
		{
			ClientCommand(client, "sm_hg");
		}
		else if(strcmp(strSelection, "normalgrav", false) == 0)
		{
			ClientCommand(client, "sm_ng");
		}
		else if(strcmp(strSelection, "superlowgrav", false) == 0)
		{
			ClientCommand(client, "sm_slg");
		}
	}
	else if (action == MenuAction_End)
	{
		CloseHandle(GravityMenu);
	}
}
	
public Action:Command_knife(client,args)
{
	if(GetConVarBool(sm_bhopcommands_weapons))
	{
		if(allow[client]==true)
		{
			GivePlayerItem(client, "weapon_knife");
			allow[client]=false;
			CreateTimer(30.0, Action_weaponspawner, client, TIMER_FLAG_NO_MAPCHANGE);
		}
		else
		{
			PrintToChat(client, "\x04[SM]\x01 You must wait 30 seconds between Spawning Weapons, Abuse will get you banned.");
		}
		
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Weapon Spawning is not Enabled!");
	}
	return Plugin_Handled;
}
	
public Action:Command_usp(client,args)
{
	if(GetConVarBool(sm_bhopcommands_weapons))
	{
		if(allow[client]==true)
		{
			GivePlayerItem(client, "weapon_usp");
			allow[client]=false;
			CreateTimer(30.0, Action_weaponspawner, client, TIMER_FLAG_NO_MAPCHANGE);
		}
		else
		{
			PrintToChat(client, "\x04[SM]\x01 You must wait 30 seconds between Spawning Weapons, Abuse will get you banned.");
		}
		
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Weapon Spawning is not Enabled!");
	}
	return Plugin_Handled;
}

public Action:Command_deagle(client,args)
{
	if(GetConVarBool(sm_bhopcommands_weapons))
	{
		if(allow[client]==true)
		{
			GivePlayerItem(client, "weapon_deagle");
			allow[client]=false;
			CreateTimer(30.0, Action_weaponspawner, client, TIMER_FLAG_NO_MAPCHANGE);
		}
		else
		{
			PrintToChat(client, "\x04[SM]\x01 You must wait 30 seconds between Spawning Weapons, Abuse will get you banned.");
		}
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Weapon Spawning is not Enabled!");
	}
	return Plugin_Handled;
}

public Action:Command_awp(client,args)
{
	if(GetConVarBool(sm_bhopcommands_weapons))
	{
		if(allow[client]==true)
		{
			GivePlayerItem(client, "weapon_awp");
			allow[client]=false;
			CreateTimer(30.0, Action_weaponspawner, client, TIMER_FLAG_NO_MAPCHANGE);
		}
		else
		{
			PrintToChat(client, "\x04[SM]\x01 You must wait 30 seconds between Spawning Weapons, Abuse will get you banned.");
		}
		
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Weapon Spawning is not Enabled!");
	}
	return Plugin_Handled;
}

public Action:Command_scout(client,args)
{
	if(GetConVarBool(sm_bhopcommands_weapons))
	{
		if(allow[client]==true)
		{
			GivePlayerItem(client, "weapon_scout");
			allow[client]=false;
			CreateTimer(30.0, Action_weaponspawner, client, TIMER_FLAG_NO_MAPCHANGE);
		}
		else
		{
			PrintToChat(client, "\x04[SM]\x01 You must wait 30 seconds between Spawning Weapons, Abuse will get you banned.");
		}
		
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Weapon Spawning is not Enabled!");
	}
	return Plugin_Handled;
}

public Action:Action_weaponspawner(Handle:timer, any:client)
{
	allow[client]=true;
}

public Action:Command_save1(client, args)
{
	GetEntPropVector(client, Prop_Send, "m_vecOrigin", checkpoint[client]);
	tele_saved[client] = true;
	PrintToChat(client, "\x04[SM]\x01 CheckPoint [1] Saved.");
	return Plugin_Handled;
}

public Action:Command_tele1(client, args)
{
	if(tele_saved[client])
	{
		TeleportEntity(client, checkpoint[client], NULL_VECTOR, NULL_VECTOR);
		PrintToChat(client, "\x04[SM]\x01 Teleported to Checkpoint [1].");
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 You Have to Place a Checkpoint [1] First, Type !s1/!save1 for that.)");
	}
	return Plugin_Handled;
}

public Action:Command_save2(client, args)
{
	GetEntPropVector(client, Prop_Send, "m_vecOrigin", checkpoint2[client]);
	tele_saved2[client] = true;
	PrintToChat(client, "\x04[SM]\x01 CheckPoint [2] Saved.");
	return Plugin_Handled;
}

public Action:Command_tele2(client, args)
{
	if(tele_saved2[client])
	{
		TeleportEntity(client, checkpoint2[client], NULL_VECTOR, NULL_VECTOR);
		PrintToChat(client, "\x04[SM]\x01 Teleported to Checkpoint [2].");
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 You Have to Place a Checkpoint [2] First, Type !s2/!save2 for that.)");
	}
	return Plugin_Handled;
}
__________________
retired

Last edited by shavit; 05-19-2012 at 11:24.
shavit is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-19-2012 , 11:37   Re: ClientCommand
Reply With Quote #2

Quote:
Originally Posted by shavit View Post
1. Clientcommand does nothing:
Code:
ClientCommand(client, "sm_lg");
Im using clientcommand because i dont wanna make a HUGEE Code.
As the documentation for ClientCommand says:
Quote:
Executes a client command. Note that this will not work on clients unless they have cl_restrict_server_commands set to 0.
You can, however, use FakeClientCommand which makes the server think a client used a command.

Quote:
Originally Posted by shavit View Post
2. Its not working:
Code:
			DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
I mean that its not displaying the same menu again.
Of course not, you have this in the menu's handler code:

PHP Code:
    else if (action == MenuAction_End)
    {
        
CloseHandle(CPMenu);
    } 
Once a menu handle is closed, that menu is deleted.

If you want to keep showing clients the same command, simply never close its handle.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-19-2012 at 11:37.
Powerlord is offline
ZzZombo
Member
Join Date: May 2012
Location: Ravenholm
Old 05-19-2012 , 12:02   Re: ClientCommand
Reply With Quote #3

Quote:
Originally Posted by Powerlord View Post
As the documentation for ClientCommand says:

You can, however, use FakeClientCommand which makes the server think a client used a command.
At least in Left 4 Dead ClientCommand() works on real clients while FakeClientCommand() doesn't.
ZzZombo is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 05-19-2012 , 12:52   Re: ClientCommand
Reply With Quote #4

Quote:
Originally Posted by Powerlord View Post
As the documentation for ClientCommand says:

You can, however, use FakeClientCommand which makes the server think a client used a command.



Of course not, you have this in the menu's handler code:

PHP Code:
    else if (action == MenuAction_End)
    {
        
CloseHandle(CPMenu);
    } 
Once a menu handle is closed, that menu is deleted.

If you want to keep showing clients the same command, simply never close its handle.
Thank you, how can i add a line like:
Code:
AddMenuItem(CPMenu, "empty1", " ", ITEMDRAW_DISABLED);
But the number before of it will not be showen?
__________________
retired
shavit is offline
TrueSurvivor
Member
Join Date: Jun 2010
Old 05-19-2012 , 17:57   Re: ClientCommand
Reply With Quote #5

Quote:
Originally Posted by ZzZombo View Post
At least in Left 4 Dead ClientCommand() works on real clients while FakeClientCommand() doesn't.
FakeClientCommand works just fine on real clients and fake clients in L4D2, unlikely to be limited on just L4D1..
But I'll take your word for it. xD
TrueSurvivor is offline
ZzZombo
Member
Join Date: May 2012
Location: Ravenholm
Old 05-19-2012 , 20:40   Re: ClientCommand
Reply With Quote #6

When I tried to use FakeClientCommand() to force a player to -attack the game said that it's an unknown command but ClientCommand() worked perfect.
ZzZombo is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-19-2012 , 20:50   Re: ClientCommand
Reply With Quote #7

Quote:
Originally Posted by shavit View Post
Thank you, how can i add a line like:
Code:
AddMenuItem(CPMenu, "empty1", " ", ITEMDRAW_DISABLED);
But the number before of it will not be showen?
Use ITEMDRAW_SPACER instead of ITEMDRAW_DISABLED. However, this doesn't work if the menu has multiple pages.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-19-2012 at 20:51.
Powerlord is offline
Visual77
Veteran Member
Join Date: Jan 2009
Old 05-19-2012 , 20:52   Re: ClientCommand
Reply With Quote #8

Quote:
Originally Posted by ZzZombo View Post
When I tried to use FakeClientCommand() to force a player to -attack the game said that it's an unknown command but ClientCommand() worked perfect.
because -attack is a client (cl) cmd. for any client cmd you should be using ClientCommand as said in post 2.

FakeClientCommand works just fine in L4D, if used correctly. you can use it for pretty much all cmds that aren't "cl" and of course sourcemod registred cmds.

Last edited by Visual77; 05-19-2012 at 21:02.
Visual77 is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 05-19-2012 , 21:26   Re: ClientCommand
Reply With Quote #9

Quote:
Originally Posted by Powerlord View Post
Use ITEMDRAW_SPACER instead of ITEMDRAW_DISABLED. However, this doesn't work if the menu has multiple pages.
Thank you!
There is only a final thing that i need to fix before release.
some stuff dont working, i mean some stuff not executing the command on the client.
Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>

#define PLUGIN_VERSION "2.5.0"

#pragma semicolon 1

new bool:allow[MAXPLAYERS+1];
new bool:tele_saved[MAXPLAYERS+1] = {false, ...};
new Float:checkpoint[MAXPLAYERS+1][3];
new bool:tele_saved2[MAXPLAYERS+1] = {false, ...};
new Float:checkpoint2[MAXPLAYERS+1][3];
new Handle:weaponsallow = INVALID_HANDLE;
new Handle:gravityallow = INVALID_HANDLE;
new Handle:checkpointsallow = INVALID_HANDLE;

 
public Plugin:myinfo =
{
	name = "Bunnyhop Commands",
	author = "TimeBomb",
	description = "Bunnyhop Commands.",
	version = PLUGIN_VERSION,
	url = ""
};
 
public OnPluginStart()
{
	RegConsoleCmd("sm_superlowgrav", Command_SuperLowgravity, "Super Low Gravity for Client.");
	RegConsoleCmd("sm_lowgrav", Command_Lowgravity, "Low Gravity for Client.");
	RegConsoleCmd("sm_highgrav", Command_Highgravity, "High Gravity for Client..");
	RegConsoleCmd("sm_normalgrav", Command_Normalgravity, "Normal Gravity for Client.");
	RegConsoleCmd("sm_superlowgravity", Command_SuperLowgravity, "Super Low Gravity for Client.");
	RegConsoleCmd("sm_lowgravity", Command_Lowgravity, "Low Gravity for Client.");
	RegConsoleCmd("sm_highgravity", Command_Highgravity, "High Gravity for Client.");
	RegConsoleCmd("sm_normalgravity", Command_Normalgravity, "Normal Gravity for Client.");
	RegConsoleCmd("sm_slg", Command_SuperLowgravity, "Super Low Gravity for Client.");
	RegConsoleCmd("sm_lg", Command_Lowgravity, "Low Gravity for Client.");
	RegConsoleCmd("sm_hg", Command_Highgravity, "High Gravity for Client.");
	RegConsoleCmd("sm_ng", Command_Normalgravity, "Normal Gravity for Client.");
	RegConsoleCmd("sm_r", Command_reviver, "Respawning Client, Usable for Restarting the Map.");
	RegConsoleCmd("sm_restart", Command_reviver, "Respawning Client, Usable for Restarting the Map.");
	RegConsoleCmd("sm_commands", Command_Commands, "Commands Menu.");
	RegConsoleCmd("sm_bhop", Command_Commands, "Commands Menu.");
	RegConsoleCmd("sm_comms", Command_Commands, "Commands Menu.");
	RegConsoleCmd("sm_guns", Command_Guns, "Guns Menu.");
	RegConsoleCmd("sm_w", Command_Guns, "Guns Menu.");
	RegConsoleCmd("sm_weapons", Command_Guns, "Guns Menu.");
	RegConsoleCmd("sm_knife", Command_knife, "Spawns a Knife, Usable to Maps without Knifes.");
	RegConsoleCmd("sm_kn", Command_knife, "Spawns a Knife, For a Fat lazy Man, Usable to Maps without Knifes.");
	RegConsoleCmd("sm_usp", Command_usp, "Spawns a Usp Pistol.");
	RegConsoleCmd("sm_awp", Command_awp, "Spawns a AWP Sniper Rifle.");
	RegConsoleCmd("sm_deagle", Command_deagle, "Spawns a Desert Eagle Pistol.");
	RegConsoleCmd("sm_scout", Command_scout, "Spawns a Scout Sniper Rifle.");
	RegConsoleCmd("sm_save1", Command_save1, "Saving a Checkpoint on The Client Position.");
	RegConsoleCmd("sm_tele1", Command_tele1, "Teleport to your Saved Checkpoint [1].");
	RegConsoleCmd("sm_s1", Command_save1, "Saving a Checkpoint on The Client Position [1].");
	RegConsoleCmd("sm_t1", Command_tele1, "Teleport to your Saved Checkpoint. [1]");
	RegConsoleCmd("sm_save2", Command_save2, "Saving a Checkpoint on The Client Position. [2]");
	RegConsoleCmd("sm_tele2", Command_tele2, "Teleport to your Saved Checkpoint. [2]");
	RegConsoleCmd("sm_s2", Command_save2, "Saving a Checkpoint on The Client Position. [2]");
	RegConsoleCmd("sm_t2", Command_tele2, "Teleport to your Saved Checkpoint. [2]");
	RegConsoleCmd("sm_cp", Command_cp, "CheckPoints Menu.");
	RegConsoleCmd("sm_checkpoints", Command_cp, "CheckPoints Menu.");
	RegConsoleCmd("sm_gravitycommands", Command_gravity, "Gravity Commands.");
	RegConsoleCmd("sm_grav", Command_gravity, "Gravity Commands.");
	weaponsallow = CreateConVar("sm_bhopcommands_weapons", "1", "Enable Weapon Spawning? [1 - True] [0 - False].");
	gravityallow = CreateConVar("sm_bhopcommands_gravity", "1", "Enable Gravity Commands? [1 - True] [0 - False].");
	checkpointsallow = CreateConVar("sm_bhopcommands_checkpoints", "1", "Enable Check Points? [1 - True] [0 - False].");
	CreateConVar("sm_bhopcommands_version", PLUGIN_VERSION, "Bunnyhop Commands Version.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
	SetConVarInt(FindConVar("sv_enablebunnyhopping"), 1);
	SetConVarInt(FindConVar("sv_enableboost"), 1);
	SetConVarInt(FindConVar("sv_airaccelerate"), 99999999);
	CreateTimer(240.0, ad, _, TIMER_REPEAT);
	AutoExecConfig(true, "bhopcommands");
}
	
public OnMapStart()
{	
	for(new i = 1; i <= MaxClients; i++)
	{
		allow[i]=true;
	}
}	

public Action:ad(Handle:SuperTimer, any:data)
{
	PrintToChatAll("\x04[SM]\x01 This Server is Running Bunnyhop Commands %s.", PLUGIN_VERSION);
}

public Action:Command_Lowgravity(client, args)
{
	if(GetConVarBool(gravityallow) && IsPlayerAlive(client))
	{
		PrintToChat(client, "\x04[SM]\x01 You have Just Changed Your Gravity to Lower!");
		SetEntityGravity(client, 0.5);
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Gravity Commands are Disabled/You are dead and unable to change gravity.");
	}
	return Plugin_Handled;
}
	
public Action:Command_Highgravity(client, args)
{
	if(GetConVarBool(gravityallow) && IsPlayerAlive(client))
	{
		PrintToChat(client, "\x04[SM]\x01 You have Just Changed Your Gravity to Higher!");
		SetEntityGravity(client, 1.5);
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Gravity Commands are Disabled/You are dead and unable to change gravity.");
	}
	return Plugin_Handled;
}
	
public Action:Command_Normalgravity(client, args)
{
	if(GetConVarBool(gravityallow) && IsPlayerAlive(client))
	{
		PrintToChat(client, "\x04[SM]\x01 You have Just Changed Your Gravity to Normal!");
		SetEntityGravity(client, 1.0);
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Gravity Commands are Disabled/You are dead and unable to change gravity.");
	}
	return Plugin_Handled;
}
	
public Action:Command_SuperLowgravity(client, args)
{
	if(GetConVarBool(gravityallow) && IsPlayerAlive(client))
	{
		PrintToChat(client, "\x04[SM]\x01 You have Just Changed Your Gravity to \x03SUPERLOWGRAVITYYY!");
		SetEntityGravity(client, 0.2);
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Gravity Commands are Disabled/You are dead and unable to change gravity.");
	}
	return Plugin_Handled;
}
	
public Action:Command_Commands(client, args)
{
	new Handle:CommandsMenu = CreateMenu(MenuHandler_CommandsMenu);
	SetMenuTitle(CommandsMenu, "Commands:");
	AddMenuItem(CommandsMenu, "commands", "!commands / !commds / !bhop - This Menu", ITEMDRAW_DISABLED);
	AddMenuItem(CommandsMenu, "gravity", "!gravitycommands / !grav - Gravity Menu");
	AddMenuItem(CommandsMenu, "guns", "!guns - Guns/Weapons Menu");
	AddMenuItem(CommandsMenu, "revive", "!r / !restart - Respawning Yourself");
	AddMenuItem(CommandsMenu, "checkpoints", "!cp / !checkpoints - CheckPoints Menu");
	DisplayMenu(CommandsMenu, client, MENU_TIME_FOREVER);
	return Plugin_Handled;
}

public MenuHandler_CommandsMenu(Handle:CommandsMenu, MenuAction:action, iClient, iMenuItem)
{
	new client = iClient;
	if (action == MenuAction_Select)
	{
		decl String:strSelection[4];
		GetMenuItem(CommandsMenu, iMenuItem, strSelection, sizeof(strSelection));
		if(strcmp(strSelection, "gravity", false) == 0)
		{
			FakeClientCommand(client, "sm_grav");
		}
		else if(strcmp(strSelection, "guns", false) == 0)
		{
			FakeClientCommand(client, "sm_guns");
		}
		else if(strcmp(strSelection, "revive", false) == 0)
		{
			FakeClientCommand(client, "sm_r");
		}
		else if(strcmp(strSelection, "checkpoints", false) == 0)
		{
			FakeClientCommand(client, "sm_cp");
		}
	}
	else if (action == MenuAction_End)
	{
		CloseHandle(CommandsMenu);
	}
}

public Action:Command_reviver(client, args)
{
	PrintToChat(client, "\x04[SM]\x01 Have Fun!");
	CS_RespawnPlayer(client);
	return Plugin_Handled;
}

public Action:Command_Guns(client, args)
{
	new Handle:WeaponMenu = CreateMenu(MenuHandler_SelectWeapon);
	SetMenuTitle(WeaponMenu, "Choose Weapon");
	SetMenuExitButton(WeaponMenu, true);
	AddMenuItem(WeaponMenu, "scout", "Scout [!scout]");
	AddMenuItem(WeaponMenu, "awp", "AWP [!awp]");
	AddMenuItem(WeaponMenu, "deagle", "Deagle [!deagle]");
	AddMenuItem(WeaponMenu, "usp", "USP [!usp]");
	AddMenuItem(WeaponMenu, "knife", "Knife [!knife/!kn]");
	DisplayMenu(WeaponMenu, client, MENU_TIME_FOREVER);
	return Plugin_Handled;
}

public MenuHandler_SelectWeapon(Handle:WeaponMenu, MenuAction:action, iClient, iMenuItem)
{
	new client = iClient;
	if (action == MenuAction_Select)
	{
		decl String:strSelection[4];
		GetMenuItem(WeaponMenu, iMenuItem, strSelection, sizeof(strSelection));
		if(strcmp(strSelection, "scout", false) == 0)
		{
			FakeClientCommand(client, "sm_scout");
		}
		else if(strcmp(strSelection, "awp", false) == 0)
		{
			FakeClientCommand(client, "sm_awp");
		}
		else if(strcmp(strSelection, "deagle", false) == 0)
		{
			FakeClientCommand(client, "sm_deagle");
		}
		else if(strcmp(strSelection, "usp", false) == 0)
		{
			FakeClientCommand(client, "sm_usp");
		}
		else if(strcmp(strSelection, "knife", false) == 0)
		{
			FakeClientCommand(client, "sm_knife");
		}
	}
	else if (action == MenuAction_End)
	{
		CloseHandle(WeaponMenu);
	}
}

public Action:Command_cp(client, args)
{
	if(GetConVarBool(checkpointsallow) && IsPlayerAlive(client))
	{
		new Handle:CPMenu = CreateMenu(MenuHandler_CPMenu);
		SetMenuTitle(CPMenu, "CheckPoints");
		SetMenuExitButton(CPMenu, true);
		AddMenuItem(CPMenu, "save1", "Save 1 - [!save1]");
		AddMenuItem(CPMenu, "tele1", "Teleport 1 - [!tele1]");
		AddMenuItem(CPMenu, "empty1", "", ITEMDRAW_SPACER);
		AddMenuItem(CPMenu, "empty2", "", ITEMDRAW_SPACER);
		AddMenuItem(CPMenu, "save2", "Save 2 - [!save2]");
		AddMenuItem(CPMenu, "tele2", "Teleport 2 - [!tele2]");
		DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 CheckPoints Commands are Disabled/You are dead and unable to use checkpoints.");
	}
	return Plugin_Handled;
}

public MenuHandler_CPMenu(Handle:CPMenu, MenuAction:action, iClient, iMenuItem)
{
	new client = iClient;
	if (action == MenuAction_Select)
	{
		decl String:strSelection[4];
		GetMenuItem(CPMenu, iMenuItem, strSelection, sizeof(strSelection));
		if(strcmp(strSelection, "save", false) == 0)
		{
			FakeClientCommand(client, "sm_save1");
			DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
		}
		else if(strcmp(strSelection, "tele", false) == 0)
		{
			FakeClientCommand(client, "sm_tele1");
			DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
		}
		else if(strcmp(strSelection, "save2", false) == 0)
		{
			FakeClientCommand(client, "sm_save2");
			DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
		}
		else if(strcmp(strSelection, "save2", false) == 0)
		{
			FakeClientCommand(client, "sm_tele2");
			DisplayMenu(CPMenu, client, MENU_TIME_FOREVER);
		}
	}
}

public Action:Command_gravity(client, args)
{
	new Handle:GravityMenu = CreateMenu(MenuHandler_SelectGravity);
	SetMenuTitle(GravityMenu, "Choose Gravity");
	SetMenuExitButton(GravityMenu, true);
	AddMenuItem(GravityMenu, "lowgrav", "Low Gravity [!lg/!lowgrav/!lowgravity]");
	AddMenuItem(GravityMenu, "highgrav", "High Gravity [!hg/!highgrav/!highgravity]");
	AddMenuItem(GravityMenu, "normalgrav", "Normal Gravity [!ng/!normalgrav/!normalgravity]");
	AddMenuItem(GravityMenu, "superlowgrav", "Super Low Gravity [!slg/!superlowgrav/!superlowgravity]");
	DisplayMenu(GravityMenu, client, MENU_TIME_FOREVER);
	return Plugin_Handled;
}

public MenuHandler_SelectGravity(Handle:GravityMenu, MenuAction:action, iClient, iMenuItem)
{
	new client = iClient;
	if (action == MenuAction_Select)
	{
		decl String:strSelection[4];
		GetMenuItem(GravityMenu, iMenuItem, strSelection, sizeof(strSelection));
		if(strcmp(strSelection, "lowgrav", false) == 0)
		{
			FakeClientCommand(client, "sm_lg");
		}
		else if(strcmp(strSelection, "highgrav", false) == 0)
		{
			FakeClientCommand(client, "sm_hg");
		}
		else if(strcmp(strSelection, "normalgrav", false) == 0)
		{
			FakeClientCommand(client, "sm_ng");
		}
		else if(strcmp(strSelection, "superlowgrav", false) == 0)
		{
			FakeClientCommand(client, "sm_slg");
		}
	}
	else if (action == MenuAction_End)
	{
		CloseHandle(GravityMenu);
	}
}
	
public Action:Command_knife(client,args)
{
	if(GetConVarBool(weaponsallow) && IsPlayerAlive(client))
	{
		if(allow[client]==true)
		{
			GivePlayerItem(client, "weapon_knife");
			allow[client]=false;
			CreateTimer(30.0, Action_weaponspawner, client, TIMER_FLAG_NO_MAPCHANGE);
		}
		else
		{
			PrintToChat(client, "\x04[SM]\x01 You must wait 30 seconds between Spawning Weapons, Abuse will get you banned.");
		}
		
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Weapons commands are Disabled/You are dead and unable to use Them.");
	}
	return Plugin_Handled;
}
	
public Action:Command_usp(client,args)
{
	if(GetConVarBool(weaponsallow) && IsPlayerAlive(client))
	{
		if(allow[client]==true)
		{
			GivePlayerItem(client, "weapon_usp");
			allow[client]=false;
			CreateTimer(30.0, Action_weaponspawner, client, TIMER_FLAG_NO_MAPCHANGE);
		}
		else
		{
			PrintToChat(client, "\x04[SM]\x01 You must wait 30 seconds between Spawning Weapons, Abuse will get you banned.");
		}
		
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Weapons commands are Disabled/You are dead and unable to use Them.");
	}
	return Plugin_Handled;
}

public Action:Command_deagle(client,args)
{
	if(GetConVarBool(weaponsallow) && IsPlayerAlive(client))
	{
		if(allow[client]==true)
		{
			GivePlayerItem(client, "weapon_deagle");
			allow[client]=false;
			CreateTimer(30.0, Action_weaponspawner, client, TIMER_FLAG_NO_MAPCHANGE);
		}
		else
		{
			PrintToChat(client, "\x04[SM]\x01 You must wait 30 seconds between Spawning Weapons, Abuse will get you banned.");
		}
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Weapons commands are Disabled/You are dead and unable to use Them.");
	}
	return Plugin_Handled;
}

public Action:Command_awp(client,args)
{
	if(GetConVarBool(weaponsallow) && IsPlayerAlive(client))
	{
		if(allow[client]==true)
		{
			GivePlayerItem(client, "weapon_awp");
			allow[client]=false;
			CreateTimer(30.0, Action_weaponspawner, client, TIMER_FLAG_NO_MAPCHANGE);
		}
		else
		{
			PrintToChat(client, "\x04[SM]\x01 You must wait 30 seconds between Spawning Weapons, Abuse will get you banned.");
		}
		
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Weapons commands are Disabled/You are dead and unable to use Them.");
	}
	return Plugin_Handled;
}

public Action:Command_scout(client,args)
{
	if(GetConVarBool(weaponsallow) && IsPlayerAlive(client))
	{
		if(allow[client]==true)
		{
			GivePlayerItem(client, "weapon_scout");
			allow[client]=false;
			CreateTimer(30.0, Action_weaponspawner, client, TIMER_FLAG_NO_MAPCHANGE);
		}
		else
		{
			PrintToChat(client, "\x04[SM]\x01 You must wait 30 seconds between Spawning Weapons, Abuse will get you banned.");
		}
		
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 Weapons commands are Disabled/You are dead and unable to use Them.");
	}
	return Plugin_Handled;
}

public Action:Action_weaponspawner(Handle:timer, any:client)
{
	allow[client] = true;
}

public Action:Command_save1(client, args)
{
	if(GetConVarBool(checkpointsallow) && IsPlayerAlive(client))
	{
		GetEntPropVector(client, Prop_Send, "m_vecOrigin", checkpoint[client]);
		tele_saved[client] = true;
		PrintToChat(client, "\x04[SM]\x01 CheckPoint [1] Saved.");
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 CheckPoints are disabled, or you are dead and have to be alive.");
	}
	return Plugin_Handled;
}

public Action:Command_tele1(client, args)
{
	if(tele_saved[client] && GetConVarBool(checkpointsallow) && IsPlayerAlive(client))
	{
		TeleportEntity(client, checkpoint[client], NULL_VECTOR, NULL_VECTOR);
		PrintToChat(client, "\x04[SM]\x01 Teleported to Checkpoint [1].");
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 You Have to Place a Checkpoint [1] First, Type !s1/!save1 for that, or you are dead and have to be alive.");
	}
	return Plugin_Handled;
}

public Action:Command_save2(client, args)
{
	if(GetConVarBool(checkpointsallow) && IsPlayerAlive(client))
	{
		GetEntPropVector(client, Prop_Send, "m_vecOrigin", checkpoint2[client]);
		tele_saved2[client] = true;
		PrintToChat(client, "\x04[SM]\x01 CheckPoint [2] Saved.");
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 CheckPoints are disabled, or you are dead and have to be alive.");
	}
	return Plugin_Handled;
}

public Action:Command_tele2(client, args)
{
	if(tele_saved2[client] && GetConVarBool(checkpointsallow) && IsPlayerAlive(client))
	{
		TeleportEntity(client, checkpoint2[client], NULL_VECTOR, NULL_VECTOR);
		PrintToChat(client, "\x04[SM]\x01 Teleported to Checkpoint [2].");
	}
	else
	{
		PrintToChat(client, "\x04[SM]\x01 You Have to Place a Checkpoint [2] First, Type !s2/!save2 for that, or you are dead and have to be alive.");
	}
	return Plugin_Handled;
}
__________________
retired
shavit 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 11:24.


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