stock shortNumber(n){
static units[][] = {
"",
"k",
"M",
"G",
"T",
"P",
"E"
};
new digits = n==0? 0 : 1+floatround(floatlog(floatabs(float(n))), floatround_floor);
// determine base 10 exponential
new exp = digits < 4? 0 : 3*((digits-1)/3);
// normalized number
new Float:m = float(n) / floatpower(10.0, float(exp));
new s[32];
format(s, charsmax(s), "%0.f%s", m, units[exp/3]);
return s;
}
#include <fakemeta>
// https://github.com/s1lentq/ReGameDLL_CS/blob/ec98c5db688a2cd26ee9507cb6b21139ce335914/regamedll/dlls/ggrenade.cpp#L590
stock UTIL_CreateSmoke(Float:position[3]) {
static m_usEvent;
if(!m_usEvent)
m_usEvent = engfunc(EngFunc_PrecacheEvent, 1, "events/createsmoke.sc");
engfunc(EngFunc_PlaybackEvent, FEV_GLOBAL, 0, m_usEvent,
0.0, position, Float:{0.0, 0.0, 0.0},
0.0, 0.0, 0, 1, 1, 0
);
}
void CBasePlayerWeapon::ReloadSound()
{
CBasePlayer *pPlayer = nullptr;
while ((pPlayer = UTIL_FindEntityByClassname(pPlayer, "player")))
{
if (pPlayer->IsDormant())
break;
if (pPlayer == m_pPlayer)
continue;
float distance = (m_pPlayer->pev->origin - pPlayer->pev->origin).Length();
if (distance <= MAX_DIST_RELOAD_SOUND)
{
MESSAGE_BEGIN(MSG_ONE, gmsgReloadSound, nullptr, pPlayer->pev);
WRITE_BYTE(int((1.0f - (distance / MAX_DIST_RELOAD_SOUND)) * 255.0f));
if (!Q_strcmp(STRING(pev->classname), "weapon_m3") || !Q_strcmp(STRING(pev->classname), "weapon_xm1014"))
WRITE_BYTE(0);
else
WRITE_BYTE(1);
MESSAGE_END();
}
}
}
const Float: MAX_DIST_RELOAD_SOUND = 512.0;
new iMsgID_ReloadSound;
public plugin_init( ) iMsgID_ReloadSound = get_user_msgid( "ReloadSound" );
stock ReloadSound( const pPlayer, const bool: bShotgun = false )
{
new Float: vecOrigin[ 3 ], Float: vecRecOrigin[ 3 ], Float: flDistance;
for ( new i = 1; i <= MaxClients; i++ )
{
if ( !is_user_connected( i ) )
continue;
if ( pPlayer == i )
continue;
get_entvar( pPlayer, var_origin, vecOrigin );
get_entvar( i, var_origin, vecRecOrigin );
flDistance = get_distance_f( vecOrigin, vecRecOrigin );
if ( flDistance <= MAX_DIST_RELOAD_SOUND )
{
message_begin( MSG_ONE, iMsgID_ReloadSound, _, i );
write_byte( floatround( ( 1.0 - flDistance / MAX_DIST_RELOAD_SOUND ) * 255.0 ) );
write_byte( !bShotgun );
message_end( );
}
}
}
is_user_connected
используется get_entvar( i, var_flags ) & FL_DORMANT
, но я кроме того, что он выставляется при дисконнекте толком ничего не нашел, вот и заменил. Поправьте если не так.Можно вынести за пределы for, и не получать на каждой иттерации.get_entvar( pPlayer, var_origin, vecOrigin );
stock register_clcmd_list(const cmd_list[][], const function[], flags = -1, const info[] = "", FlagManager = -1, bool:info_ml = false, const size = sizeof(cmd_list)) {
#pragma unused info
#pragma unused FlagManager
#pragma unused info_ml
for(new i; i < size; i++) {
register_clcmd(cmd_list[i], function, flags, info, FlagManager, info_ml);
}
}
stock register_concmd_list(const cmd_list[][], const function[], flags = -1, const info[] = "", FlagManager = -1, bool:info_ml = false, const size = sizeof(cmd_list)) {
#pragma unused info
#pragma unused FlagManager
#pragma unused info_ml
for(new i; i < size; i++) {
register_concmd(cmd_list[i], function, flags, info, FlagManager, info_ml);
}
}
stock register_srvcmd_list(const cmd_list[][], const function[], flags = -1, const info[] = "", bool:info_ml = false, const size = sizeof(cmd_list)) {
#pragma unused info
#pragma unused info_ml
for(new i; i < size; i++) {
register_srvcmd(cmd_list[i], function, flags, info, info_ml);
}
}
#include <amxmodx>
public plugin_init() {
new cmd[][] = {"!guns", "\guns", "/guns", ".guns", "guns"};
register_clcmd_list(cmd, "hCMD_Guns");
}
public hCMD_Guns(id) {
//Menu_Guns(id);
}
#define register_cmd_list(%0,%1,%2) for (new i = 0; i < sizeof(%1); i++) register_%0(%1[i], %2)
#include <amxmodx>
#define register_cmd_list(%0,%1,%2) for (new i = 0; i < sizeof(%1); i++) register_%0(%1[i], %2)
public plugin_init()
{
new cmd[][] = {"!guns", "\guns", "/guns", ".guns", "guns"};
register_cmd_list(clcmd, cmd, "@Command_Guns" /*, ADMIN_LEVEL_A, etc. */);
// register_cmd_list(concmd, cmd, "@Command_Guns" /*, ADMIN_LEVEL_A, etc. */);
// register_cmd_list(srvcmd, cmd, "@Command_Guns" /*, ADMIN_LEVEL_A, etc. */);
}
@Command_Guns(id)
{
// ololo
}
#include <amxmodx>
#define DEBUG 1
#define debug_print(%1) \
do { if (DEBUG) server_print("==^n[DEBUG] %s:%i: %s^n==", __FILE__, __LINE__, %1); } while (0)
public plugin_init() {
debug_print(" INIT STATE #1 ");
}
Так что делает?ЧТО ТУТ ДЕЛАЕТ do while ???
#define register_trigger_clcmd(%0,%1) \
for (new i = 0; i < sizeof(BASE_CHAT_TRIGGERS); i++) \
{ \
register_clcmd(fmt("say %s%s", BASE_CHAT_TRIGGERS[i], %0), %1); \
register_clcmd(fmt("say_team %s%s", BASE_CHAT_TRIGGERS[i], %0), %1); \
}
new const BASE_CHAT_TRIGGERS[][] = { "", "/", "\", "!", "." };
public plugin_init()
{
register_trigger_clcmd("guns", "@Command_Guns" /*, ADMIN_LEVEL_A, etc. */)
}
@Command_Guns(id)
{
// ololo
}
new const parts[] = {1,1,1,1,1,1};
new const sizes[] = {26,26,26,26,26,26};
new count = 6;
server_print("%d",CalculateModelBodyArr(parts,sizes,count));
server_print("%d",CalculateModelBodyInt(1,sizes,count));
server_print("%d",CalculateModelBodyIntFixedSize(1,26,count));
public CalculateModelBodyArr(const parts[], const sizes[],const count){//Если есть массив который нужно выбрать
static bodyInt32 = 0, temp=0, it=0, tempCount;bodyInt32=0;tempCount = count;
while (tempCount--){
if (sizes[tempCount] == 1)continue;
temp = parts[tempCount]; for (it=0;it<tempCount;it++)temp *= sizes[it];
bodyInt32 += temp;
}
return bodyInt32;
}
public CalculateModelBodyInt(const parts, const sizes[],const count){//Если нужно везде одну и ту же выбрать...
static bodyInt32 = 0, temp=0, it=0, tempCount;bodyInt32=0;tempCount = count;
while (tempCount--){
if (sizes[tempCount] == 1)continue;
temp = parts; for (it=0;it<tempCount;it++)temp *= sizes[it];
bodyInt32 += temp;
}
return bodyInt32;
}
public CalculateModelBodyIntFixedSize(const parts, const sizes,const count){//Если нужно везде одну и ту же выбрать и размер фиксированный во всех...
static bodyInt32 = 0, temp=0, it=0, tempCount;bodyInt32=0;tempCount = count;
while (tempCount--){
// if (sizes[tempCount] == 1)continue;
temp = parts; for (it=0;it<tempCount;it++)temp *= sizes/* [it] */;
bodyInt32 += temp;
}
return bodyInt32;
}
#include <iostream>
int CalculateModelBody2(int selected_body[], int bodyCount[], int count);
int CalculateModelBody2(int selected_body, int bodyCount[], int count);
int main()
{
int selected[] = {1,1,1,1,1,1};
int bodyCount[] = {26,26,26,26,26,26};
printf("%d\n",CalculateModelBody2(selected,bodyCount, 6));
printf("%d\n",CalculateModelBody2(1,bodyCount, 6));
}
int CalculateModelBody2(int parts[], int sizes[],int count){//Если есть массив который нужно выбрать
int body = 0;
while (count--){
if (sizes[count] == 1)continue;
int temp = parts[count];
for (int i = 0; i < count; i++)temp *= sizes[i];
body += temp;
}
return body;
}
int CalculateModelBody2(int parts, int sizes[],int count){//Если нужно везед одну и ту же выбрать...
int body = 0;
while (count--){
if (sizes[count] == 1)continue;
int temp = parts;
for (int i = 0; i < count; i++)temp *= sizes[i];
body += temp;
}
return body;
}
Address Length Original bytes Patched bytes
00405C79 0x1 14 20
00405C7B 0x1 32 79
00405CEE 0x1 21 2D
new Float:vAngles[3];
AnglesToFloorSprite(Origin,vAngles);
set_entvar(iFire, var_angles, vAngles);
stock AnglesToFloorSprite(const Float:origin[3], Float:fAngles[3]){
static iTrace, Float:to[3], Float:normal[3];
iTrace = create_tr2();
xs_vec_copy(origin, to); to[2] -= 99999.0;//exactly down
engfunc(EngFunc_TraceLine, origin, to, IGNORE_MONSTERS, 0, iTrace);
get_tr2(iTrace, TR_vecPlaneNormal, normal); free_tr2(iTrace);
normal[0]*=-1.0; normal[1]*=-1.0;
vector_to_angle(normal, fAngles);
}
new const Float:SubFloat[3] = {0.0, 0.0, 9999.0/*down*/};
stock FloorOriginAngles(Float:flOrigin[3], Float:fAngles[3]){
static Float:origin[3], Float:traceto[3], Float:fraction, Float:original_forward[3], Float:angles2[3], Float:right[3], Float:up[3], Float:fwd[3];
new iTrace = create_tr2();if(!iTrace)return;
xs_vec_sub(flOrigin, SubFloat, traceto);
engfunc(EngFunc_TraceLine, flOrigin, traceto, IGNORE_MONSTERS|IGNORE_MISSILE, 0, iTrace);
get_tr2(iTrace, TR_flFraction, fraction);
if(fraction == 1.0){free_tr2(iTrace);return;}
angle_vector(fAngles, ANGLEVECTOR_FORWARD, original_forward);
get_tr2(iTrace, TR_vecPlaneNormal, up); free_tr2(iTrace);
xs_vec_cross(original_forward, up, right);
xs_vec_cross(up, right, fwd);
vector_to_angle(fwd, fAngles);
vector_to_angle(right, angles2);
fAngles[2] = -1.0 * angles2[0];
}