AMXX plugins collection

Description

Collection of my plugins for Half-Life Dedicated Server (Counter Strike 1.6 game server) written on Pawn language. There are different types of game modifications - from administrative to entertainment. Demonstrations in gallery above, sources on Git link below.

My profile on Dev-CS.ru

Details

Technologies Pawn, AmxModX, ReAPI, ReHLDS, nVault
Date August 2021
Github https://github.com/zakandaiev/AMXX-plugins

Code snippets

clike [Pawn] Check time in range

// variables declaration skipped

cvar[TIME_START] = get_int_time("22:00");
cvar[TIME_END] = get_int_time("6:00");

CheckForNight() {
	game[IS_NIGHT] = false;

	new hours, mins; time(hours, mins);
	new cur_time = hours * 60 + mins;

	if(cvar[TIME_START] <= cvar[TIME_END]) {
		if(cvar[TIME_START] <= cur_time <= cvar[TIME_END]) {
			game[IS_NIGHT] = true;
		}
	} else {
		if(cvar[TIME_START] <= cur_time <= 24 * 60 || cur_time <= cvar[TIME_END]) {
			game[IS_NIGHT] = true;
		}
	}
}

stock get_int_time(string[]) {
	new left[4], right[4]; strtok(string, left, charsmax(left), right, charsmax(right), ':');
	return str_to_num(left) * 60 + str_to_num(right);
}

clike [AMXX+ReAPI] Screen fade stock

#include <amxmodx>
#include <reapi>

stock screen_fade(id, red, green, blue, alfa, durration) {
	if(!is_user_connected(id) || is_user_bot(id)) {
		return;
	}

	if(bool:(Float:get_member(id, m_blindStartTime) + Float:get_member(id, m_blindFadeTime) >= get_gametime())) {
		return;
	}

	new dUnits = clamp((durration * (1 << 12)), 0, 0xFFFF);

	static userMessage_ScreenFade;
	if(userMessage_ScreenFade > 0 || (userMessage_ScreenFade = get_user_msgid("ScreenFade"))) {
		message_begin(MSG_ONE_UNRELIABLE, userMessage_ScreenFade, .player = id);
		write_short(dUnits);
		write_short(dUnits/2);
		write_short(0x0000);
		write_byte(red);
		write_byte(green);
		write_byte(blue);
		write_byte(alfa);
		message_end();
	}
}