Senior Member
|
07-14-2018
, 17:45
Re: Please remove :)
|
#25
|
Quote:
Originally Posted by psychonic
The deleted code:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#define PLUGIN_VERSION "1.6"
new Handle:cvar_maxweaponstotal = INVALID_HANDLE;
new Handle:cvar_maxweaponsclient = INVALID_HANDLE;
new numweaponstotal;
new numweaponsclient[MAXPLAYERS + 1];
public Plugin:myinfo =
{
name = "[L4D2] Melee Wepons Menu",
author = "dani1341",
description = "Allows Clients To Get Melee Weapons From The Melee Weapon Menu",
version = PLUGIN_VERSION,
url = ""
}
public OnPluginStart()
{
//melee weapons menu cvar
RegConsoleCmd("melee", MeleeMenu);
//plugin version
CreateConVar("melee_version", PLUGIN_VERSION, "L4D 2 Melee Weapons Menu version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FC VAR_NOTIFY);
cvar_maxweaponstotal = CreateConVar("melee_max", "40", "How much times all players can get melee weapons per map", FCVAR_PLUGIN|FCVAR_NOTIFY);
cvar_maxweaponsclient = CreateConVar("melee_playermax", "10", "How much times one player can get melee weapons", FCVAR_PLUGIN|FCVAR_NOTIFY);
HookEvent("round_end", Event_RoundEnd);
//autoexec
AutoExecConfig(true, "l4d2_melee");
}
public OnMapStart()
{
numweaponstotal = 0;
for(new i = 1; i <= MAXPLAYERS; i++)
numweaponsclient[i] = 0;
}
public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
numweaponstotal = 0;
for(new i = 1; i <= MAXPLAYERS; i++)
numweaponsclient[i] = 0;
}
public OnClientPostAdminCheck(client)
{
for(new i = 1; i <= MAXPLAYERS; i++)
numweaponsclient[i] = 0;
}
public Action:MeleeMenu(client,args)
{
if(!client || !IsClientInGame(client))
return Plugin_Handled;
if(GetClientTeam(client) != 2)
{
PrintToChat(client, "Melee Weapons Menu is only available to survivors.");
return Plugin_Handled;
}
if(numweaponstotal >= GetConVarInt(cvar_maxweaponstotal))
{
PrintToChat(client, "Limit of %i total melee weapons for this map has been reached.", GetConVarInt(cvar_maxweaponstotal));
return Plugin_Handled;
}
if(numweaponsclient[client] >= GetConVarInt(cvar_maxweaponsclient))
{
PrintToChat(client, "You have reached your limit of %i for this map.", GetConVarInt(cvar_maxweaponsclient));
return Plugin_Handled;
}
Melee(client);
return Plugin_Handled;
}
public Action:Melee(clientId)
{
new Handle:menu = CreateMenu(MeleeMenuHandler);
SetMenuTitle(menu, "Melee Weapons Menu");
AddMenuItem(menu, "option1", "Baseball Bat");
AddMenuItem(menu, "option2", "Crowbar");
AddMenuItem(menu, "option3", "Cricket Bat");
AddMenuItem(menu, "option4", "Electric Guitar");
AddMenuItem(menu, "option5", "Fire Axe");
AddMenuItem(menu, "option6", "Frying Pan");
AddMenuItem(menu, "option7", "Golf Club");
AddMenuItem(menu, "option8", "Katana");
AddMenuItem(menu, "option9", "Knife");
AddMenuItem(menu, "option10", "Machete");
AddMenuItem(menu, "option11", "Magnum");
AddMenuItem(menu, "option12", "Night Stick");
AddMenuItem(menu, "option13", "Pistol");
AddMenuItem(menu, "option14", "Riot Shield");
SetMenuExitButton(menu, true);
DisplayMenu(menu, clientId, MENU_TIME_FOREVER);
return Plugin_Handled;
}
public MeleeMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
//Strip the CHEAT flag off of the "give" command
new flags = GetCommandFlags("give");
SetCommandFlags("give", flags & ~FCVAR_CHEAT);
if ( action == MenuAction_Select ) {
switch (itemNum)
{
case 0: //Baseball Bat
{
//Give the player a Baseball Bat
FakeClientCommand(client, "give baseball_bat");
}
case 1: //Crowbar
{
//Give the player a Crowbar
FakeClientCommand(client, "give crowbar");
}
case 2: //Cricket Bat
{
//Give the player a Cricket Bat
FakeClientCommand(client, "give cricket_bat");
}
case 3: //Electric Guitar
{
//Give the player a Electric Guitar
FakeClientCommand(client, "give electric_guitar");
}
case 4: //Fire Axe
{
//Give the player a Fire Axe
FakeClientCommand(client, "give fireaxe");
}
case 5: //Frying Pan
{
//Give the player a Frying Pan
FakeClientCommand(client, "give frying_pan");
}
case 6: //Golf Club
{
//Give the player a Golf Club
FakeClientCommand(client, "give golfclub");
}
case 7: //Katana
{
//Give the player a Katana
FakeClientCommand(client, "give katana");
}
case 8: //Knife
{
//Give the player a Knife
FakeClientCommand(client, "give knife");
}
case 9: //Machete
{
//Give the player a Machete
FakeClientCommand(client, "give machete");
}
case 10: //Magnum
{
//Give the player a Magnum
FakeClientCommand(client, "give pistol_magnum");
}
case 11: //Night Stick
{
//Give the player a Night Stick
FakeClientCommand(client, "give tonfa");
}
case 12: //Pistol
{
//Give the player a Pistol
FakeClientCommand(client, "give pistol");
}
case 13: //Riot Shield
{
//Give the player a Riot Shield
FakeClientCommand(client, "give riotshield");
}
}
numweaponstotal++;
numweaponsclient[client]++;
}
//Add the CHEAT flag back to "give" command
SetCommandFlags("give", flags|FCVAR_CHEAT);
}
|
What's the purpose of this?
PHP Code:
public OnClientPostAdminCheck(client)
{
for(new i = 1; i <= MAXPLAYERS; i++)
numweaponsclient[i] = 0;
}
When one client connects, it resets the melee count for everyone.
So I'm assuming this function wouldn't be too useful after a client fully connects, since everyone's melee count just got reset:
PHP Code:
if(numweaponsclient[client] >= GetConVarInt(cvar_maxweaponsclient))
{
PrintToChat(client, "You have reached your limit of %i for this map.", GetConVarInt(cvar_maxweaponsclient));
return Plugin_Handled;
}
|
|