Junior Member
|
04-12-2018
, 10:14
sub-model, p_, w_
|
#1
|
Hi, my model its sub model: Submodel 1, Submodel 2, Submodel 3, Submodel 4... p_, w_
I got a p_ and w model, it contains 20 sub-models inside.
how to show the sub model from .cfg?
skins.cfg
"id" "name" "v_" "p_" "w_" "sub id" - this is sub-id how to make this?
This is my code
Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
#include <cstrike>
#define MAX 200
new const PLUGIN[] = "New Plug-In";
new const VERSION[] = "1.0";
new const AUTHOR[] = "author";
/*================================================================================
=================================================================================*/
new const g_weapons[] =
{
CSW_P228, CSW_SCOUT, CSW_XM1014, CSW_MAC10, CSW_AUG, CSW_ELITE, CSW_FIVESEVEN, CSW_UMP45, CSW_SG550, CSW_GALI, CSW_GALIL, CSW_FAMAS, CSW_USP,
CSW_GLOCK18, CSW_AWP, CSW_MP5NAVY, CSW_M249, CSW_M3, CSW_M4A1, CSW_TMP, CSW_G3SG1, CSW_DEAGLE, CSW_SG552, CSW_AK47, CSW_P90
}
new const g_max_clip[] = { 13, 10, 7, 30, 30, 30, 20, 25, 30, 35, 35, 25, 12, 20, 10, 30, 100, 8, 30, 30, 20, 7, 30, 30, 50 }
enum _:AmmoIds { ammo_none, ammo_338magnum = 1, ammo_762nato, ammo_556natobox, ammo_556nato, ammo_buckshot, ammo_45acp, ammo_57mm, ammo_50ae, ammo_357sig, ammo_9mm }
new g_iAmmoMax[AmmoIds] = { -1, 30, 90, 200, 90, 32, 100, 100, 35, 52, 120 }
new const g_iAmmoWeaponSharedBitSum[AmmoIds] = { 0,
(1<<CSW_AWP), (1<<CSW_SCOUT)|(1<<CSW_G3SG1)|(1<<CSW_AK47), (1<<CSW_M249),
(1<<CSW_AUG)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_M4A1)|(1<<CSW_SG552),
(1<<CSW_XM1014)|(1<<CSW_M3), (1<<CSW_MAC10)|(1<<CSW_UMP45)|(1<<CSW_USP),
(1<<CSW_P90)|(1<<CSW_FIVESEVEN), (1<<CSW_DEAGLE), (1<<CSW_P228),
(1<<CSW_MP5NAVY)|(1<<CSW_TMP)|(1<<CSW_ELITE)|(1<<CSW_GLOCK18)
}
new g_msgid_AmmoX;
#pragma semicolon 1;
new bUsingGuns[33][CSW_VESTHELM];
new WeaponMdls[MAX][128], WeaponMdlsP[MAX][128], WeaponMdlsW[MAX][128];
new WeaponNames[MAX][64], Weapons[MAX], WeaponDrop[MAX], AllWeapon;
new Folder[48], SkinFile[48];
new const eWeapon[][] =
{
"", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
"weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
"weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy",
"weapon_m249", "weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang",
"weapon_deagle", "weapon_sg552", "weapon_ak47", "weapon_knife", "weapon_p90"
};
public plugin_precache()
{
new Line[512], Data[10][128], Len;
AllWeapon++;
get_configsdir(Folder, 47);
format(SkinFile, 47, "%s/rcsgo/skins.cfg", Folder);
if(file_exists(SkinFile))
{
for(new i; i < file_size(SkinFile, 1); i++)
{
if(AllWeapon >= MAX)
{
break;
}
read_file(SkinFile, i, Line, 512, Len);
if(strlen(Line) < 5 || Line[0] == ';' || (Line[0] == '/' && Line[1] == '/'))
continue;
parse(Line, Data[0], 31, Data[1], 31, Data[2], 128, Data[3], 128, Data[4], 128, Data[5]);
Weapons[AllWeapon] = str_to_num(Data[0]);
copy(WeaponNames[AllWeapon], 63, Data[1]);
if(ValidMdl(Data[2]))
{
precache_model(Data[2]);
copy(WeaponMdls[AllWeapon], 128, Data[2]);
if(file_exists(Data[3]) && strlen(Data[3]) > 5)
{
precache_model(Data[3]);
copy(WeaponMdlsP[AllWeapon], 128, Data[3]);
}
if(file_exists(Data[4]) && strlen(Data[3]) > 5)
{
precache_model(Data[4]);
copy(WeaponMdlsW[AllWeapon], 128, Data[4]);
}
}
WeaponDrop[AllWeapon] = str_to_num(Data[5]);
}
}
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_forward(FM_SetModel, "SetModel", 1);
for(new i; i < sizeof(eWeapon); i++)
{
if(strlen(eWeapon[i]) > 3)
{
RegisterHam(Ham_Item_Deploy, eWeapon[i], "WeaponSwitch", 1);
}
}
}
public SetModel(entity, const model[])
{
if(!pev_valid(entity))
return FMRES_IGNORED;
new classname[32]; pev(entity, pev_classname, classname, sizeof(classname));
if(!equal(classname, "weaponbox"))
return FMRES_IGNORED;
new id; id = pev(entity, pev_owner);
new wid; wid = get_user_weapon(id, _, _);
new weapon; weapon = find_ent_by_owner(-1, eWeapon[wid], entity);
if(!is_user_connected(id))
{
return FMRES_SUPERCEDE;
}
if(bUsingGuns[id][wid] && !pev(weapon, pev_impulse))
{
set_pev(weapon, pev_impulse, bUsingGuns[id][wid]);
if(strlen(WeaponMdlsW[pev(weapon, pev_impulse)]) > 5)
{
entity_set_model(entity, WeaponMdlsW[bUsingGuns[id][wid]]);
}
}
else if(bUsingGuns[id][wid])
{
if(strlen(WeaponMdlsW[bUsingGuns[id][wid]]) > 5)
{
entity_set_model(entity, WeaponMdlsW[bUsingGuns[id][wid]]);
}
}
return FMRES_IGNORED;
}
public WeaponSwitch(Weapon)
{
new id = get_pdata_cbase(Weapon, 41, 4);
new wid = cs_get_weapon_id(Weapon);
if(id > 32 || id < 1)
{
return HAM_SUPERCEDE;
}
if(!is_user_connected(id))
{
return HAM_SUPERCEDE;
}
if(pev(Weapon, pev_impulse))
{
set_pev(id, pev_viewmodel2, WeaponMdls[pev(Weapon, pev_impulse)]);
if(strlen(WeaponMdlsP[pev(Weapon, pev_impulse)]) > 5)
{
set_pev(id, pev_weaponmodel2, WeaponMdlsP[pev(Weapon, pev_impulse)]);
}
}
else if(bUsingGuns[id][wid])
{
set_pev(id, pev_viewmodel2, WeaponMdls[bUsingGuns[id][wid]]);
if(strlen(WeaponMdlsP[bUsingGuns[id][wid]]) > 5)
{
set_pev(id, pev_weaponmodel2, WeaponMdlsP[bUsingGuns[id][wid]]);
}
set_task(0.1, "UpdateStatusText", id);
}
return HAM_IGNORED;
}
public client_disconnected(id)
{
for(new i; i < CSW_VESTHELM; i++) { bUsingGuns[id][i] = 0; }
}
public client_putinserver(id)
{
for(new i; i < CSW_VESTHELM; i++) { bUsingGuns[id][i] = 0; }
}
stock ExplodeString(const string[], output[], olen = sizeof output)
{
new len = strlen(string); // We retrieve the length of the current string passed.
if (!len) { return 0; } // If the string is empty we stop there.
new i, c, j, count;
new number[12];
do {
while (string[i] == ' ') i++; // One or more spaces can be used between 2 numbers, so we move forward until we find a number.
while ((number[j++] = c = string[i++]) && c != ' ') {} // We loop and save the number found until the next space found or end of string.
output[count++] = str_to_num(number); // We convert the number saved previously into a number and we stored in output at the slot count.
j = 0; }
while (i < len && count < olen); // We should looping while we have not cross the string length.
return count;
}
stock get_user_name_ex(id)
{
new szName[33]; get_user_name(id, szName, charsmax(szName));
replace_all(szName, charsmax(szName), "'", "\'");
replace_all(szName, charsmax(szName), "^"", "\^"");
return szName;
}
stock bool:ValidMdl(Mdl[])
{
return (containi(Mdl, ".mdl") != -1) ? true : false;
}
stock get_weapon_maxclip(wpnid = 0)
{
for(new a = 0; a < sizeof (g_weapons); a++)
{
if(wpnid == g_weapons[a])
{
return g_max_clip[a];
}
}
return false;
}
stock SetFullBpAmmo(id, iWeaponID)
{
new iFullbpammo, iAmmoId;
for(new i = 1; i < AmmoIds; i++)
{
if(g_iAmmoWeaponSharedBitSum[i] & (1<<iWeaponID))
{
iAmmoId = i;
iFullbpammo = g_iAmmoMax[i];
break;
}
}
if(!iAmmoId) return;
cs_set_user_bpammo(id, iWeaponID, iFullbpammo);
message_begin(MSG_ONE_UNRELIABLE, g_msgid_AmmoX, _, id);
write_byte(iAmmoId);
write_byte(iFullbpammo);
message_end();
}
stock has_user_weapon(id, iCswId, iSlot = 0)
{
new iWeapon;
if(!iSlot)
{
static const iWeaponsSlots[] =
{
-1,
2, // CSW_P228
-1,
1, // CSW_SCOUT
4, // CSW_HEGRENADE
1, // CSW_XM1014
5, // CSW_C4
1, // CSW_MAC10
1, // CSW_AUG
4, // CSW_SMOKEGRENADE
2, // CSW_ELITE
2, // CSW_FIVESEVEN
1, // CSW_UMP45
1, // CSW_SG550
1, // CSW_GALIL
1, // CSW_FAMAS
2, // CSW_USP
2, // CSW_GLOCK18
1, // CSW_AWP
1, // CSW_MP5NAVY
1, // CSW_M249
1, // CSW_M3
1, // CSW_M4A1
1, // CSW_TMP
1, // CSW_G3SG1
4, // CSW_FLASHBANG
2, // CSW_DEAGLE
1, // CSW_SG552
1, // CSW_AK47
3, // CSW_KNIFE
1 // CSW_P90
}; iSlot = iWeaponsSlots[iCswId];
}
const XO_PLAYER = 5;
const m_rgpPlayerItems_Slot0 = 367;
iWeapon = get_pdata_cbase(id, m_rgpPlayerItems_Slot0 + iSlot, XO_PLAYER);
const XO_WEAPON = 4;
const m_pNext = 42;
const m_iId = 43;
while(iWeapon > 0)
{
if(get_pdata_int(iWeapon, m_iId, XO_WEAPON) == iCswId)
return iWeapon;
iWeapon = get_pdata_cbase(iWeapon, m_pNext, XO_WEAPON);
}
return 0;
}
Last edited by Bugsy; 04-12-2018 at 18:52.
|
|