Hey guys,
I just randomly coded this plugin, and I just wanted to know if it has a good quality and would actually function properly?
PHP Code:
#include < amxmodx >
#include < cstrike >
#include < hamsandwich >
new Array:g_ArrPlayerModel;
new const g_szPlayerModel[][] = { "model_one", "model_two" };
public plugin_precache()
{
g_ArrPlayerModel = ArrayCreate(32, 1);
new Index;
for(Index = 0; Index < sizeof g_szPlayerModel; Index++)
ArrayPushString(g_ArrPlayerModel, g_szPlayerModel[index]);
new Path[100];
for(Index = 0; Index < ArraySize(g_ArrPlayerModel); Index++)
{
ArrayGetString(g_ArrPlayerModel, Index, Path, charsmax(Path));
format(Path, charsmax(Path), "models/player/%s/%s.mdl", Path, Path);
precache_model(Path);
format(Path, charsmax(Path), "models/player/%s/%sT.mdl", Path, Path);
if( file_exists(Path) )
precache_model(Path);
}
}
public plugin_init()
{
register_plugin("Model Set", "1.0", "Chilimax");
RegisterHam(Ham_Spawn, "player", "Ham_PlayerSpawn_Post", true);
}
public Ham_PlayerSpawn_Post(Index)
{
if( !is_user_alive(Index) || !cs_get_user_team(Index) )
return;
new Model[32];
ArrayGetString(g_ArrPlayerModel, random_num(0, ArraySize(g_ArrPlayerModel) - 1), Model, charsmax(Model));
cs_set_user_model(Index, Model);
}
And what about this one, too?
PHP Code:
#include < amxmodx >
#include < cstrike >
#include < hamsandwich >
new const g_szPlayerModel[][] = { "model_one", "model_two" };
public plugin_precache()
{
new Path[100];
for(Index = 0; Index < sizeof g_szPlayerModel; Index++)
{
formatex(Path, charsmax(Path), "models/player/%s/%s.mdl", g_szPlayerModel[Index], g_szPlayerModel[Index]);
precache_model(Path);
formatex(Path, charsmax(Path), "models/player/%s/%sT.mdl", g_szPlayerModel[Index], g_szPlayerModel[Index]);
if( file_exists(Path) )
precache_model(Path);
}
}
public plugin_init()
{
register_plugin("Model Set", "1.0", "Chilimax");
RegisterHam(Ham_Spawn, "player", "Ham_PlayerSpawn_Post", true);
}
public Ham_PlayerSpawn_Post(Index)
{
if( !is_user_alive(Index) || !cs_get_user_team(Index) )
return;
new Model[32];
GetRandomModel(random_num(0, sizeof g_szPlayerModel), Model, charsmax(Model));
cs_set_user_model(Index, Model);
}
GetRandomModel(iRandom, Model[], iLen)
{
new Index;
for(Index = 0; Index < sizeof g_szPlayerModel; Index++)
{
if( iRandom == Index )
return formatex(Model, iLen, "%s", g_szPlayerModel[iRandom]);
}
return -1;
}
__________________