Skip to content

Commit

Permalink
Added class VIP using Sourcemod Admin Flag
Browse files Browse the repository at this point in the history
  • Loading branch information
oylsister committed Mar 8, 2021
1 parent cbc512d commit 61af2b7
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 26 deletions.
12 changes: 12 additions & 0 deletions csgo/addons/sourcemod/configs/zr/playerclasses.txt
Expand Up @@ -21,6 +21,7 @@
// 1 - Admins only
// 2 - Mother zombies only
// group text Restrict class to member of this SourceMod group. Leave blank for no restriction.
// sm_flags text Restrict class to client of this SourceMod admin flag. Leave blank for no restriction.
// name text The class name used in class menu.
// description text The class description used in class menu.
// model_path text Path to model to use. Relative to cstrike folder.
Expand Down Expand Up @@ -74,6 +75,7 @@
"team_default" "yes"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Classic"
"description" "Need brains!!! Arrrrggghh!"
Expand Down Expand Up @@ -120,6 +122,7 @@
"team_default" "no"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Fast"
"description" "-HP | +Speed | +Jump | +Knockback"
Expand Down Expand Up @@ -166,6 +169,7 @@
"team_default" "no"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Mutated"
"description" "+HP | -Speed | +Jump | +Knockback"
Expand Down Expand Up @@ -212,6 +216,7 @@
"team_default" "no"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Heavy"
"description" "+HP | -Speed | -Knockback"
Expand Down Expand Up @@ -258,6 +263,7 @@
"team_default" "no"
"flags" "2"
"group" ""
"sm_flags" ""

"name" "Mother zombie"
"description" "+HP regen | +Speed | +Jump | -Knockback"
Expand Down Expand Up @@ -304,6 +310,7 @@
"team_default" "no"
"flags" "3"
"group" ""
"sm_flags" ""

"name" "Admin mother zombie"
"description" "+HP regen | +Speed | +Jump | -Knockback"
Expand Down Expand Up @@ -356,6 +363,7 @@
"team_default" "yes"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Normal Human"
"description" "Default Counter-Strike settings"
Expand Down Expand Up @@ -402,6 +410,7 @@
"team_default" "yes"
"flags" "0"
"group" "" // Write the name of a SourceMod group for vip players ("zr_vip" for instance), then make it in SourceMod.
"sm_flags" "" // Write the adminf flag of a sourcemod for vip players ("ao" for instance)

"name" "VIP Human"
"description" "Human class for important players"
Expand Down Expand Up @@ -448,6 +457,7 @@
"team_default" "no"
"flags" "1"
"group" ""
"sm_flags" ""

"name" "Admin Human"
"description" "Human class for admins"
Expand Down Expand Up @@ -494,6 +504,7 @@
"team_default" "no"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Speedy"
"description" "+Speed"
Expand Down Expand Up @@ -540,6 +551,7 @@
"team_default" "no"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Light"
"description" "-Speed | +Jump | +Immunity"
Expand Down
12 changes: 12 additions & 0 deletions cstrike/addons/sourcemod/configs/zr/playerclasses.txt
Expand Up @@ -21,6 +21,7 @@
// 1 - Admins only
// 2 - Mother zombies only
// group text Restrict class to member of this SourceMod group. Leave blank for no restriction.
// sm_flags text Restrict class to client of this SourceMod admin flag. Leave blank for no restriction.
// name text The class name used in class menu.
// description text The class description used in class menu.
// model_path text Path to model to use. Relative to cstrike folder.
Expand Down Expand Up @@ -74,6 +75,7 @@
"team_default" "yes"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Classic"
"description" "Need brains!!! Arrrrggghh!"
Expand Down Expand Up @@ -120,6 +122,7 @@
"team_default" "no"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Fast"
"description" "-HP | +Speed | +Jump | +Knockback"
Expand Down Expand Up @@ -166,6 +169,7 @@
"team_default" "no"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Mutated"
"description" "+HP | -Speed | +Jump | +Knockback"
Expand Down Expand Up @@ -212,6 +216,7 @@
"team_default" "no"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Heavy"
"description" "+HP | -Speed | -Knockback"
Expand Down Expand Up @@ -258,6 +263,7 @@
"team_default" "no"
"flags" "2"
"group" ""
"sm_flags" ""

"name" "Mother zombie"
"description" "+HP regen | +Speed | +Jump | -Knockback"
Expand Down Expand Up @@ -304,6 +310,7 @@
"team_default" "no"
"flags" "3"
"group" ""
"sm_flags" ""

"name" "Admin mother zombie"
"description" "+HP regen | +Speed | +Jump | -Knockback"
Expand Down Expand Up @@ -356,6 +363,7 @@
"team_default" "yes"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Normal Human"
"description" "Default Counter-Strike settings"
Expand Down Expand Up @@ -402,6 +410,7 @@
"team_default" "yes"
"flags" "0"
"group" "" // Write the name of a SourceMod group for vip players ("zr_vip" for instance), then make it in SourceMod.
"sm_flags" ""

"name" "VIP Human"
"description" "Human class for important players"
Expand Down Expand Up @@ -448,6 +457,7 @@
"team_default" "no"
"flags" "1"
"group" ""
"sm_flags" ""

"name" "Admin Human"
"description" "Human class for admins"
Expand Down Expand Up @@ -494,6 +504,7 @@
"team_default" "no"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Speedy"
"description" "+Speed"
Expand Down Expand Up @@ -540,6 +551,7 @@
"team_default" "no"
"flags" "0"
"group" ""
"sm_flags" ""

"name" "Light"
"description" "-Speed | +Jump | +Immunity"
Expand Down
2 changes: 1 addition & 1 deletion src/zombiereloaded.sp
Expand Up @@ -53,7 +53,7 @@



#define VERSION "3.6 Franug edition"
#define VERSION "3.6.1 Franug edition"

bool g_allweapons[MAXPLAYERS + 1];

Expand Down
39 changes: 39 additions & 0 deletions src/zr/playerclasses/attributes.inc
Expand Up @@ -234,6 +234,41 @@ stock ClassGetGroup(index, String:buffer[], maxlen, cachetype = ZR_CLASS_CACHE_P
return -1;
}

/**
* Gets the class sourcemod flags required to use the class.
*
* @param index Index of the class in a class cache or a client index,
* depending on the cache type specified.
* @param buffer The destination string buffer.
* @param maxlen The length of the destination string buffer.
* @param cachetype Optional. Specifies what class cache to read from. Options:
* ZR_CLASS_CACHE_ORIGINAL - Unchanced class data.
* ZR_CLASS_CACHE_MODIFIED - Changed/newest class data.
* ZR_CLASS_CACHE_PLAYER (default) - Player cache. If this one
* is used, index will be used as a client index.
* @return Number of cells written. -1 on error.
*/
stock ClassGetSM_Flags(index, String:buffer[], maxlen, cachetype = ZR_CLASS_CACHE_PLAYER)
{
switch (cachetype)
{
case ZR_CLASS_CACHE_ORIGINAL:
{
return strcopy(buffer, maxlen, ClassData[index][Class_SM_Flags]);
}
case ZR_CLASS_CACHE_MODIFIED:
{
return strcopy(buffer, maxlen, ClassDataCache[index][Class_SM_Flags]);
}
case ZR_CLASS_CACHE_PLAYER:
{
return strcopy(buffer, maxlen, ClassPlayerCache[index][Class_SM_Flags]);
}
}

return -1;
}

/**
* Gets the class name displayed in the class menu.
*
Expand Down Expand Up @@ -1157,6 +1192,10 @@ stock ClassAttributeNameToFlag(const String:attributename[])
{
return ZR_CLASS_GROUP;
}
else if (StrEqual(attributename, "sm_flags", false))
{
return ZR_CLASS_SM_FLAGS;
}
else if (StrEqual(attributename, "name", false))
{
return ZR_CLASS_NAME;
Expand Down
5 changes: 5 additions & 0 deletions src/zr/playerclasses/classcommands.inc
Expand Up @@ -903,6 +903,11 @@ stock ClassModifyString(classindex, attributeflag, const String:value[])
strcopy(ClassDataCache[classindex][Class_Group], 64, value);
return true;
}
case ZR_CLASS_SM_FLAGS:
{
strcopy(ClassDataCache[classindex][Class_SM_Flags], 64, value);
return true;
}
case ZR_CLASS_NAME:
{
strcopy(ClassDataCache[classindex][Class_Name], 64, value);
Expand Down
24 changes: 24 additions & 0 deletions src/zr/playerclasses/filtertools.inc
Expand Up @@ -841,6 +841,11 @@ stock bool:ClassFilterMatch(index, filter[ClassFilter], cachetype = ZR_CLASS_CAC
decl String:groupname[64];
groupname[0] = 0;
ClassGetGroup(index, groupname, sizeof(groupname), cachetype);

// Get class sm_flags.
decl String:sm_flags[64];
sm_flags[0] = 0;
ClassGetSM_Flags(index, sm_flags, sizeof(sm_flags), cachetype);

// Check if a client is specified in the filter.
new client = filter[ClassFilter_Client];
Expand All @@ -855,6 +860,19 @@ stock bool:ClassFilterMatch(index, filter[ClassFilter], cachetype = ZR_CLASS_CAC
return false;
}
}
// Check if there are any sm_flags set.
if (strlen(sm_flags))
{
int flags = ReadFlagString(sm_flags);

// No valid flag, blocked for everyone.
if(!flags)
return false;

// Check if user doesn't have the required flags.
if(GetUserFlagBits(client) & flags != flags)
return false;
}
}

// Check if classes with groups are set to be excluded.
Expand All @@ -865,6 +883,12 @@ stock bool:ClassFilterMatch(index, filter[ClassFilter], cachetype = ZR_CLASS_CAC
{
return false;
}

// Exclude class if it requires flags.
if (strlen(sm_flags))
{
return false;
}
}

// The class passed the filter.
Expand Down

0 comments on commit 61af2b7

Please sign in to comment.