Ok , IŽll post here what I have done till now. I canŽt guarantee that it works on every map , there might be some issues , take what you need but if you got it fixed with pieces of this , you have to post the solution here.
Will this work for all maps if I add all default models?
char fbiModelsCT[][] =
{
"models/player/custom_player/legacy/ctm_fbi.mdl",
"models/player/custom_player/legacy/ctm_fbi_variantA.mdl",
"models/player/custom_player/legacy/ctm_fbi_variantB.mdl",
"models/player/custom_player/legacy/ctm_fbi_variantC.mdl",
"models/player/custom_player/legacy/ctm_fbi_variantD.mdl"
};
char gignModelsCT[][] =
{
"models/player/custom_player/legacy/ctm_gign.mdl",
"models/player/custom_player/legacy/ctm_gign_variantA.mdl",
"models/player/custom_player/legacy/ctm_gign_variantB.mdl",
"models/player/custom_player/legacy/ctm_gign_variantC.mdl",
"models/player/custom_player/legacy/ctm_gign_variantD.mdl"
};
public Action Event_Spawn(Event gEventHook, const char[] gEventName, bool iDontBroadcast)
{
int client = GetClientOfUserId(gEventHook.GetInt("userid"));
if (isValidClient(client) && IsPlayerAlive(client) && !IsFakeClient(client))
{
int team = GetClientTeam(client);
if (team == 3)
{
char sModelCT[128];
GetEntPropString(client, Prop_Data, "m_ModelName", sModelCT, sizeof(sModelCT));
for (int i = 0; i < sizeof(fbiModelsCT); i++)
{
if (StrEqual(fbiModelsCT[i], sModelCT))
{
SetEntityModel(client,gignModelsCT[GetRandomInt(0 , -1)]);
SetEntPropString(client, Prop_Send, "m_szArmsModel", "models/player/custom_player/superheroes/ultron/ultron_arms.mdl");
CreateTimer(1.5, PlayerModel, client);
}
}
for (int j = 0; j < sizeof(gignModelsCT); j++)
{
if (StrEqual(gignModelsCT[j], sModelCT))
{
SetEntityModel(client,fbiModelsCT[GetRandomInt(0 , -1)]);
SetEntPropString(client, Prop_Send, "m_szArmsModel", "models/player/custom_player/superheroes/ultron/ultron_arms.mdl");
CreateTimer(1.5, PlayerModel, client);
}
}
}
}
You have to do this for all models(sas/swat/st6/idf ect.) and than check as ex. if the gign replaces the swat correctly witout overlapping and so on(like trial and error).
So here is my final solution for replacing the Arm- and Playermodels:
Code:
#include <sourcemod>
#include <sdktools>
#pragma newdecls required
char anarchistModelsT[][] =
{
"models/player/custom_player/legacy/tm_anarchist.mdl",
"models/player/custom_player/legacy/tm_anarchist_variantA.mdl",
"models/player/custom_player/legacy/tm_anarchist_variantB.mdl",
"models/player/custom_player/legacy/tm_anarchist_variantC.mdl",
"models/player/custom_player/legacy/tm_anarchist_variantD.mdl"
};
char balkanModelsT[][] =
{
"models/player/custom_player/legacy/tm_balkan_variantA.mdl",
"models/player/custom_player/legacy/tm_balkan_variantB.mdl",
"models/player/custom_player/legacy/tm_balkan_variantC.mdl",
"models/player/custom_player/legacy/tm_balkan_variantD.mdl",
"models/player/custom_player/legacy/tm_balkan_variantE.mdl"
};
char leetModelsT[][] =
{
"models/player/custom_player/legacy/tm_leet_variantA.mdl",
"models/player/custom_player/legacy/tm_leet_variantB.mdl",
"models/player/custom_player/legacy/tm_leet_variantC.mdl",
"models/player/custom_player/legacy/tm_leet_variantD.mdl",
"models/player/custom_player/legacy/tm_leet_variantE.mdl"
};
char phoenixModelsT[][] =
{
"models/player/custom_player/legacy/tm_phoenix.mdl",
"models/player/custom_player/legacy/tm_phoenix_heavy.mdl",
"models/player/custom_player/legacy/tm_phoenix_variantA.mdl",
"models/player/custom_player/legacy/tm_phoenix_variantB.mdl",
"models/player/custom_player/legacy/tm_phoenix_variantC.mdl",
"models/player/custom_player/legacy/tm_phoenix_variantD.mdl"
};
char pirateModelsT[][] =
{
"models/player/custom_player/legacy/tm_pirate.mdl",
"models/player/custom_player/legacy/tm_pirate_variantA.mdl",
"models/player/custom_player/legacy/tm_pirate_variantB.mdl",
"models/player/custom_player/legacy/tm_pirate_variantC.mdl",
"models/player/custom_player/legacy/tm_pirate_variantD.mdl"
};
char professionalModelsT[][] =
{
"models/player/custom_player/legacy/tm_professional.mdl",
"models/player/custom_player/legacy/tm_professional_var1.mdl",
"models/player/custom_player/legacy/tm_professional_var2.mdl",
"models/player/custom_player/legacy/tm_professional_var3.mdl",
"models/player/custom_player/legacy/tm_professional_var4.mdl"
};
char separatistModelsT[][] =
{
"models/player/custom_player/legacy/tm_separatist.mdl",
"models/player/custom_player/legacy/tm_separatist_variantA.mdl",
"models/player/custom_player/legacy/tm_separatist_variantB.mdl",
"models/player/custom_player/legacy/tm_separatist_variantC.mdl",
"models/player/custom_player/legacy/tm_separatist_variantD.mdl"
};
char fbiModelsCT[][] =
{
"models/player/custom_player/legacy/ctm_fbi.mdl",
"models/player/custom_player/legacy/ctm_fbi_variantA.mdl",
"models/player/custom_player/legacy/ctm_fbi_variantB.mdl",
"models/player/custom_player/legacy/ctm_fbi_variantC.mdl",
"models/player/custom_player/legacy/ctm_fbi_variantD.mdl"
};
char gignModelsCT[][] =
{
"models/player/custom_player/legacy/ctm_gign.mdl",
"models/player/custom_player/legacy/ctm_gign_variantA.mdl",
"models/player/custom_player/legacy/ctm_gign_variantB.mdl",
"models/player/custom_player/legacy/ctm_gign_variantC.mdl",
"models/player/custom_player/legacy/ctm_gign_variantD.mdl"
};
char gsg9ModelsCT[][] =
{
"models/player/custom_player/legacy/ctm_gsg9.mdl",
"models/player/custom_player/legacy/ctm_gsg9_variantA.mdl",
"models/player/custom_player/legacy/ctm_gsg9_variantB.mdl",
"models/player/custom_player/legacy/ctm_gsg9_variantC.mdl",
"models/player/custom_player/legacy/ctm_gsg9_variantD.mdl"
};
char idfModelsCT[][] =
{
"models/player/custom_player/legacy/ctm_idf.mdl",
"models/player/custom_player/legacy/ctm_idf_variantA.mdl",
"models/player/custom_player/legacy/ctm_idf_variantB.mdl",
"models/player/custom_player/legacy/ctm_idf_variantC.mdl",
"models/player/custom_player/legacy/ctm_idf_variantD.mdl",
"models/player/custom_player/legacy/ctm_idf_variantE.mdl",
"models/player/custom_player/legacy/ctm_idf_variantF.mdl"
};
char sasModelsCT[][] =
{
"models/player/custom_player/legacy/ctm_sas.mdl",
"models/player/custom_player/legacy/ctm_sas_variantA.mdl",
"models/player/custom_player/legacy/ctm_sas_variantB.mdl",
"models/player/custom_player/legacy/ctm_sas_variantC.mdl",
"models/player/custom_player/legacy/ctm_sas_variantD.mdl",
"models/player/custom_player/legacy/ctm_sas_variantE.mdl"
};
char st6ModelsCT[][] =
{
"models/player/custom_player/legacy/ctm_st6.mdl",
"models/player/custom_player/legacy/ctm_st6_variantA.mdl",
"models/player/custom_player/legacy/ctm_st6_variantB.mdl",
"models/player/custom_player/legacy/ctm_st6_variantC.mdl",
"models/player/custom_player/legacy/ctm_st6_variantD.mdl"
};
char swatModelsCT[][] =
{
"models/player/custom_player/legacy/ctm_swat.mdl",
"models/player/custom_player/legacy/ctm_swat_variantA.mdl",
"models/player/custom_player/legacy/ctm_swat_variantB.mdl",
"models/player/custom_player/legacy/ctm_swat_variantC.mdl",
"models/player/custom_player/legacy/ctm_swat_variantD.mdl"
};
public void OnConfigsExecuted()
{
for (int i = 0; i < sizeof(fbiModelsCT); i++)
{
if(fbiModelsCT[i][0] && !IsModelPrecached(fbiModelsCT[i]))
PrecacheModel(fbiModelsCT[i]);
}
for (int i = 0; i < sizeof(gignModelsCT); i++)
{
if(gignModelsCT[i][0] && !IsModelPrecached(gignModelsCT[i]))
PrecacheModel(gignModelsCT[i]);
}
for (int i = 0; i < sizeof(anarchistModelsT); i++)
{
if(anarchistModelsT[i][0] && !IsModelPrecached(anarchistModelsT[i]))
PrecacheModel(anarchistModelsT[i]);
}
for (int i = 0; i < sizeof(phoenixModelsT); i++)
{
if(phoenixModelsT[i][0] && !IsModelPrecached(phoenixModelsT[i]))
PrecacheModel(phoenixModelsT[i]);
}
for (int i = 0; i < sizeof(pirateModelsT); i++)
{
if(pirateModelsT[i][0] && !IsModelPrecached(pirateModelsT[i]))
PrecacheModel(pirateModelsT[i]);
}
// Precache the default Armmodels for T&CT
PrecacheModel("models/weapons/t_arms.mdl");
PrecacheModel("models/weapons/ct_arms.mdl");
// Precache the Custom Arm- and Playermodels
PrecacheModel("models/player/custom_player/superheroes/ultron/ultron_arms.mdl");
PrecacheModel("models/player/custom_player/superheroes/ultron/ultron.mdl");
PrecacheModel("models/player/custom_player/superheroes/black_panther/black_panther_arms.mdl");
PrecacheModel("models/player/custom_player/superheroes/black_panther/black_panther.mdl");
}
public void OnPluginStart()
{
HookEvent("player_spawn", Event_Spawn, EventHookMode_Post);
}
public Action Event_Spawn(Event gEventHook, const char[] gEventName, bool iDontBroadcast)
{
int client = GetClientOfUserId(gEventHook.GetInt("userid"));
if (isValidClient(client) && IsPlayerAlive(client) && !IsFakeClient(client))
{
int team = GetClientTeam(client);
if (team == 2)
{
char sModelT[128];
GetEntPropString(client, Prop_Data, "m_ModelName", sModelT, sizeof(sModelT)); // Get the complete Modelname.
PrintToChat(client, "Modelname is : %s", sModelT);
// Now loop through the team2 arrays and check if the Modelname is in it , if yes we set a differant Model that is compatibel with the map.
for (int a = 0; a < sizeof(anarchistModelsT); a++)
{
if (StrEqual(anarchistModelsT[a], sModelT))
{
SetEntityModel(client,pirateModelsT[GetRandomInt(0 , -1)]);
}
}
for (int b = 0; b < sizeof(phoenixModelsT); b++)
{
if (StrEqual(phoenixModelsT[b], sModelT))
{
SetEntityModel(client,pirateModelsT[GetRandomInt(0 , -1)]);
}
}
for (int c = 0; c < sizeof(balkanModelsT); c++)
{
if (StrEqual(balkanModelsT[c], sModelT))
{
SetEntityModel(client,anarchistModelsT[GetRandomInt(0 , -1)]);
}
}
for (int d = 0; d < sizeof(leetModelsT); d++)
{
if (StrEqual(leetModelsT[d], sModelT))
{
SetEntityModel(client,anarchistModelsT[GetRandomInt(0 , -1)]);
}
}
for (int e = 0; e < sizeof(pirateModelsT); e++)
{
if (StrEqual(pirateModelsT[e], sModelT))
{
SetEntityModel(client,anarchistModelsT[GetRandomInt(0 , -1)]);
}
}
for (int f = 0; f < sizeof(professionalModelsT); f++)
{
if (StrEqual(professionalModelsT[f], sModelT))
{
SetEntityModel(client,anarchistModelsT[GetRandomInt(0 , -1)]);
}
}
for (int h = 0; h < sizeof(separatistModelsT); h++)
{
if (StrEqual(separatistModelsT[h], sModelT))
{
SetEntityModel(client,anarchistModelsT[GetRandomInt(0 , -1)]);
}
}
SetEntPropString(client, Prop_Send, "m_szArmsModel", "models/weapons/t_arms.mdl"); // First set default Armsmodel.
SetEntPropString(client, Prop_Send, "m_szArmsModel", "models/player/custom_player/superheroes/ultron/ultron_arms.mdl"); // Now we can replace the default Armmodel with our Custom one.
CreateTimer(1.5, PlayerModel, client); // Create Timer with delay before setting the new Playermodel.
}
// Now loop through the team3 arrays and check if the Modelname is in it , if yes we set a differant Model that is compatibel with the map.
else if (team == 3)
{
char sModelCT[128];
GetEntPropString(client, Prop_Data, "m_ModelName", sModelCT, sizeof(sModelCT));
PrintToChat(client, "Modelname is : %s", sModelCT);
for (int i = 0; i < sizeof(fbiModelsCT); i++)
{
if (StrEqual(fbiModelsCT[i], sModelCT))
{
SetEntityModel(client,gignModelsCT[GetRandomInt(0 , -1)]);
}
}
for (int j = 0; j < sizeof(gsg9ModelsCT); j++)
{
if (StrEqual(gsg9ModelsCT[j], sModelCT))
{
SetEntityModel(client,fbiModelsCT[GetRandomInt(0 , -1)]);
}
}
for (int k = 0; k < sizeof(gignModelsCT); k++)
{
if (StrEqual(gignModelsCT[k], sModelCT))
{
SetEntityModel(client,fbiModelsCT[GetRandomInt(0 , -1)]);
}
}
for (int l = 0; l < sizeof(idfModelsCT); l++)
{
if (StrEqual(idfModelsCT[l], sModelCT))
{
SetEntityModel(client,fbiModelsCT[GetRandomInt(0 , -1)]);
}
}
for (int m = 0; m < sizeof(sasModelsCT); m++)
{
if (StrEqual(sasModelsCT[m], sModelCT))
{
SetEntityModel(client,gignModelsCT[GetRandomInt(0 , -1)]);
}
}
for (int n = 0; n < sizeof(st6ModelsCT); n++)
{
if (StrEqual(st6ModelsCT[n], sModelCT))
{
SetEntityModel(client,fbiModelsCT[GetRandomInt(0 , -1)]);
}
}
for (int o = 0; o < sizeof(swatModelsCT); o++)
{
if (StrEqual(swatModelsCT[o], sModelCT))
{
SetEntityModel(client,gignModelsCT[GetRandomInt(0 , -1)]);
}
}
SetEntPropString(client, Prop_Send, "m_szArmsModel", "models/weapons/ct_arms.mdl"); // First set default Armsmodel.
SetEntPropString(client, Prop_Send, "m_szArmsModel", "models/player/custom_player/superheroes/black_panther/black_panther_arms.mdl"); // Now we can replace the default Armmodel with our Custom one.
CreateTimer(1.5, PlayerModel, client); // Create Timer with delay before setting the new Playermodel.
}
}
return Plugin_Continue;
}
public Action PlayerModel(Handle timer ,any client)
{
if(GetClientTeam(client) == 2)
{
// Set the Custom Playermodel.
SetEntityModel(client,"models/player/custom_player/superheroes/ultron/ultron.mdl");
}
else if(GetClientTeam(client) == 3)
{
// Set the Custom Playermodel.
SetEntityModel(client,"models/player/custom_player/superheroes/black_panther/black_panther.mdl");
}
}
bool isValidClient(int client, bool bot = false)
{
if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client) && (bot ? IsFakeClient(client) : !IsFakeClient(client)))
return true;
return false;
}
Hopefully this work for a while before Valve will destroy it again.
It worked perfectly on my local server (windows), but on my dedicated server (linux) it gets desynchronized setting the arms at the wrong time, etc. Do you know why this is happening?
ps: sorry for my english (Google Translate)
Last edited by brunoronning; 03-29-2017 at 16:22.
Reason: edit