Merged heads.

This commit is contained in:
richard 2009-04-11 01:56:53 +02:00
commit d063def554
7 changed files with 132 additions and 378 deletions

View File

@ -170,32 +170,36 @@
"ru" "Отображение здоровья включено."
}
"Weapon has been restricted"
// ===========================
// Weapon Restrict
// ===========================
"Restrict weapon"
{
"#format" "{1:s}"
"en" "Weapon @green\"{1}\" @defaulthas been restricted."
"ru" "Оружие @green\"{1}\" было запрещено."
}
"Weapon group has been restricted"
{
"#format" "{1:s}"
"en" "Weapon group @green\"{1}\" @defaulthas been restricted."
"ru" "Группа оружия @green\"{1}\" была запрещена."
}
"Weapon has been unrestricted"
"Unrestrict weapon"
{
"#format" "{1:s}"
"en" "Weapon @green\"{1}\" @defaulthas been unrestricted."
"ru" "Оружие @green\"{1}\" было разрешено."
}
"Weapon group has been unrestricted"
"Restrict custom weapon group"
{
"#format" "{1:s}"
"en" "Weapon group @green\"{1}\" @defaulthas been restricted."
"ru" "Группа оружия @green\"{1}\" была разрешена."
"#format" "{1:s},{2:s}"
"en" "Weapon group @green\"{1}\" ({2}) @defaulthas been restricted."
"ru" "Группа оружия @green\"{1}\" ({2}) была запрещена."
}
"Unrestrict custom weapon group"
{
"#format" "{1:s},{2:s}"
"en" "Weapon group @green\"{1}\" ({2}) @defaulthas been unrestricted."
"ru" "Группа оружия @green\"{1}\" ({2}) была разрешена."
}
"Weapon is restricted"
@ -205,18 +209,10 @@
"ru" "Оружие @green{1} @default запрещено."
}
"Weapon already restricted"
{
"#format" "{1:s}"
"en" "Weapon @green\"{1}\" @defaultis already restricted."
"ru" "Оружие @green\"{1}\" @default уже запрещено. "
}
"Weapon invalid"
{
"#format" "{1:s}"
"en" "Weapon @green\"{1}\" @defaultis invalid or not currently restricted."
"ru" "Оружие @green\"{1}\" @default указано неверно или в данный момент не запрещено."
"en" "Weapon @green\"{1}\" @defaultis not currently restricted."
}
"Zombie cant use weapon"
@ -225,6 +221,8 @@
"ru" "Зомби не могут использовать оружие!"
}
"Suicide text"
{
"en" "Nice try n00b!"
@ -294,12 +292,6 @@
"ru" "ZTele (!ztele) - Телепорт на место появления"
}
"!zmenu stuck"
{
"en" "ZStuck (!zstuck) - Unsticks you from another player"
"ru" "ZStuck (!zstuck) - Разлепляет вас с другим игроком"
}
"!zmenu hp"
{
"en" "ZHP (!zhp) - Toggle persistent display of HP as zombie"

View File

@ -34,7 +34,11 @@
#include "zr/menu"
#include "zr/sayhooks"
#include "zr/zadmin"
// Weapons
#include "zr/weapons/restrict"
#include "zr/weapons/markethandler"
#include "zr/damagecontrol"
#include "zr/commands"
#include "zr/event"

View File

@ -160,14 +160,14 @@ public Action:Command_Restrict(client, argc)
{
case Successful_Weapon:
{
ZR_ReplyToCommand(client, "Restrict weapon", arg1);
ZR_PrintToChat(0, "Restrict weapon", arg1);
}
case Successful_Group:
{
decl String:weaponlist[128];
WeaponRestrictGetWeaponList(arg1, weaponlist, sizeof(weaponlist), ", ");
ZR_ReplyToCommand(client, "Restrict custom weapon group", arg1, weaponlist);
ZR_PrintToChat(0, "Restrict custom weapon group", arg1, weaponlist);
}
case Invalid:
{
@ -217,14 +217,14 @@ public Action:Command_Unrestrict(client, argc)
{
case Successful_Weapon:
{
ZR_ReplyToCommand(client, "Unrestrict weapon", arg1);
ZR_PrintToChat(0, "Unrestrict weapon", arg1);
}
case Successful_Group:
{
decl String:weaponlist[128];
WeaponRestrictGetWeaponList(arg1, weaponlist, sizeof(weaponlist), ", ");
ZR_ReplyToCommand(client, "Unrestrict custom weapon group", arg1, weaponlist);
ZR_PrintToChat(0, "Unrestrict custom weapon group", arg1, weaponlist);
}
case Invalid:
{

View File

@ -137,64 +137,6 @@ bool:ZMarket(client)
return true;
}
public bool:Market_OnWeaponSelected(client, String:weaponid[])
{
if (!weaponid[0] || !IsPlayerAlive(client))
{
return false;
}
if (IsPlayerZombie(client))
{
ZR_PrintToChat(client, "Zombie cant use weapon");
return false;
}
if (StrEqual(weaponid, "rebuy"))
{
return true;
}
decl String:display[64];
decl String:weapon[32];
new price;
if (!Market_GetWeaponIDInfo(weaponid, display, weapon, price))
{
return false;
}
ReplaceString(weapon, sizeof(weapon), "weapon_", "");
if (WeaponRestrictIsRestricted(weapon))
{
ZR_PrintToChat(client, "Weapon is restricted", weapon);
return false;
}
new bool:buyzone = GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]);
if (!IsClientInBuyZone(client) && buyzone)
{
ZR_PrintCenterText(client, "Market out of buyzone");
return false;
}
return true;
}
public Market_PostOnWeaponSelected(client, &bool:allowed)
{
if (!allowed)
{
return;
}
ZMarket(client);
}
ZSpawn(client)
{
new bool:spawn = GetConVarBool(gCvars[CVAR_ZSPAWN]);
@ -225,16 +167,6 @@ ZSpawn(client)
AddPlayerToList(client);
}
public Action:CollisionOn(Handle:timer, any:index)
{
if (!IsClientInGame(index))
{
return;
}
NoCollide(index, false);
}
ZHP(client)
{
new bool:zhp = GetConVarBool(gCvars[CVAR_ZHP]);

View File

@ -1,261 +0,0 @@
/**
* ====================
* Zombie:Reloaded
* File: weaponrestrict.inc
* Author: Greyscale
* ====================
*/
new Handle:restrictedWeapons = INVALID_HANDLE;
new gRestrict[MAXPLAYERS+1];
enum WepRestrictQuery
{
Successful, /** Weapon (un)restrict query was successful */
Invalid, /** Weapon invalid */
Existing, /** Already restricted */
}
InitWeaponRestrict()
{
RegConsoleCmd("buy", BuyHook);
restrictedWeapons = CreateArray(32, 0);
}
ClientHookUse(client)
{
gRestrict[client] = Hacks_Hook(client, HACKS_HTYPE_WEAPON_CANUSE, Weapon_CanUse, false);
}
ClientUnHookUse(client)
{
Hacks_Unhook(gRestrict[client]);
}
public Action:BuyHook(client, argc)
{
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
if (!enabled)
{
return Plugin_Continue;
}
if (IsPlayerHuman(client))
{
decl String:weapon[64];
GetCmdArg(1, weapon, sizeof(weapon));
ReplaceString(weapon, sizeof(weapon), "weapon_", "");
if (IsWeaponRestricted(weapon))
{
ZR_PrintToChat(client, "Weapon is restricted", weapon);
return Plugin_Handled;
}
}
else
{
ZR_PrintToChat(client, "Zombie cant use weapon");
return Plugin_Handled;
}
return Plugin_Continue;
}
WepRestrictQuery:RestrictWeapon(const String:weapon[])
{
if (IsWeaponGroup(weapon))
{
RestrictWeaponGroup(weapon);
ZR_PrintToChat(0, "Weapon group has been restricted", weapon);
return Successful;
}
if (!IsWeaponRestricted(weapon))
{
PushArrayString(restrictedWeapons, weapon);
ZR_PrintToChat(0, "Weapon has been restricted", weapon);
return Successful;
}
return Existing;
}
RestrictWeaponGroup(const String:group[])
{
if (StrEqual(group, "pistols", false))
{
PushArrayString(restrictedWeapons, "glock");
PushArrayString(restrictedWeapons, "usp");
PushArrayString(restrictedWeapons, "p228");
PushArrayString(restrictedWeapons, "deagle");
PushArrayString(restrictedWeapons, "elite");
PushArrayString(restrictedWeapons, "fiveseven");
}
else if (StrEqual(group, "shotguns", false))
{
PushArrayString(restrictedWeapons, "m3");
PushArrayString(restrictedWeapons, "xm1014");
}
else if (StrEqual(group, "smgs", false))
{
PushArrayString(restrictedWeapons, "tmp");
PushArrayString(restrictedWeapons, "mac10");
PushArrayString(restrictedWeapons, "mp5navy");
PushArrayString(restrictedWeapons, "ump45");
PushArrayString(restrictedWeapons, "p90");
}
else if (StrEqual(group, "rifles", false))
{
PushArrayString(restrictedWeapons, "galil");
PushArrayString(restrictedWeapons, "famas");
PushArrayString(restrictedWeapons, "ak47");
PushArrayString(restrictedWeapons, "m4a1");
PushArrayString(restrictedWeapons, "sg552");
PushArrayString(restrictedWeapons, "aug");
}
else if (StrEqual(group, "snipers", false))
{
PushArrayString(restrictedWeapons, "scout");
PushArrayString(restrictedWeapons, "sg550");
PushArrayString(restrictedWeapons, "g3sg1");
PushArrayString(restrictedWeapons, "awp");
}
}
WepRestrictQuery:UnRestrictWeapon(const String:weapon[])
{
if (IsWeaponGroup(weapon))
{
UnRestrictWeaponGroup(weapon);
ZR_PrintToChat(0, "Weapon group has been unrestricted", weapon);
return Successful;
}
new index = GetRestrictedWeaponIndex(weapon);
if (index > -1)
{
RemoveFromArray(restrictedWeapons, index);
ZR_PrintToChat(0, "Weapon has been unrestricted", weapon);
return Successful;
}
return Invalid;
}
UnRestrictWeaponGroup(const String:group[])
{
if (StrEqual(group, "pistols", false))
{
UnRestrictWeapon("glock");
UnRestrictWeapon("usp");
UnRestrictWeapon("p228");
UnRestrictWeapon("deagle");
UnRestrictWeapon("elite");
UnRestrictWeapon("fiveseven");
}
else if (StrEqual(group, "shotguns", false))
{
UnRestrictWeapon("m3");
UnRestrictWeapon("xm1014");
}
else if (StrEqual(group, "smgs", false))
{
UnRestrictWeapon("tmp");
UnRestrictWeapon("mac10");
UnRestrictWeapon("mp5navy");
UnRestrictWeapon("ump45");
UnRestrictWeapon("p90");
}
else if (StrEqual(group, "rifles", false))
{
UnRestrictWeapon("galil");
UnRestrictWeapon("famas");
UnRestrictWeapon("ak47");
UnRestrictWeapon("m4a1");
UnRestrictWeapon("sg552");
UnRestrictWeapon("aug");
}
else if (StrEqual(group, "snipers", false))
{
UnRestrictWeapon("scout");
UnRestrictWeapon("sg550");
UnRestrictWeapon("g3sg1");
UnRestrictWeapon("awp");
}
}
bool:IsWeaponRestricted(const String:weapon[])
{
for (new x = 0; x < GetArraySize(restrictedWeapons); x++)
{
decl String:restrictedweapon[32];
GetArrayString(restrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon));
if (StrEqual(weapon, restrictedweapon, false))
{
return true;
}
}
return false;
}
GetRestrictedWeaponIndex(const String:weapon[])
{
for (new x = 0; x < GetArraySize(restrictedWeapons); x++)
{
decl String:restrictedweapon[32];
GetArrayString(restrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon));
ReplaceString(restrictedweapon, sizeof(restrictedweapon), "weapon_", "");
if (StrEqual(weapon, restrictedweapon, false))
{
return x;
}
}
return -1;
}
bool:IsWeaponGroup(const String:weapon[])
{
return (StrEqual(weapon, "pistols", false) || StrEqual(weapon, "shotguns", false) || StrEqual(weapon, "smgs", false) || StrEqual(weapon, "rifles", false) || StrEqual(weapon, "snipers", false));
}
public Weapon_CanUse(client, weapon, dummy1, dummy2, dummy3, dummy4)
{
new bool:enabled = GetConVarBool(gCvars[CVAR_ENABLE]);
if (!enabled)
{
return Hacks_Continue;
}
new String:weaponname[32];
GetEdictClassname(weapon, weaponname, sizeof(weaponname));
ReplaceString(weaponname, sizeof(weaponname), "weapon_", "");
if (IsWeaponRestricted(weaponname))
{
return 0;
}
if (IsPlayerZombie(client) && !StrEqual(weaponname, "knife"))
{
return 0;
}
return Hacks_Continue;
}

View File

@ -0,0 +1,87 @@
/**
* ====================
* Zombie:Reloaded
* File: markethandler.inc
* Author: Greyscale
* ====================
*/
/**
* (Market) Forward called when a client selects a weapon from the market.
*
* @param client The client index.
* @param weaponid The unique weapon ID used for market natives.
* @return True to allow market to take over, false to block purchase.
*/
public bool:Market_OnWeaponSelected(client, String:weaponid[])
{
// If player is dead or weaponid is invalid, then stop
if (!weaponid[0] || !IsPlayerAlive(client))
{
return false;
}
// If player is a zombie, then stop
if (IsPlayerZombie(client))
{
ZR_PrintToChat(client, "Zombie cant use weapon");
return false;
}
// If player is using the rebuy option then allow
if (StrEqual(weaponid, "rebuy"))
{
return true;
}
decl String:display[64];
decl String:weapon[32];
new price;
// If the market plugin can't find info about the weapon, then stop
if (!Market_GetWeaponIDInfo(weaponid, display, weapon, price))
{
return false;
}
// Strip "weapon_" from entity name
ReplaceString(weapon, sizeof(weapon), "weapon_", "");
// If the weapon is restricted, then stop
if (WeaponRestrictIsRestricted(weapon))
{
ZR_PrintToChat(client, "Weapon is restricted", weapon);
return false;
}
// Check if buyzone cvar is enabled, and if the client is in a buyzone
new bool:buyzone = GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]);
if (!IsClientInBuyZone(client) && buyzone)
{
ZR_PrintCenterText(client, "Market out of buyzone");
return false;
}
return true;
}
/**
* (Market) Forward called one frame after a client selects a weapon from the market.
*
* @param client The client index.
* @param allowed True when the weapon was purchased successfully, false otherwise.
*/
public Market_PostOnWeaponSelected(client, &bool:allowed)
{
// If the purchase wasn't allowed, then stop
if (!allowed)
{
return;
}
// Resend market menu
ZMarket(client);
}

View File

@ -7,12 +7,12 @@
*/
/**
* Array to store restricted weapon names
* Array to store restricted weapon names.
*/
new Handle:gRestrictedWeapons = INVALID_HANDLE;
/**
* Array to store keyvalue data
* Array to store keyvalue data.
*/
new Handle:kvWeaponGroups = INVALID_HANDLE;
@ -22,17 +22,17 @@ new Handle:kvWeaponGroups = INVALID_HANDLE;
new gCanUseHookID[MAXPLAYERS+1];
/**
* Query results returned when (un)restricting a weapon
* Query results returned when (un)restricting a weapon.
*/
enum WpnRestrictQuery
{
Successful_Weapon, /** Weapon (un)restrict query was successful */
Successful_Group, /** Group (un)restrict query was successful */
Successful_Weapon, /** Weapon (un)restrict query was successful. */
Successful_Group, /** Group (un)restrict query was successful. */
Invalid, /** Weapon/Group invalid */
}
/**
* Initialize data and hook commands
* Initialize data and hook commands.
*/
WeaponRestrictInit()
{
@ -44,7 +44,7 @@ WeaponRestrictInit()
}
/**
* Loads weapon data from file
* Loads weapon data from file.
*/
WeaponRestrictMapStart()
{
@ -69,7 +69,7 @@ WeaponRestrictMapStart()
}
/**
* Clears restricted weapon array
* Clears restricted weapon array.
*/
RestrictWeaponUnrestrictAll()
{
@ -77,9 +77,9 @@ RestrictWeaponUnrestrictAll()
}
/**
* Hook Weapon_CanUse function on a client
* Hook Weapon_CanUse function on a client.
*
* @param client The client index
* @param client The client index.
*/
WeaponRestrictClientInit(client)
{
@ -87,9 +87,9 @@ WeaponRestrictClientInit(client)
}
/**
* Unhook Weapon_CanUse function on a client
* Unhook Weapon_CanUse function on a client.
*
* @param client The client index
* @param client The client index.
*/
WeaponRestrictClientDisconnect(client)
{
@ -98,10 +98,10 @@ WeaponRestrictClientDisconnect(client)
/**
* Command callback function for the "buy" command
* Used to block use of this command under certain conditions
* Used to block use of this command under certain conditions.
*
* @param client The client index.
* @param argc Argument count
* @param argc Argument count.
*/
public Action:WeaponRestrictBuyHook(client, argc)
{
@ -141,12 +141,12 @@ public Action:WeaponRestrictBuyHook(client, argc)
}
/**
* Restricts a weapon
* Restricts a weapon.
*
* @param weapon The weapon/group name.
* @return Successful_Weapon: The call successfully restricted a weapon.
* Successful_Group: The call successfully restricted a weapon group.
* Invalid: The call was unsuccessful due to invalid weapon.
* Invalid: The call was unsuccessful due to invalid weapon.
*/
WpnRestrictQuery:WeaponRestrictRestrict(const String:weapon[])
{
@ -183,7 +183,7 @@ WpnRestrictQuery:WeaponRestrictRestrict(const String:weapon[])
}
/**
* Unrestricts a weapon
* Unrestricts a weapon.
*
* @param weapon The weapon/group name.
* @return Successful_Weapon: The call successfully restricted a weapon.