Code:
#include <amxmodx>
//#include <rose>
public plugin_init() {
register_plugin("Test Plugin 8", "1.0", "[ --{-@ ]");
}
// F: models/(\w+/)?v_([abcdefghijklmnopqrstuvxyz0123456789]+)(\_\w+)?\.mdl
// R: models/v_\2.mdl
new Array:g_aRankName;
new Array:g_aRankKills;
new Array:g_aSkinWeaponID;
new Array:g_aSkinName;
new Array:g_aSkinModel;
new Array:g_aSkinChance;
new Array:g_aSkinCostMin;
new Array:g_aSkinBody;
new g_iRanksNum;
new g_iSkinsNum;
enum dummyshit {
PATH[256],
BODYINDEX,
}
new g_eDefaultModels[50][dummyshit]
public plugin_precache()
{
//new hTimer = TimerStart();
g_aRankName = ArrayCreate(32);
g_aRankKills = ArrayCreate();
g_aSkinWeaponID = ArrayCreate();
g_aSkinName = ArrayCreate(32)
g_aSkinModel = ArrayCreate(128);
g_aSkinChance = ArrayCreate();
g_aSkinCostMin = ArrayCreate();
g_aSkinBody = ArrayCreate();
new fp = fopen("addons/amxmodx/configs/csgoclassy.ini", "rt");
if (!fp)
{
set_fail_state("[CSGO Classy] Could not open file csgoclassy.ini");
}
new buff[256];
new section;
new leftpart[48];
new rightpart[48];
new weaponid[4];
new weaponname[32];
new weaponmodel[128];
new weaponchance[8];
new weaponcostmin[8];
new bodypart[8]
new weapontype[5];
new szTemp[2][64];
new Dummy[32]
while(fgets(fp, buff, charsmax(buff)))
{
trim(buff);
if(buff[0] == ';' || buff[0] == EOS || buff[0] == '#' || buff[0] == ' ')
{
continue
}
if (buff[0] == '[')
{
section += 1;
continue;
}
switch (section)
{
case 1:
{
strtok(buff, szTemp[0], charsmax(szTemp[]), szTemp[1], charsmax(szTemp[]), '=', 1);
if(equali(szTemp[0], "MYSQL_HOST"))
{
copy(Dummy, charsmax(Dummy), szTemp[1]);
}
if(equali(szTemp[0], "MYSQL_USER"))
{
copy(Dummy, charsmax(Dummy), szTemp[1]);
}
if(equali(szTemp[0], "MYSQL_PASS"))
{
copy(Dummy, charsmax(Dummy), szTemp[1]);
}
if(equali(szTemp[0], "MYSQL_DB"))
{
copy(Dummy, charsmax(Dummy), szTemp[1]);
}
}
case 2:
{
parse(buff, leftpart, charsmax(leftpart), rightpart, charsmax(rightpart));
ArrayPushString(g_aRankName, leftpart);
ArrayPushCell(g_aRankKills, str_to_num(rightpart));
g_iRanksNum += 1;
}
case 3:
{
parse(buff, weaponid, charsmax(weaponid), weaponmodel, charsmax(weaponmodel), bodypart, charsmax(bodypart));
if(file_exists(weaponmodel))
{
precache_model(weaponmodel);
}
else
{
if(containi(weaponmodel, ".mdl") == -1)
{
log_to_file("DUMBLOG.log", "The model that you tried to precache doesn't have a .mdl extension. This error occurs when a section from csgoclassy.ini doesn't exists.")
}
server_print("You have a missing model ^"%s^" in the [DEFAULT] section of csgoclassy.ini", weaponmodel);
set_fail_state("");
}
copy(g_eDefaultModels[str_to_num(weaponid)][PATH], charsmax(g_eDefaultModels[][PATH]), weaponmodel)
g_eDefaultModels[str_to_num(weaponid)][BODYINDEX] = strlen(bodypart) > 0 ? str_to_num(bodypart) : 0
}
case 4:
{
switch(0)
{
case 0: parse(buff, weaponid, 3, weaponname, 31, weaponmodel, charsmax(weaponmodel), weaponchance, 7, weaponcostmin, 7, bodypart, 7);
case 1: parse(buff, weaponid, 3, weaponname, 31, weaponmodel, charsmax(weaponmodel), weapontype, charsmax(weapontype), weaponchance, 7, weaponcostmin, 7, bodypart, 7);
}
if (!file_exists(weaponmodel))
{
server_print("[CSGO Classy] You have a missing model ^"%s^" in the [SKINS] section of csgoclassy.ini", weaponmodel);
set_fail_state("");
}
/*
if(false)
{
switch(weapontype[0])
{
case 'c': ArrayPushCell(g_aSkinType, CRAFT_SKIN);
case 'd': ArrayPushCell(g_aSkinType, DROP_SKIN);
}
}
*/
if(!equal(g_eDefaultModels[str_to_num(weaponid)], weaponmodel))
{
precache_model(weaponmodel)
}
ArrayPushCell(g_aSkinWeaponID, str_to_num(weaponid));
ArrayPushString(g_aSkinName, weaponname);
ArrayPushString(g_aSkinModel, weaponmodel);
ArrayPushCell(g_aSkinChance, str_to_num(weaponchance));
ArrayPushCell(g_aSkinCostMin, str_to_num(weaponcostmin));
ArrayPushCell(g_aSkinBody, str_to_num(bodypart))
g_iSkinsNum += 1;
}
}
}
fclose(fp);
//TimerStop(hTimer);
//TimerServerPrint(hTimer, 2, false, "Done, %T");
return PLUGIN_CONTINUE
}