| nonameguy123 |
10-14-2019 12:07 |
Help Player Animation
2 Attachment(s)
Anyone can fix that? Bug on player animation
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <cstrike>
#include <hamsandwich>
#include <xs>
#include <fun>
#define PLUGIN "Test Buffclass Shino & Miho"
#define VERSION "1.0"
#define AUTHOR ""
#define shino_model_prec "models/player/shino/shino.mdl"
#define miho_model_prec "models/player/miho/miho.mdl"
#define TASK_EMOTION 1962
#define TASK_HOLDTIME 1963
new const RADIO_MESSEAGE[][] = {
"COVERME",
"TAKEPOINT",
"POSITION",
"REGROUP",
"FOLLOWME",
"HITASSIST",
"GO",
"FALLBACK",
"STICKTOG",
"GETINPOS",
"STORMFRONT",
"REPORTIN",
"AFFIRM",
"ROGER",
"ENEMYSPOT",
"BACKUP",
"CLEAR",
"INPOS",
"REPRTINGIN",
"BLOW",
"NEGATIVE",
"ENEMYDOWN",
"FIREINHOLE"
}
new const RADIO_FILE[][] = {
"coverme1",
"coverme2",
"takepoint1", // 2
"takepoint2",
"position1", // 4
"position2",
"regroup1", // 6
"regroup2",
"followme1", // 8
"followme2",
"fireassis1", // 10
"fireassis2",
"go1", // 12
"go2",
"fallback1", // 14
"fallback2",
"staytogether1", // 16
"staytogether2",
"takeposition1", // 18
"takeposition2",
"stormfront1", // 20
"stormfront2",
"reportin1", // 22
"reportin2",
///// DIFFERENT
"roger1", // 23
"roger2", // 24
"enemys1", // 26
"enemys2",
"help1", // 28
"help2",
"clear1", // 30
"clear2",
"position1", // 32
"position2",
"reportin1", // 34
"reportin2",
"getout1", // 36
"getout2",
"negative1", // 38
"negative2",
"enemydown1", // 40
"enemydown2",
"fireinhole1", // 42
"fireinhole2",
"fireinhole3"
}
new const shino_emotsound[][] =
{
//emoticon number 01
"vox/shino/emotion/hi1.wav", //0
//charm - emoticon number 02
"vox/shino/emotion/charms1.wav", //1
//emotion number 03
"vox/shino/emotion/love2.wav", //2
//emotion number 04
"vox/shino/emotion/transform.wav", //3
//emotion number 05
"vox/shino/emotion/energyfield1.wav", //4
"vox/shino/emotion/energyfield2.wav" //5
}
new const miho_emotsound[][] =
{
//emoticon number 01
"vox/miho/emotion/hi1.wav",
//charm - emoticon number 02
"vox/miho/emotion/taunt1.wav",
//emotion number 03
"vox/miho/emotion/transform.wav",
//emotion number 04
"vox/miho/emotion/transform.wav",
//emotion number 05
"vox/miho/emotion/energyfield1.wav",
"vox/miho/emotion/energyfield2.wav"
}
new const miho_ragdolls[][] =
{
"player/miho/die1.wav", // 0
"player/miho/die2.wav", //1
"player/miho/f_hit_flesh-1.wav", //2
"player/miho/f_hit_flesh-2.wav", //3
"player/miho/f_hit_flesh-3.wav", //4
"player/miho/headshot1.wav", // 5
"player/miho/headshot2.wav" //6
}
new const shino_ragdolls[][] =
{
"player/shino/die1.wav", // 0
"player/shino/die2.wav", //1
"player/shino/f_hit_flesh-1.wav", //2
"player/shino/f_hit_flesh-2.wav", //3
"player/shino/f_hit_flesh-3.wav", //4
"player/shino/headshot1.wav", // 5
"player/shino/headshot2.wav" //6
}
new bool:UsingBuffChar,bool:UseMiho, bool:UseShino,bool:RegisterEntity
new g_msgSendAudio,g_AnimEnt[33], g_AvtEnt[33],g_InDoingEmo[33]
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_EmitSound, "fw_EmitSound")
register_message(get_user_msgid("SendAudio"), "message_SendAudio")
g_msgSendAudio = get_user_msgid("SendAudio");
RegisterHam(Ham_Spawn, "player", "PlayerSpawn", 1)
register_clcmd("show_emot_menu", "emot_menu_handle");
register_clcmd("say /useshino", "ChooseShino");
register_clcmd("say /usemiho", "ChooseMiho");
}
public plugin_precache()
{
precache_model(shino_model_prec)
precache_model(miho_model_prec)
new i;
for(i = 0; i < sizeof(shino_emotsound); i++)
precache_sound(shino_emotsound[i])
for(i = 0; i < sizeof(miho_emotsound); i++)
precache_sound(miho_emotsound[i])
for(i = 0; i <sizeof(miho_ragdolls); i++)
precache_sound(miho_ragdolls[i])
for(i = 0; i < sizeof(shino_ragdolls); i++)
precache_sound(shino_ragdolls[i])
}
public ChooseMiho(id)
{
if(!is_user_alive(id)) return;
UsingBuffChar = true;
UseMiho = true
UseShino = false;
ReplaceModel(id, "miho");
}
public ChooseShino(id)
{
if(!is_user_alive(id)) return;
UsingBuffChar = true;
UseMiho = false
UseShino = true;
ReplaceModel(id, "shino");
}
public AllReset(id)
{
UsingBuffChar = false;
UseMiho = false;
UseShino = false;
ResetModel(id)
client_cmd(id, "bind j show_emot_menu")
}
public fw_EmitSound(id, channel, const sample[], Float:volume, Float:attn, flags, pitch)
{
// Replace these next sounds for zombies only
if (!is_user_connected(id) || !UsingBuffChar)
return FMRES_IGNORED;
static sound[64]
// Zombie being hit
if (sample[7] == 'b' && sample[8] == 'h' && sample[9] == 'i' && sample[10] == 't')
{
new iRand = random_num(1,100)
if (!(iRand%2)) format(sound, charsmax(sound), "%s", UseShino?shino_ragdolls[2]:miho_ragdolls[2])
else if (!(iRand%3)) format(sound, charsmax(sound), "%s", UseShino?shino_ragdolls[3]:miho_ragdolls[3])
else format(sound, charsmax(sound), "%s",UseShino?shino_ragdolls[4]:miho_ragdolls[4])
emit_sound(id, channel, sound, volume, attn, flags, pitch)
return FMRES_SUPERCEDE;
}
// Zombie dies
if (sample[7] == 'd' && ((sample[8] == 'i' && sample[9] == 'e') || (sample[8] == 'e' && sample[9] == 'a')))
{
new iRand = random_num(1,100)
if (!(iRand%2)) format(sound, charsmax(sound), "%s", UseShino?shino_ragdolls[0]:miho_ragdolls[0])
else format(sound, charsmax(sound), "%s", UseShino?shino_ragdolls[1]:miho_ragdolls[1])
emit_sound(id, channel, sound, volume, attn, flags, pitch)
return FMRES_SUPERCEDE;
}
// Zombie being headshot
if (sample[7] == 'h' && sample[8] == 'e' && sample[9] == 'a' && sample[10] == 'd')
{
new iRand = random_num(1,100)
if (!(iRand%2)) format(sound, charsmax(sound), "%s", UseShino?shino_ragdolls[5]:miho_ragdolls[5])
else format(sound, charsmax(sound), "%s", UseShino?shino_ragdolls[6]:miho_ragdolls[6])
emit_sound(id, channel, sound, volume, attn, flags, pitch)
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
public PlayerSpawn(id)
{
AllReset(id)
client_printc(id, "!g[CSO Emotion]!n Press !g[J]!n to use !tEmotion!n")
}
public emot_menu_handle(id)
{
if(!UsingBuffChar)
return PLUGIN_CONTINUE
if(get_user_flags(id) & ADMIN_RCON)
{
new szmenu[1000]
formatex(szmenu, 300, "\r[CSO] \wEmotion Menu Handle")
new menu = menu_create(szmenu,"_menu_handle")
formatex(szmenu, 63, "\wEmoticon 1^n")
menu_additem(menu, szmenu,"1",0)
formatex(szmenu, 63, "\wEmoticon 2^n")
menu_additem(menu, szmenu,"2",0)
formatex(szmenu, 63, "\wEmoticon 3^n")
menu_additem(menu, szmenu,"3",0)
formatex(szmenu, 63, "\wEmoticon 4^n")
menu_additem(menu, szmenu,"4",0)
formatex(szmenu, 63, "\wEmoticon 5^n")
menu_additem(menu, szmenu,"5",0)
menu_setprop(menu, MPROP_EXITNAME, "Exit Menu")
menu_display(id, menu, 0)
}
return PLUGIN_HANDLED
}
public _menu_handle(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu)
return PLUGIN_HANDLED
}
new data[6], iName[64]
new access, callback
menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
new key = str_to_num(data)
switch(key)
{
case 1:
{
UTIL_PlayAnimation(id,7.0, 2.0, 95)
Delay_nextAttack(id, 5.0)
Stock_SetPlayerAnim(id, "emotion01", 1.0)
PlaySound(id, UseMiho?miho_emotsound[0] : shino_emotsound[0])
}
case 2:
{
UTIL_PlayAnimation(id,7.0, 2.0, 96)
Delay_nextAttack(id, 5.0)
Stock_SetPlayerAnim(id, "emotion02", 1.0)
PlaySound(id, UseMiho?miho_emotsound[1] : shino_emotsound[1])
}
case 3:
{
UTIL_PlayAnimation(id,7.0, 2.0, 97)
Delay_nextAttack(id, 5.0)
Stock_SetPlayerAnim(id, "emotion03", 1.0)
PlaySound(id, UseMiho?miho_emotsound[2] : shino_emotsound[2])
}
case 4:
{
UTIL_PlayAnimation(id,7.0, 2.0, 98)
Delay_nextAttack(id, 5.0)
Stock_SetPlayerAnim(id, "emotion04", 1.0)
PlaySound(id, UseMiho?miho_emotsound[3] : shino_emotsound[3])
}
case 5:
{
UTIL_PlayAnimation(id,7.0, 2.0, 99)
Delay_nextAttack(id, 5.0)
Stock_SetPlayerAnim(id, "emotion07", 1.0)
PlaySound(id, UseMiho?miho_emotsound[random_num(4,5)] : shino_emotsound[random_num(4,5)])
}
}
menu_destroy(menu)
return PLUGIN_HANDLED
}
//AnimEnt Dias
public AvatarAnimEnt(id, EmoId)
{
new Avt = create_entity("info_target")
if(!pev_valid(Avt)) return
static Float:Origin[3], Float:Angles[3], Float:Velocity[3];
pev(id, pev_origin, Origin); pev(id, pev_angles, Angles);pev(id, pev_velocity, Velocity)
Avt = g_AvtEnt[id];
set_pev(g_AvtEnt[id], pev_classname, "EntityAvatar")
engfunc(EngFunc_SetModel, g_AvtEnt[id], UseShino?shino_model_prec:miho_model_prec)
Origin[2] -= 36.0
set_pev(g_AvtEnt[id], pev_origin, Origin)
set_pev(g_AvtEnt[id], pev_angles, Angles)
set_pev(g_AvtEnt[id], pev_velocity, Velocity)
drop_to_floor(g_AvtEnt[id])
Set_Entity_Anim(g_AvtEnt[id], EmoId, 1)
set_pev(g_AvtEnt[id], pev_solid, SOLID_NOT)
set_pev(g_AvtEnt[id], pev_movetype, MOVETYPE_FOLLOW)
set_pev(g_AvtEnt[id], pev_owner, id)
set_pev(g_AvtEnt[id], pev_impulse, 1091)
set_pev(g_AvtEnt[id], pev_nextthink, get_gametime() + 0.1)
set_pev(g_AvtEnt[id], pev_size, Float:{-15.0,-15.0,-15.0}, Float:{15.0,15.0,15.0})
Set_Entity_Invisible(g_AvtEnt[id], 0)
if(!RegisterEntity){
RegisterHamFromEntity(Ham_Think, g_AvtEnt[id], "EntThink")
RegisterEntity = true;
}
}
public EntThink(ent)
{
if(!pev_valid(ent)) return HAM_IGNORED
if(pev(ent, pev_impulse) != 1091) return HAM_IGNORED
set_pev(ent, pev_nextthink, get_gametime() + 0.5)
return HAM_IGNORED
}
public Set_Emotion_Start(id, EmoId)
{
g_InDoingEmo[id] = 1
AvatarAnimEnt(id, EmoId)
set_task(5.0, "Reset_Emotion", id+TASK_EMOTION)
}
public Check_Avalible(id)
{
if(!pev_valid(g_AnimEnt[id]) || !pev_valid(g_AvtEnt[id]))
{
Do_Reset_Emotion(id)
return 0
}
return 1
}
public Reset_Emotion(id)
{
id -= TASK_EMOTION
if(!is_user_connected(id))
return
if(!g_InDoingEmo[id])
return
Do_Reset_Emotion(id)
}
public Do_Reset_Emotion(id)
{
if(!is_user_connected(id))
return
if(!g_InDoingEmo[id])
return
if(task_exists(id+TASK_EMOTION)) remove_task(id+TASK_EMOTION)
Set_Entity_Invisible(id, 0)
if(pev_valid(g_AnimEnt[id])) engfunc(EngFunc_RemoveEntity, g_AnimEnt[id])
if(pev_valid(g_AvtEnt[id])) engfunc(EngFunc_RemoveEntity, g_AvtEnt[id])
g_InDoingEmo[id] = 0
}
//Send Audio Thanks NST
public message_SendAudio(msg_id, msg_dest, msg_entity)
{
// get value
new audio[64], audio_f[8], id
id = get_msg_arg_int(1)
get_msg_arg_string(2, audio, charsmax(audio))
format(audio_f, charsmax(audio_f), "%s", audio)
if(!UsingBuffChar)
return PLUGIN_CONTINUE;
// replace sound radio 1 - 3
new check, radio_new[64]
for (new i=0; i<23; i++)
{
if(equal(audio[7], RADIO_MESSEAGE[i]))
{
new iRand = random_num(1,100)
if(i == 22)
{
if (!(iRand%2)) format(radio_new, charsmax(radio_new), "%s", get_urlsound_radio(RADIO_FILE[42]))
else if (!(iRand%3)) format(radio_new, charsmax(radio_new), "%s", get_urlsound_radio(RADIO_FILE[43]))
else format(radio_new, charsmax(radio_new), "%s", get_urlsound_radio(RADIO_FILE[44]))
} else if(i == 12 || i == 13) {
if (!(iRand%2)) format(radio_new, charsmax(radio_new), "%s", get_urlsound_radio(RADIO_FILE[23]))
else format(radio_new, charsmax(radio_new), "%s", get_urlsound_radio(RADIO_FILE[24]))
} else {
if (!(iRand%2)) format(radio_new, charsmax(radio_new), "%s", get_urlsound_radio(RADIO_FILE[i*2]))
else format(radio_new, charsmax(radio_new), "%s", get_urlsound_radio(RADIO_FILE[i*2+1]))
}
check = 1
}
}
// replace sound radio other
if (equal(audio_f, "%!MRAD_") && !check)
{
// radio one
replace(audio, charsmax(audio), "%!MRAD_", "")
strtolower(audio)
format(radio_new, charsmax(radio_new), "%s", get_urlsound_radio(audio))
// radio all
if (!id)
{
send_radio_all(audio)
return PLUGIN_HANDLED
}
}
// replace radio
if (file_exists(get_fullurl_radio(radio_new))) set_msg_arg_string(2, radio_new)
return PLUGIN_CONTINUE
}
//stock
stock PlaySound(id, const iSound[]){
if(!is_user_alive(id))
return
client_cmd(id, "spk %s", iSound)
}
stock Delay_nextAttack(id, Float:Nexttime)
{
if(!is_user_alive(id))
return
set_pdata_float(id, 83, Nexttime, 5)
}
stock UTIL_PlayAnimation(iPlayer,Float:Time,Float:flFramerate=1.0, iSequence) {
if(!is_user_alive(iPlayer))
return
set_pev(iPlayer, pev_animtime, Time);
set_pev(iPlayer, pev_framerate, flFramerate);
set_pev(iPlayer, pev_sequence, iSequence);
set_pev(iPlayer, pev_gaitsequence, iSequence);
}
stock Stock_SetPlayerAnim(id, const AnimName[], Float:rate=1.0)
{
static AnimNum, Float:FrameRate, Float:GroundSpeed, bool:Loops, Anim2[64]
if(!(pev(id, pev_flags) & FL_DUCKING)) format(Anim2, 63, "%s", AnimName)
else format(Anim2, 63, "%s", AnimName)
if ((AnimNum=lookup_sequence(id,Anim2,FrameRate,Loops,GroundSpeed))==-1) AnimNum=0
if (!Loops || (Loops && pev(id,pev_sequence)!=AnimNum))
{
set_pev(id, pev_gaitsequence, AnimNum)
set_pev(id, pev_sequence, AnimNum)
set_pev(id, pev_frame, 0.0)
set_pev(id, pev_animtime, get_gametime())
}
set_pev(id, pev_framerate, rate)
set_pdata_int(id, 40, Loops, 4)
set_pdata_int(id, 39, 0, 4)
set_pdata_float(id, 36, FrameRate, 4)
set_pdata_float(id, 37, GroundSpeed, 4)
set_pdata_float(id, 38, get_gametime(), 4)
set_pdata_int(id, 73, 28, 5)
set_pdata_int(id, 74, 28, 5)
set_pdata_float(id, 220, get_gametime(), 5)
}
//Replace Model as ModelIndex
stock ReplaceModel(id, const model[])
{
cs_set_user_model(id, model, true)
set_pev(id, pev_modelindex, model)
}
stock ResetModel(id)
{
cs_reset_user_model(id)
set_pev(id, pev_modelindex, pev(id, pev_modelindex))
}
stock fm_cs_get_user_model(id, Model[], Len)
{
if(!is_user_connected(id))
return
engfunc(EngFunc_InfoKeyValue, engfunc(EngFunc_GetInfoKeyBuffer, id), "model", Model, Len)
}
stock Set_Entity_Invisible(ent, Invisible = 1)
{
if(!pev_valid(ent))
return
set_pev(ent, pev_effects, Invisible == 0 ? pev(ent, pev_effects) & ~EF_NODRAW : pev(ent, pev_effects) | EF_NODRAW)
}
stock Set_Entity_Anim(ent, Anim, ResetFrame)
{
if(!pev_valid(ent))
return
set_pev(ent, pev_animtime, get_gametime())
set_pev(ent, pev_framerate, 1.0)
set_pev(ent, pev_sequence, Anim)
set_pev(ent, pev_gaitsequence, Anim)
if(ResetFrame) set_pev(ent, pev_frame, 0)
}
stock client_printc(index, const text[], any:...)
{
new szMsg[128];
vformat(szMsg, sizeof(szMsg) - 1, text, 3);
replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04");
replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01");
replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03");
if(index == 0)
{
for(new i = 0; i < get_maxplayers(); i++)
{
if(!is_user_connected(i))
continue
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, i)
write_byte(i)
write_string(szMsg)
message_end()
}
} else {
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, index);
write_byte(index);
write_string(szMsg);
message_end();
}
}
//Radio
send_radio_all(audio[])
{
for (new id = 1; id < 33; id++)
{
if (!is_user_connected(id)) continue;
message_begin(MSG_ONE, g_msgSendAudio, _, id)
write_byte(0)
write_string(get_urlsound_radio(audio))
write_short(100)
message_end()
//client_print(id, print_chat, "S[%i]M[%s]", get_user_sex(id), get_urlsound_radio(audio, get_user_sex(id)))
}
}
get_fullurl_radio(file[])
{
new audio[64]
format(audio, charsmax(audio), "sound/%s", file)
return audio
}
get_urlsound_radio(filename[])//, sex)
{
new audio[64]
format(audio, charsmax(audio), UseMiho?"radio/miho/%s.wav" : "radio/shino/%s.wav", filename)
client_print(0, print_chat, "[%s]", audio)
return audio
}
|