// =========================== //
// Native //
// =========================== //
/**
* Check if is Holliday.
*
* @return true/false
*/
native bool:fv_is_holliday();
/**
* Check if is Nights.
*
* @return true/false
*/
native bool:fv_is_nights();
/**
* Check if is Gifts.
*
* @param iPlayer index player
*
* @return true/false
*/
native bool:fv_is_user_gifts(const iPlayer);
/**
* Gets holiday flags.
*
* @return bitsum of flags
*/
native fv_get_holliday_flags();
/**
* Gets Nights flags.
*
* @return bitsum of flags
*/
native fv_get_nights_flags();
/**
* Gets Gifts flags.
*
* @param iPlayer index player
*
* @return bitsum of flags
*/
native fv_get_gifts_flags(const iPlayer);
/**
* Gets Ignor Holliday flags.
*
* @param szBuffer Destination string buffer to copy to
* @param iSize Maximum length of the string buffer
*
* @return The result length
*/
native fv_get_ignor_flags_holliday(szBuffer[], const iSize);
/**
* Gets Ignor Nigths flags.
*
* @param szBuffer Destination string buffer to copy to
* @param iSize Maximum length of the string buffer
*
* @return The result length
*/
native fv_get_ignor_flags_nights(szBuffer[], const iSize);
/**
* Gets Unix time stamp for end Gifts.
*
* @param iPlayer index player
*
* @return Unix time stamp
*/
native fv_get_time_end_gifts(const iPlayer);
/**
* Gets original user flags.
*
* @param iPlayer index player
*
* @return bitsum of flags
*/
native fv_get_user_flags(const iPlayer);
/**
* Gets VipTest flags.
*
* @return bitsum of flags
*/
native fv_get_viptest_flags();
/**
* Check if is GSClient.
*
* @param iPlayer index player
*
* @return true/false
*/
native bool:fv_is_user_gsclient(const iPlayer);
/**
* Gets Ignor VipTest flags.
*
* @param szBuffer Destination string buffer to copy to
* @param iSize Maximum length of the string buffer
*
* @return The result length
*/
native fv_get_ignor_flags_viptest(szBuffer[], const iSize);
/**
* Check if using VipTest.
*
* @param iPlayer index player
*
* @return true/false
*/
native bool:fv_is_user_viptest(const iPlayer);
// =========================== //
// Forwards //
// =========================== //
/**
* Called when a player sets gift flags
*
* @param iPlayer Client index
* @param szAuthid Client authid
* @param bitflags Client bitflags
* @param bitSetFlags Set gift bitflags
*
* @noreturn
*/
forward FV_SetGifts(iPlayer, szAuthid[], iStart, iEnd, bitFlags, bitSetFlags);
/**
* Сalled when gift flags are taken away from the player
*
* @param iPlayer Client index
* @param szAuthid Client authid
* @param bitflags Client bitflags
* @param bitSetFlags Remove gift bitflags
*
* @noreturn
*/
forward FV_RemoveGifts(iPlayer, szAuthid[], bitFlags, bitSetFlags);
/**
* Called when night mode starts
*
* @param iStart Unix start time
* @param iEnd Unix end time
* @param bitSetFlags Set night bitflags
* @param szIgnorFlags Night ignor flags
*
* @noreturn
*/
forward FV_StartNights(iStart, iEnd, bitSetFlags, szIgnorFlags[]);
/**
* Called when night mode end
*
* @param bitSetFlags Remove night bitflags
* @param szIgnorFlags Night ignor flags
*
* @noreturn
*/
forward FV_EndNights(bitFlags, szIgnorFlags[]);
/**
* Called when holliday mode starts
*
* @param iStart Unix start time
* @param iEnd Unix end time
* @param bitSetFlags Set holliday bitflags
* @param szIgnorFlags Holliday ignor flags
*
* @noreturn
*/
forward FV_StartHolliday(iStart, iEnd, bitSetFlags, szIgnorFlags[]);
/**
* Called when holliday mode end
*
* @param bitSetFlags Remove holliday bitflags
* @param szIgnorFlags Holliday ignor flags
*
* @noreturn
*/
forward FV_EndHolliday(bitFlags, szIgnorFlags[]);
/**
* Called when a player sets viptest flags
*
* @param iPlayer Client index
* @param szAuthid Client authid
* @param iTimeEnd Unix end time
* @param bitflags Client bitflags
* @param bitSetFlags Set viptest bitflags
*
* @noreturn
*/
forward FV_SetVipTest(iPlayer, szAuthid[], iTimeEnd, bitFlags, bitSetFlags);
/**
* Сalled when viptest flags are taken away from the player
*
* @param iPlayer Client index
* @param szAuthid Client authid
* @param bitflags Client bitflags
* @param bitSetFlags Remove viptest bitflags
*
* @noreturn
*/
forward FV_RemoveVipTest(iPlayer, szAuthid[], bitFlags, bitSetFlags);
/**
* Called when a player sets clients flags
*
* @param iPlayer Client index
* @param szAuthid Client authid
* @param bitflags Client bitflags
* @param bitSetFlags Set clients bitflags
*
* @noreturn
*/
forward FV_SetClients(iPlayer, szAuthid[], bitFlags, bitSetFlags);
/**
* Сalled when clients flags are taken away from the player
*
* @param iPlayer Client index
* @param szAuthid Client authid
* @param bitflags Client bitflags
* @param bitSetFlags Remove clients bitflags
*
* @noreturn
*/
forward FV_RemoveClients(iPlayer, szAuthid[], bitFlags, bitSetFlags);
// =========================== //
// Stocks //
// =========================== //
/**
* Reading Hud settings (fixed)
*
* @param szHud Array for reading settings
* @param iRed Red saturation
* @param iGreen Green saturation
* @param iBlue Blue saturation
* @param x Location of the message on the x axis in percent
* @param y Location of the message on the y axis in percent
* @param effects Display effect
* @param flFxTime Duration of the effect
* @param flHoldTime Time the message stays on screen
* @param flFadeInTime Time it takes the message to fully appear (fade-in)
* @param flFadeOut Time it takes the message to fully disappear (fade-out)
*
* @noreturn
*/
stock UTIL_ReadHudSettings(const szHud[], &iRed = 255, &iGreen = 255, &iBlue = 255, &Float: x = 0.1, &Float: y = 0.3, &effects,
&Float: flFxTime, &Float: flHoldTime, &Float: flFadeInTime, &Float: flFadeOut)
{
new iStart, iEnd;
iRed = strtol(szHud, iEnd); iStart += iEnd;
iGreen = strtol(szHud[iStart], iEnd); iStart += iEnd;
iBlue = strtol(szHud[iStart], iEnd); iStart += iEnd;
x = strtof(szHud[iStart], iEnd); iStart += iEnd;
y = strtof(szHud[iStart], iEnd); iStart += iEnd;
effects = strtol(szHud[iStart], iEnd); iStart += iEnd;
flFxTime = strtof(szHud[iStart], iEnd); iStart += iEnd;
flHoldTime = strtof(szHud[iStart], iEnd); iStart += iEnd;
flFadeInTime = strtof(szHud[iStart], iEnd); iStart += iEnd;
flFadeOut = strtof(szHud[iStart]);
}
/**
* Checking for flags
*
* @note If there is a dot in front of the flags, then each flag is checked,
* otherwise at least one of them is present. Separation of groups
* separated by a space. https://dev-cs.ru/threads/222/post-158636
*
* @param bitFlags Сhecked flags
* @param szIgnor Trigger flags
*
* @return true/false
*/
stock bool: UTIL_IsIgnorFlags(bitFlags, szIgnor[])
{
new iPos, szFlags[32];
while (iPos != -1)
{
iPos = argparse(szIgnor, iPos, szFlags, charsmax(szFlags));
if (replace(szFlags, charsmax(szFlags), ".", ""))
{
if (bitFlags == (bitFlags | read_flags(szFlags))) return true;
}
else
{
if (bitFlags & read_flags(szFlags)) return true;
}
}
return false;
}
/**
* Checks which of the specified flags the player does not have
*
* @note Checks which of the specified flags the player does not have.
* Original: https://dev-cs.ru/threads/222/post-158636
*
* @param iPlayer Client index
* @param bitFlags Bitsum of specified flags
* @param szOther String for copying flags that the user does not have
*
* @return Bitsum Flags that the user does not have
*/
stock UTIL_GetOtherFlags(const iPlayer, bitFlags, szOther[])
{
bitFlags &= ~get_user_flags(iPlayer);
get_flags(bitFlags, szOther, 31);
return bitFlags;
}
/**
* Issues flags that the user does not have from the specified ones
*
* @param iPlayer Client index
* @param bitFlags Flags to be issued to the user
*
* @return Flags that will be issued to the user
*/
stock add_user_flags(const iPlayer, bitFlags)
{
bitFlags &= ~get_user_flags(iPlayer);
set_user_flags(iPlayer, bitFlags);
return bitFlags;
}
/**
* Gets the number of the day of the week
*
* @return Number of the day of the week
*/
stock UTIL_GetWeekDay()
{
new szTime[4];
get_time("%w", szTime, charsmax(szTime));
return str_to_num(szTime);
}
/**
* Checking the current time in the specified interval
*
* @note Checking for the time in the specified interval
* Original: https://dev-cs.ru/threads/222/post-158636
*
* @param iStart Start time (unix)
* @param iEnd End time (unix)
*
* @return true/false
*/
stock bool: UTIL_IsTimeWithin(const iStart, const iEnd)
{
new iSysTime = get_systime();
if (iStart <= iSysTime && iSysTime <= iEnd) return true;
return false;
}
/**
* Checking that the creation time and duration have passed
*
* @param iCreated Created time (unix)
* @param iLength Length (unix)
*
* @return true/false
*/
stock bool: UTIL_IsTimePassed(const iCreated, const iLength)
{
if (iCreated + iLength <= get_systime()) return true;
return false;
}
/**
* Checks the string for the presence of the chat command symbol and deletes it
*
* @param szBuffer Destination string buffer to copy to
* @param iSize Maximum length of the string buffer
*
* @return true/false
*/
stock bool: UTIL_IsDefaultChatCmd(szBuffer[], const iSize)
{
switch (szBuffer[0])
{
case '/': {replace_all(szBuffer, iSize, "/", "");}
case '!': {replace_all(szBuffer, iSize, "!", "");}
case '.': {replace_all(szBuffer, iSize, ".", "");}
case '?': {replace_all(szBuffer, iSize, "?", "");}
default: {return false;}
}
return true;
}