Hello,
This is a mid-advanced tutorial on how to make player animations on the end of round.
Regame is recommended so you can change the delay between end of round and start of a new one.
I won't give many explanations about the code itself, it's meant for people who will understand it by reading it because edits will be necessary, you will likely need per map configurations etc as i've just made a simple code to explain how i've done it. Said so, I will just explain the process.
Video Here
It's a dropbox link because i can not remember my youtube gmail account that i had auto login for like 10 years. It's not even a password problem, i don't remember the email itself
So, the method i use is based on entities. We create an entity to get a camera view and we create entities to set a model and animations.
This is just a trick by replicating your player models with only celebrating animations.
You will grab your personal player models and you will decompile them. After that you must gather all required files to recompile the model that i've attached. To know which files you will need just decompile celebrate_am.mdl, it's a small model, it's intuitive and self explanatory. All that you need to know is that the QC file is the master file, the file you will use to compile the model.
So just edit QC file, replace the SMD files for the ones you need. And if required edit the plugin as you need.
To get Origin & Angles i recommend you to use
this plugin.
Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#define CT_WON 8321
enum _:g_Strings
{
EntClassName,
CelebratingMp3,
CelebratingModel
}
new Get_String[g_Strings][64] =
{
"Celebrating_Ent",
"sound/alliedmodders.mp3",
"models/celebrate_am.mdl"
}
new g_iEnt[5]
new Float:g_iOrigin[5][3] =
{
{ 540.0, 48.0, 0.1 },
{ 393.0, 107.0, 0.1 },
{ 320.0, 46.0, 0.1 },
{ 357.0, -86.0, 0.1 },
{ 580.0, -213.0, 46.0 }
}
new Float:g_iAngles[5][3] =
{
{ 0.0, 285.0, 0.0 },
{ 0.0, 308.0, 0.0 },
{ 0.0, 323.0, 0.0 },
{ 0.0, 341.0, 0.0 },
{ 0.0, 129.0, 0.0 }
}
new Float:g_flOutside[3] = { 9999.0, 9999.0, 9999.0 }
public plugin_init() {
register_plugin("End Round Celebration", "0.0.1", "Jhob94")
register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0") // Remove Entities at new round
register_message(get_user_msgid("SendAudio"), "TextMsg__SendAudio")
BuildEntities()
}
public plugin_precache()
{
engfunc(EngFunc_PrecacheModel, Get_String[CelebratingModel])
engfunc(EngFunc_PrecacheGeneric, Get_String[CelebratingMp3])
}
public Event_NewRound()
{
for(new i=0; i < 5; i++)
{
if(pev_valid(g_iEnt[i]))
engfunc(EngFunc_SetOrigin, g_iEnt[i], g_flOutside)
}
}
public TextMsg__SendAudio(iMsgId, iMsgDest, id)
{
if(!id)
{
new szSound[14]
get_msg_arg_string(2, szSound, charsmax(szSound))
if(equal(szSound, "%!MRAD_terwin") || equal(szSound, "%!MRAD_ctwin"))
{
set_task(1.0, "StartCelebration", szSound[7] == 'c' ? CT_WON : 0) // A little delay for better effect
client_cmd(0, "mp3 play %s", Get_String[CelebratingMp3])
}
}
}
public StartCelebration(iCT)
{
if(pev_valid(g_iEnt[4]))
{
engfunc(EngFunc_SetOrigin, g_iEnt[4], g_iOrigin[4])
set_pev(g_iEnt[4], pev_angles, g_iAngles[4])
}
new iBody = iCT ? 4 : 0
for(new i=0; i < 4; i++)
{
if(pev_valid(g_iEnt[i]))
{
engfunc(EngFunc_SetOrigin, g_iEnt[i], g_iOrigin[i])
set_pev(g_iEnt[i], pev_angles, g_iAngles[i])
engfunc(EngFunc_DropToFloor, g_iEnt[i])
set_pev(g_iEnt[i], pev_body, iBody + i)
set_pev(g_iEnt[i], pev_animtime, get_gametime())
set_pev(g_iEnt[i], pev_framerate, 1.0)
set_pev(g_iEnt[i], pev_sequence, random(4))
}
}
new iPlayers[32], iNum
get_players(iPlayers, iNum)
for(new i = 0; i < iNum; i++)
{
new id = iPlayers[i]
if(is_user_alive(id))
{
set_pev(id, pev_origin, g_flOutside)
engfunc(EngFunc_SetView, id, g_iEnt[4])
}
}
}
BuildEntities()
{
for(new i=0; i < 5; i++)
{
g_iEnt[i] = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
if(pev_valid(g_iEnt[i]))
{
set_pev(g_iEnt[i], pev_classname, Get_String[EntClassName])
switch(i)
{
case 4:
{
engfunc(EngFunc_SetModel, g_iEnt[i], "models/w_usp.mdl") // Our Cam View
set_pev(g_iEnt[i], pev_solid, SOLID_TRIGGER)
set_pev(g_iEnt[i], pev_movetype, MOVETYPE_FLY)
set_pev(g_iEnt[i], pev_rendermode, kRenderTransTexture)
set_pev(g_iEnt[i], pev_renderamt, 0.0)
}
default:
{
engfunc(EngFunc_SetModel, g_iEnt[i], Get_String[CelebratingModel])
set_pev(g_iEnt[i], pev_gamestate, 1)
set_pev(g_iEnt[i], pev_solid, SOLID_BBOX)
new Float:maxs[3] = {16.0, 16.0, 36.0}
new Float:mins[3] = {-16.0, -16.0, -36.0}
engfunc(EngFunc_SetSize, g_iEnt[i], mins, maxs)
}
}
engfunc(EngFunc_SetOrigin, g_iEnt[i], g_flOutside)
}
}
}
Any question feel free to ask.