Скриптер
Участник
Пользователь
- Сообщения
- 109
- Реакции
- 79
- Помог
- 1 раз(а)
new const
instead of define
for strings.SoundFile = SoundFile1
should be used copy
instead.get_pcvar_num(i_music)
you can use bind_pcvar_num
rg_find_ent_by_class
with a custom classname.if(enty != 0){ rh_emit_sound2(enty, 0, CHAN_VOICE, SoundFile, SOUNDVOLUME, SOUNDATT, 0, PITCH_NORM); }
just unreadableHC_BREAK
in not ReAPI hooks? Moreover, you shouldn't use HC_BREAK
in PreThink. Why don't you use HC_CONTINUE
?format(g_MapFile, sizeof(g_MapFile), "maps/%s.juke.cfg", map)
it's better to use formatex
charsmax
instead of sizeof
in natives like format
, formatex
...is_user_alive
instead of g_alive[id]if(get_pcvar_num(i_music) == 1){
SoundFile = SoundFile1
}
else if(get_pcvar_num(i_music) == 2){
SoundFile = SoundFile2
}
else{
SoundFile = SoundFile3
}
It's more reasonable to useAlso you should create a variable if you want to check if user is alive. It is overkill to checkis_user_alive
instead of g_alive[id]
is_user_alive
to not break compatibility with other plugins which respawn players. An example could be a plugin which respawns players to make them ghosts (walking on the map being dead).Yes, it can be used. But I think it's better to use something like that to not hardcode:Maybe switch
new const g_szSounds[][] =
{
"ambience/Opera.wav",
"ambience/lv_jubilee.wav",
"ambience/guit1.wav"
};
new g_szSoundFile[64];
copy(g_szSoundFile, charsmax(g_szSoundFile), g_szSounds[g_iCvarMusic - 1]);
I still think that variable is better. It is overkill to check is_user_alive.It's more reasonable to useis_user_alive
to not break compatibility with other plugins which respawn players. An example could be a plugin which respawns players to make them ghosts (walking on the map being dead).
Spawn(id)
{
if(is_user_alive(id))
{
g_alive[id] = true;
}
}
Killed(victim)
{
g_alive[victim] = false;
}
PreThink(id)
{
//if(!is_user_alive(id))
if(!g_alive[id])
{
return;
}
}
A little more optimized, nothing more. It can change the behavior of the plugin if a plugin such as I described is being used in the server. But if there is no plugin like that so no issues.I still think that variable is better. It is overkill to check is_user_alive.