Skip to content

Commit

Permalink
Merge pull request #32 from Giferns/patch-1
Browse files Browse the repository at this point in the history
fix `rt_force_fwd_mode 1` behavior
  • Loading branch information
Giferns authored Sep 13, 2024
2 parents bb4ed18 + 88b43d5 commit cde0d6f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
2 changes: 1 addition & 1 deletion addons/amxmodx/scripting/include/rt_api.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#endif
#define _rt_api_included

public stock const VERSION[] = "2.3.14";
public stock const VERSION[] = "2.3.15";
public stock const AUTHORS[] = "DEV-CS.RU Community";

/**
Expand Down
37 changes: 25 additions & 12 deletions addons/amxmodx/scripting/rt_sounds.sma
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public stock const INI_FILE[] = "addons/amxmodx/configs/rt_configs/rt_sounds.ini

enum CVARS {
Float:SOUND_RADIUS,
NEARBY_PLAYERS
NEARBY_PLAYERS,
FORCE_FWD_MODE
};

new g_eCvars[CVARS];
Expand All @@ -30,15 +31,16 @@ enum sections_struct {
new sections_struct:g_eCurrentSection;
new g_iSounds[sections_struct];
new g_szSounds[sections_struct][MAX_SOUNDS_PER_SECTION][MAX_SOUND_LENGTH];
new g_iTicks[MAX_PLAYERS + 1];

public plugin_precache() {
register_plugin(PLUGIN, VERSION, AUTHORS);

if(!file_exists(INI_FILE)) {
set_fail_state("[RT Sounds] File ^"%s^" not found", INI_FILE);
return;
}

new INIParser:iParser = INI_CreateParser();
INI_SetReaders(iParser, "ReadKeyValue", "ReadNewSection");
INI_ParseFile(iParser, INI_FILE);
Expand All @@ -51,24 +53,30 @@ public plugin_precache() {
}

public rt_revive_start(const iEnt, const iPlayer, const iActivator, const Modes:eMode) {
g_iTicks[iActivator] = 0;

switch(eMode) {
case MODE_REVIVE: { PlaybackSound(iEnt, iPlayer, iActivator, SECTION_REVIVE_START); }
case MODE_PLANT: { PlaybackSound(iEnt, iPlayer, iActivator, SECTION_PLANT_START); }
}
}

public rt_revive_loop_post(const iEnt, const iPlayer, const iActivator, const Float:fTimer, Modes:eMode) {
switch(eMode) {
case MODE_REVIVE: { PlaybackSound(iEnt, iPlayer, iActivator, SECTION_REVIVE_LOOP); }
case MODE_PLANT: { PlaybackSound(iEnt, iPlayer, iActivator, SECTION_PLANT_LOOP); }
if(!g_eCvars[FORCE_FWD_MODE] || ++g_iTicks[iActivator] == 10) {
g_iTicks[iActivator] = 0;

switch(eMode) {
case MODE_REVIVE: { PlaybackSound(iEnt, iPlayer, iActivator, SECTION_REVIVE_LOOP); }
case MODE_PLANT: { PlaybackSound(iEnt, iPlayer, iActivator, SECTION_PLANT_LOOP); }
}
}
}

public rt_revive_end(const iEnt, const iPlayer, const iActivator, const Modes:eMode) {
switch(eMode) {
case MODE_REVIVE: {
new Modes:iMode = Modes:get_entvar(iEnt, var_iuser3);

if(iMode != MODE_PLANT)
PlaybackSound(iEnt, iPlayer, iActivator, SECTION_REVIVE_END);
}
Expand Down Expand Up @@ -101,21 +109,21 @@ public bool:ReadNewSection(INIParser:iParser, const szSection[], bool:bInvalidTo
g_eCurrentSection = SECTION_PLANT_END;
return true;
}

return false;
}

public bool:ReadKeyValue(INIParser:iParser, const szKey[], const szValue[]) {
if(szKey[0] == EOS)
return false;

new szSound[MAX_SOUND_LENGTH];
copy(szSound, charsmax(szSound), szKey);
trim(szSound);
copy(g_szSounds[g_eCurrentSection][g_iSounds[g_eCurrentSection]++], charsmax(g_szSounds[][]), szSound);

precache_sound(szSound);

return true;
}

Expand All @@ -135,7 +143,7 @@ stock PlaybackSoundNearbyPlayers(const iPlayer, const szSound[]) {

new Float:fVecOrigin[3];
get_entvar(iPlayer, var_vuser4, fVecOrigin);

while((iEnt = engfunc(EngFunc_FindEntityInSphere, iEnt, fVecOrigin, g_eCvars[SOUND_RADIUS])) > 0)
if(ExecuteHam(Ham_IsPlayer, iEnt))
rg_send_audio(iEnt, szSound);
Expand All @@ -162,4 +170,9 @@ public CreateCvars() {
2.0),
g_eCvars[NEARBY_PLAYERS]
);

new pCvar = get_cvar_pointer("rt_force_fwd_mode");

if(pCvar)
bind_pcvar_num(pCvar, g_eCvars[FORCE_FWD_MODE]);
}
28 changes: 20 additions & 8 deletions addons/amxmodx/scripting/rt_timer.sma
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ enum CVARS {
REVIVE_COLORS[MAX_COLORS_LENGTH],
REVIVE_COORDS[MAX_COORDS_LENGTH],
PLANTING_COLORS[MAX_COLORS_LENGTH],
PLANTING_COORDS[MAX_COORDS_LENGTH]
PLANTING_COORDS[MAX_COORDS_LENGTH],
FORCE_FWD_MODE
};

new g_eCvars[CVARS];
Expand Down Expand Up @@ -40,12 +41,12 @@ new const TIMER_REPLACE_SYMB[] = "| -";
new const TIMER_REPLACE_WITH[] = "| |";

new g_szTimer[MAX_PLAYERS + 1][64];

new g_iHudSyncObj;
new g_iTicks[MAX_PLAYERS + 1];

public plugin_precache() {
CreateCvars();

server_cmd("exec %s", CFG_FILE);
server_exec();

Expand Down Expand Up @@ -82,7 +83,7 @@ public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHORS);

register_dictionary("rt_library.txt");

if(!g_eCvars[TIMER_TYPE])
g_iHudSyncObj = CreateHudSyncObj();

Expand All @@ -92,6 +93,8 @@ public plugin_init() {
}

public rt_revive_start(const iEnt, const iPlayer, const iActivator, const Modes:eMode) {
g_iTicks[iActivator] = 0;

switch(g_eCvars[TIMER_TYPE]) {
case 0: {
formatex(g_szTimer[iPlayer], charsmax(g_szTimer[]), TIMER_BEGIN);
Expand All @@ -113,10 +116,14 @@ public rt_revive_start(const iEnt, const iPlayer, const iActivator, const Modes:
}

public rt_revive_loop_post(const iEnt, const iPlayer, const iActivator, const Float:fTimer, Modes:eMode) {
if(!g_eCvars[TIMER_TYPE]) {
replace(g_szTimer[iPlayer], charsmax(g_szTimer[]), TIMER_REPLACE_SYMB, TIMER_REPLACE_WITH);
if(!g_eCvars[FORCE_FWD_MODE] || ++g_iTicks[iActivator] == 10) {
g_iTicks[iActivator] = 0;

if(!g_eCvars[TIMER_TYPE]) {
replace(g_szTimer[iPlayer], charsmax(g_szTimer[]), TIMER_REPLACE_SYMB, TIMER_REPLACE_WITH);

DisplayHudMessage(iPlayer, iActivator, eMode);
DisplayHudMessage(iPlayer, iActivator, eMode);
}
}
}

Expand All @@ -129,7 +136,7 @@ public rt_revive_cancelled(const iEnt, const iPlayer, const iActivator, const Mo
case 1: {
if(iActivator != RT_NULLENT)
rg_send_bartime(iActivator, 0);

if(eMode == MODE_REVIVE && iPlayer != RT_NULLENT)
rg_send_bartime(iPlayer, 0);
}
Expand Down Expand Up @@ -186,4 +193,9 @@ public CreateCvars() {
g_eCvars[PLANTING_COORDS],
charsmax(g_eCvars[PLANTING_COORDS])
);

new pCvar = get_cvar_pointer("rt_force_fwd_mode");

if(pCvar)
bind_pcvar_num(pCvar, g_eCvars[FORCE_FWD_MODE]);
}

0 comments on commit cde0d6f

Please sign in to comment.