Skip to content

Commit

Permalink
Merge pull request #7 from byjumpe/alpha-release
Browse files Browse the repository at this point in the history
Updating the repository, releasing fixes, refactoring, expanding functionality.
  • Loading branch information
d3m37r4 authored Nov 29, 2023
2 parents a022a6b + 812a4a8 commit 450cd59
Show file tree
Hide file tree
Showing 22 changed files with 377 additions and 72 deletions.
1 change: 1 addition & 0 deletions cstrike/addons/amxmodx/configs/plugins-regg.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ regg_leader.amxx debug
regg_map_cleaner.amxx debug
regg_notify.amxx debug
regg_warmup.amxx debug
regg_show_winner.amxx debug
2 changes: 1 addition & 1 deletion cstrike/addons/amxmodx/configs/regg/regg-levels.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ points=3
mod=100

[LEVEL]
title=Scount
title=Scout
weapon=weapon_scout
points=2
mod=100
Expand Down
11 changes: 6 additions & 5 deletions cstrike/addons/amxmodx/configs/regg/regg-main.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ regg_ammo_amount "200"
// Восстанавливать патроны в обойме за убийство
regg_refill_on_kill "1"

// Сколько брони выдавать при спавне
regg_give_armor "100"

// Давать шлем с броней или нет
regg_give_helmet "1"
// Давать броню при спавне игрока?
// 0 - Без брони
// 1 - Только броню
// 2 - Броню и Шлем
//
regg_free_armor 0

// Время разминки в секундах
regg_warmup_time "60"
Expand Down
10 changes: 10 additions & 0 deletions cstrike/addons/amxmodx/configs/regg/regg-vote.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[vote_mode]
team
single
ffa

[vote_setting]
startvotetime = 10
votetime = 15
freeze = 0
screenfade = 0
8 changes: 8 additions & 0 deletions cstrike/addons/amxmodx/data/lang/regg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ REGG_STEAL_POINTS = ^3%n ^1украл ^4%d ^1очка у ^4%n
REGG_WARMUP_HUD = Разминочный раунд
REGG_WARMUP_START = Начался разминочный раунд!
REGG_WARMUP_END = Разминка завершена!^rПриготовьтесь к бою, игра началась!

REGG_VOTE_MENU = Голосование за выбор режима игры:
REGG_MODE_SINGLE = Одиночный
REGG_MODE_TEAM = Командный
REGG_MODE_FFA = FFA
REGG_PLAYER_VOTE = Игрок ^4%n ^1проголосовал за режим ^4%s
REGG_END_VOTE = Голосование окончено, выбран режим игры ^4%s
REGG_VOTE_ENDED = Голосование уже окончено!
4 changes: 2 additions & 2 deletions cstrike/addons/amxmodx/scripting/include/regg.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
**/

#define REGG_MAJOR_VERSION 0
#define REGG_MINOR_VERSION 2
#define REGG_MAINTENANCE_VERSION 26
#define REGG_MINOR_VERSION 3
#define REGG_MAINTENANCE_VERSION 32

#define REGG_VERSION str_to_num(fmt("%d%d%d", REGG_MAJOR_VERSION, REGG_MINOR_VERSION, REGG_MAINTENANCE_VERSION))
#define REGG_VERSION_STR fmt("%d.%d.%d-alpha", REGG_MAJOR_VERSION, REGG_MINOR_VERSION, REGG_MAINTENANCE_VERSION)
Expand Down
17 changes: 5 additions & 12 deletions cstrike/addons/amxmodx/scripting/regg/config.inl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ enum _:config_s {
CfgAWPOneShot,
CfgAmmoAmount,
CfgRefillOnKill,
CfgGiveArmor,
CfgGiveHelmet,
CfgFreeArmor,
};

enum config_section_s {
Expand Down Expand Up @@ -95,18 +94,12 @@ registerCvars() {
), Config[CfgRefillOnKill]);

bind_pcvar_num(create_cvar(
"regg_give_armor", "100",
.has_min = true,
.min_val = 0.0
), Config[CfgGiveArmor]);

bind_pcvar_num(create_cvar(
"regg_give_helmet", "1",
"regg_free_armor", "0",
.has_min = true,
.min_val = 0.0,
.has_max = true,
.max_val = 1.0
), Config[CfgGiveHelmet]);
.max_val = 2.0
), Config[CfgFreeArmor]);
}

changeGameCvars() {
Expand Down Expand Up @@ -159,7 +152,7 @@ changeGameCvars() {
} else {
pcvar = get_cvar_pointer("mp_friendlyfire");
GameCvars[GCFriendlyFire] = get_pcvar_num(pcvar);
set_pcvar_num(pcvar, 1);
set_pcvar_num(pcvar, 0);
}
}

Expand Down
43 changes: 36 additions & 7 deletions cstrike/addons/amxmodx/scripting/regg/functions.inl
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,14 @@ ReGG_Result:killKnife(const killer, const victim) {
}

giveDefaultWeapons(const id) {
if(Config[CfgGiveArmor] > 0) {
rg_set_user_armor(id, Config[CfgGiveArmor], Config[CfgGiveHelmet] ? ARMOR_VESTHELM : ARMOR_KEVLAR);
switch(ArmorType:Config[CfgFreeArmor]) {
case ARMOR_KEVLAR: {
rg_set_user_armor(id, 100, ARMOR_KEVLAR);
}
case ARMOR_VESTHELM: {
rg_set_user_armor(id, 100, ARMOR_VESTHELM);
}
}

rg_give_item(id, "weapon_knife");
}

Expand Down Expand Up @@ -192,8 +196,16 @@ removeWeapon(const id, const level) {
return;
}
new WeaponIdType:wid = Levels[level][LevelWeaponID];
if(wid != WEAPON_KNIFE) {
new wname[32];
new wname[32];
if(wid == WEAPON_HEGRENADE) {
for(new i = 0; i < GrenadeWeaponsNum; i++) {
rg_get_weapon_info(GrenadeWeapons[i], WI_NAME, wname, charsmax(wname));
rg_remove_item(id, wname, true);
}
rg_get_weapon_info(wid, WI_NAME, wname, charsmax(wname));
rg_remove_item(id, wname, true);
}
else if(wid != WEAPON_KNIFE) {
rg_get_weapon_info(wid, WI_NAME, wname, charsmax(wname));
rg_remove_item(id, wname, true);
}
Expand Down Expand Up @@ -603,8 +615,25 @@ getTeamSlot(const id) {
}

getTeamLevelPoints(const slot, const level) {
new points = getTeamPlayers(slot) * Levels[level][LevelPoints];
return Levels[level][LevelMod] != 100 ? Levels[level][LevelMod] * points / 100 : points;
new points;
new point_s = getTeamPlayers(slot) * Levels[level][LevelPoints];
new lvlmod = Levels[level][LevelMod];
if(lvlmod != 100) {
points = roundPoints(lvlmod, point_s);
} else {
points = point_s;
}

return points;
}

roundPoints(num1, num2) {
new Float:fNum1 = float(num1);
new Float:fNum2 = float(num2);
new Float:value = fNum1 * fNum2 / 100.0;
new num = floatround(value, floatround_ceil);

return num;
}

getTeamPlayers(const slot) {
Expand Down
29 changes: 14 additions & 15 deletions cstrike/addons/amxmodx/scripting/regg/hooks.inl
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,21 @@ public SV_DropClient_Post(const id) {
}

public CSGameRules_RestartRound_Pre() {
if(!get_member_game(m_bCompleteReset)) {
return HC_CONTINUE;
}
for(new player = 1; player <= MaxClients; player++) {
Players[player][PlayerPoints] = 0;
Players[player][PlayerLevel] = 0;

if(is_user_connected(player) && (TEAM_TERRORIST <= TeamName:get_member(player, m_iTeam) <= TEAM_CT)) {
rg_remove_all_items(player, true);
giveDefaultWeapons(player);
giveWeapon(player, 0);
if(get_member_game(m_bCompleteReset)) {
for(new player = 1; player <= MaxClients; player++) {
Players[player][PlayerPoints] = 0;
Players[player][PlayerLevel] = 0;

if(is_user_connected(player) && (TEAM_TERRORIST <= TeamName:get_member(player, m_iTeam) <= TEAM_CT)) {
rg_remove_all_items(player, true);
giveDefaultWeapons(player);
giveWeapon(player, 0);
}
}
for(new slot = ReGG_SlotT; slot <= ReGG_SlotCT; slot++) {
Teams[slot][TeamPoints] = 0;
Teams[slot][TeamLevel] = 0;
}
}
for(new slot = ReGG_SlotT; slot <= ReGG_SlotCT; slot++) {
Teams[slot][TeamPoints] = 0;
Teams[slot][TeamLevel] = 0;
}
return HC_CONTINUE;
}
Expand Down
2 changes: 1 addition & 1 deletion cstrike/addons/amxmodx/scripting/regg_balancer.sma
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
new bool:BalanceTeams = false;

public plugin_init() {
register_plugin("[ReGG] Balancer", REGG_VERSION_STR, "F@nt0M");
register_plugin("[ReGG] Balancer", REGG_VERSION_STR, "Jumper & d3m37r4");

RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", true);
RegisterHookChain(RG_CBasePlayer_CanSwitchTeam, "CBasePlayer_CanSwitchTeam_Pre", false);
Expand Down
2 changes: 1 addition & 1 deletion cstrike/addons/amxmodx/scripting/regg_controller.sma
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum {
new Mode;

public plugin_init() {
register_plugin("[ReGG] Controller", REGG_VERSION_STR, "F@nt0M");
register_plugin("[ReGG] Controller", REGG_VERSION_STR, "Jumper & d3m37r4");
bind_pcvar_num(create_cvar(
"regg_mode", "0",
.has_min = true, .min_val = 0.0,
Expand Down
2 changes: 1 addition & 1 deletion cstrike/addons/amxmodx/scripting/regg_core.sma
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public plugin_natives() {
}

public plugin_init() {
register_plugin("[ReGG] Core", REGG_VERSION_STR, "F@nt0M");
register_plugin("[ReGG] Core", REGG_VERSION_STR, "Jumper & d3m37r4");

register_dictionary("regg.txt");

Expand Down
2 changes: 1 addition & 1 deletion cstrike/addons/amxmodx/scripting/regg_informer.sma
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ new SyncHudStats;
new PlayerInfos[MAX_PLAYERS + 1][256];

public plugin_init() {
register_plugin("[ReGG] Informer", REGG_VERSION_STR, "F@nt0M");
register_plugin("[ReGG] Informer", REGG_VERSION_STR, "Jumper & d3m37r4");
SyncHudStats = CreateHudSyncObj();
state disabled;
}
Expand Down
2 changes: 1 addition & 1 deletion cstrike/addons/amxmodx/scripting/regg_leader.sma
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ new SyncHudStats;
new LeaderInfo[256];

public plugin_init() {
register_plugin("[ReGG] Leader", REGG_VERSION_STR, "F@nt0M");
register_plugin("[ReGG] Leader", REGG_VERSION_STR, "Jumper & d3m37r4");
SyncHudStats = CreateHudSyncObj();
state none;
}
Expand Down
2 changes: 1 addition & 1 deletion cstrike/addons/amxmodx/scripting/regg_map_cleaner.sma
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ new bool:CTCantBuy, bool:TCantBuy;
new bool:MapHasBombTarget, bool:MapHasBombZone, bool:MapHasRescueZone, bool:MapHasEscapeZone, bool:MapHasVIPSafetyZone;

public plugin_init() {
register_plugin("[ReGG] Map Cleaner", REGG_VERSION_STR, "F@nt0M");
register_plugin("[ReGG] Map Cleaner", REGG_VERSION_STR, "Jumper & d3m37r4");

bind_pcvar_num(create_cvar(
"regg_block_map_conditions", "1",
Expand Down
2 changes: 1 addition & 1 deletion cstrike/addons/amxmodx/scripting/regg_mapmanager.sma
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
new VoteType;

public plugin_init() {
register_plugin("[ReGG] Map Manager", REGG_VERSION_STR, "F@nt0M");
register_plugin("[ReGG] Map Manager", REGG_VERSION_STR, "Jumper & d3m37r4");

bind_pcvar_num(create_cvar(
"regg_mapchange_type", "1",
Expand Down
2 changes: 1 addition & 1 deletion cstrike/addons/amxmodx/scripting/regg_motd.sma
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
new const STYLES_URL[] = "http://localhost/regungame.css";

public plugin_init() {
register_plugin("[ReGG] MOTD", REGG_VERSION_STR, "F@nt0M");
register_plugin("[ReGG] MOTD", REGG_VERSION_STR, "Jumper & d3m37r4");
}

public ReGG_FinishPost(const killer, const victim) {
Expand Down
36 changes: 25 additions & 11 deletions cstrike/addons/amxmodx/scripting/regg_notify.sma
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public plugin_precache() {
}

public plugin_init() {
register_plugin("[ReGG] Notify", REGG_VERSION_STR, "F@nt0M");
register_plugin("[ReGG] Notify", REGG_VERSION_STR, "Jumper & d3m37r4");
state none;

firtKnifeLvl = true;
Expand All @@ -92,7 +92,7 @@ public ReGG_StartPost(const ReGG_Mode:mode) {

public ReGG_FinishPost() {
state none;
PlaySound(0, fmt("%a", ArrayGetStringHandle(Winner, random(WinnerNum))));
PlaySound(0, Winner, WinnerNum);
}

public ReGG_KillEnemyPost(const killer, const victim, const WeaponIdType:value, const ReGG_Result:result) <single> {
Expand All @@ -104,7 +104,7 @@ public ReGG_KillEnemyPost(const killer, const victim, const WeaponIdType:value,
case ReGG_ResultPointsDown: {}

case ReGG_ResultLevelUp: {
PlaySound(killer, fmt("%a", ArrayGetStringHandle(LevelUp, random(LevelUpNum))));
PlaySound(killer, LevelUp, LevelUpNum);

new level = ReGG_GetLevel(killer);
new title[32];
Expand All @@ -113,7 +113,7 @@ public ReGG_KillEnemyPost(const killer, const victim, const WeaponIdType:value,
}

case ReGG_ResultLevelDown: {
PlaySound(killer, fmt("%a", ArrayGetStringHandle(LevelDown, random(LevelDownNum))));
PlaySound(killer, LevelDown, LevelDownNum);
new level = ReGG_GetLevel(killer);
new title[32];
ReGG_GetLevelTitle(level, title, charsmax(title));
Expand Down Expand Up @@ -156,7 +156,7 @@ notifyTeam(const slot, const level, const ReGG_Result:result) {
switch(result) {
case ReGG_ResultLevelUp: {
if(playerSlot == slot) {
PlaySound(player, fmt("%a", ArrayGetStringHandle(LevelUp, random(LevelUpNum))));
PlaySound(player, LevelUp, LevelUpNum);
client_print_color(player, print_team_default, "%L %L", LANG_PLAYER, "REGG_PREFIX", LANG_PLAYER, "REGG_LVL_TEAM_UP", level + 1, title);
} else {
client_print_color(
Expand All @@ -168,7 +168,7 @@ notifyTeam(const slot, const level, const ReGG_Result:result) {

case ReGG_ResultLevelDown: {
if(playerSlot == slot) {
PlaySound(player, fmt("%a", ArrayGetStringHandle(LevelDown, random(LevelDownNum))));
PlaySound(player, LevelDown, LevelDownNum);
client_print_color(player, print_team_default, "%L %L", LANG_PLAYER, "REGG_PREFIX", LANG_PLAYER, "REGG_LVL_TEAM_DOWN", level + 1, title);
} else {
client_print_color(
Expand Down Expand Up @@ -196,10 +196,10 @@ public ReGG_StealPointsPost(const killer, const victim, const value) <none> {}
public ReGG_GiveWeaponPost(const id, const WeaponIdType:value) {
if(fistGrenadeLvl && value == WEAPON_HEGRENADE) {
fistGrenadeLvl = false;
PlaySound(0, fmt("%a", ArrayGetStringHandle(GrenadeLevel, random(GrenadeLevelNum))));
PlaySound(0, GrenadeLevel, GrenadeLevelNum);
} else if (firtKnifeLvl && value == WEAPON_KNIFE) {
firtKnifeLvl = false;
PlaySound(0, fmt("%a", ArrayGetStringHandle(KnifeLevel, random(KnifeLevelNum))));
PlaySound(0, KnifeLevel, KnifeLevelNum);
}
}

Expand Down Expand Up @@ -280,13 +280,21 @@ bool:PrecacheSoundEx(Array:arr, const keys[]) {
log_amx("Invalid sound file! Parse string '%s'. Only sound files in wav or mp3 format should be used!", keys);
return false;
}

static Sound[MAX_RESOURCE_PATH_LENGTH];
formatex(Sound, charsmax(Sound), "sound/%s", keys);
ArrayPushString(arr, Sound);

if(IsMp3Format(keys)) {
ArrayPushString(arr, Sound);
} else {
ArrayPushString(arr, keys);
}

if(!file_exists(Sound)) {
log_amx("File missing '%s'.", Sound);
return false;
}

if(IsMp3Format(keys)) {
precache_generic(Sound);
} else {
Expand All @@ -296,9 +304,15 @@ bool:PrecacheSoundEx(Array:arr, const keys[]) {
return true;
}

PlaySound(const id, const sound[]) {
PlaySound(const id, Array:arr, const arr_num) {
if(arr_num == 0) {
return;
}
static sound[MAX_RESOURCE_PATH_LENGTH];
ArrayGetString(arr, random(arr_num), sound, charsmax(sound));

if(IsMp3Format(sound)) {
client_cmd(id, "stopsound; mp3 play %s", sound);
client_cmd(id, "mp3 play %s", sound);
} else {
rg_send_audio(id, sound);
}
Expand Down
Loading

0 comments on commit 450cd59

Please sign in to comment.