Hello,
I'm working off an already-created plugin for personal use, a plugin that lets you play as robots in TF2. I was interested in the Precache function and thought I could use that for any model, provided theres an MDL in the /models and the player types a command of the path, say "/clone/clonetrooper.mdl". However I am very new to sourcemod scripting and have ran into problems. When trying to compile this I get many errors like some of the variables are shadowing a variable at a preceding level, undefined/invalid expressions, etc. The full SP is attached, the code of problem is at 413-428, and 561-585:
-Argument that changes player stats and runs custom model command:
PHP Code:
public Action:Command_Cmodel_Me(client, args)
{
if (GetClientTeam(client) ==3)
{
SetEntPropFloat(client, Prop_Send, "m_flModelScale", 1.0);
TF2Attrib_SetByName(client, "max health additive bonus", 1000.0);
SetEntityHealth(client, 1000);
SetModelC(client, args);
ReplyToCommand(client, "[Red2Robot] You now have a custom model!");
ShowActivity2(client, "[Red2Robot] ", "%N is now using a custom model!", client);
}
else
{
ReplyToCommand(client, "[Red2Robot] You need to be in the BLU/Robots team in order to get a custom model.");
}
}
-Custom model command:
PHP Code:
stock bool:SetModelC(client)
{
if (args == 1):
new String:arg1[128]
GetCmdArg(1, arg1, 128);
if (!IsValidClient(client)) return false;
if (!IsPlayerAlive(client)) return false;
new String:Mdl[PLATFORM_MAX_PATH];
switch (TF2_GetPlayerClass(client))
{
Format(Mdl, sizeof(Mdl), arg1);
}
if (!StrEquals(Mdl, ""))
{
Format(Mdl, sizeof(Mdl), "models/%s.mdl", Mdl);
PrecacheModel(Mdl);
}
SetVariantString(Mdl);
AcceptEntityInput(client, "SetCustomModel");
SetEntProp(client, Prop_Send, "m_bUseClassAnimations", 1);
if (StrEqual(Mdl, "")) return false;
return true;
else if (args == 0):
ReplyToCommand(client, "[Red2Robot] Error no input found!");
}
Its probably because I don't know how to import strings from a command
If anyone could help that would be awesome.
Thanks