I was making a cool inventory with particle effects for use with my item system and someone asked me to make them one that works with just classic weapons and since Ziro's apperently can't be copied and pasted into a WNPC(?) I figured I'd make one with tabs that could. I gave it to them and they had 100000 questions about it so I figured I could just post it here and explain it.
This is how it works:
You must first put your weapon's into categories ex "Weapons/Bow" or "Tools/Hammer". After doing that all you have to do is edit thiso.weapontabs and put the category into the array. Say you wanted to add everything in "Tools/" you would do it like this:
PHP Code:
thiso.weapontabs = {"Tools"};
everything in "Tools/" would show up like "Tools/Hammer", "Tools/Axe","Tools/Water Can" or whatever.
Next lets say you want to add a new tab for event items right after that would contain everything in "Events/" you would just do:
PHP Code:
thiso.weapontabs = {"Tools","Events"};
Everything in this tab would be things like "Events/Color Changer" or "Events/Ban Hammer".
If you want to change your images just put this into your weapon npcs.
PHP Code:
this.image = "imagename.png";
This will not show anything that is just "WeaponName" so everything must be categorized which will help with organization. I would suggest putting all the weapons like 'system weapons' and anything you dont want the player to have access to as just "WeaponName" with no category. I tried to explain this as best I could so there wont be any questions but I guess feel free to ask.
PHP Code:
//#CLIENTSIDE
function onCreated(){
thiso.weapontabs = {"Weapons","Events","Tools","Fun","Etc"};
enablefeatures(allfeatures - 4);
onOpenInventoryGui();
InventoryGuiControl_Container.hide();
}
function onKeyPressed(){
if (keydown(9))
{
if (InventoryGuiControl_Container.visible = false)
{
InventoryGuiControl_Container.show();
onOpenInventoryGui();
}
elseif (InventoryGuiControl_Container.visible = true){
InventoryGuiControl_Container.hide();
}
}
}
function onOpenInventoryGui(){
new GuiControl("InventoryGuiControl_Container"){
extent = "332 270";
x = (screenwidth/2)-width/2;
y = (screenheight/2)-height/2;
new GuiTabCtrl("InventoryGuiTabCtrl_TabSelect"){
profile = "GuiBlueTabProfile";
x = 0;
y = 0;
extent = "332 20";
tabwidth = 326/thiso.weapontabs.size();
clearrows();
for (temp.i = 0; temp.i < thiso.weapontabs.size(); temp.i++)
{
addrow(temp.i, thiso.weapontabs[temp.i]);
thiso.catchevent(name,"onSelect","onUpdateInventory");
}
setselectedrow(0);
}
new GuiScrollCtrl("InventoryGuiScrollCtrl_WeaponList"){
profile = "GuiBlueScrollProfile";
x = 0;
y = 20;
extent = "332 230";
hscrollbar = "alwaysOff";
}
new GuiScrollCtrl("InventoryGuiScrollCtrl_WeaponNameContainer"){
profile = "GuiBlueScrollProfile";
x = 0;
y = 250;
extent = "332 26";
hscrollbar = vscrollbar = "alwaysOff";
new GuiMLTextCtrl("InventoryGuiMLTextCtrl_WeaponName"){
profile = "GuiBlueMLTextProfile";
x = 0;
y = 0;
extent = "332 20";
text = "";
}
}
}
onUpdateInventory();
}
function onUpdateInventory(){
for (temp.i = 0; temp.i < player.weapons.size();temp.i++)
{
(@ "InventoryGuiBitmapCtrl_Weapon_" @ temp.i).destroy();
}
temp.w = "-1";
temp.h = "0";
for (temp.i = 0; temp.i < player.weapons.size();temp.i++)
{
with (InventoryGuiScrollCtrl_WeaponList){
temp.weaponsection = InventoryGuiTabCtrl_TabSelect.getselectedtext();
if (player.weapons[i].name.starts(temp.weaponsection))
{
if (!(player.weapons[i].name.starts("-") || player.weapons[i].name.starts("*")))
{
if (temp.w > 7)
{
temp.w = "0";
temp.h++;
}
else
temp.w++;
new GuiBitmapCtrl("InventoryGuiBitmapCtrl_Weapon_" @ temp.i){
x = (temp.w*34)+5;
y = (temp.h*34)+6;
extent = "32 32";
bitmap = player.weapons[i].image;
hint = player.weapons[i].name;
this.wepid = temp.i;
this.wepname = player.weapons[i].name;
thiso.catchevent(name,"onMouseMove","onSetGuiText");
thiso.catchevent(name,"onMouseDown","onSetWeapon");
}
}
}
}
}
GraalControl.makeFirstResponder(true);
}
function onSetWeapon(GuiBitmapCtrl_Weapon){
selectedweapon = GuiBitmapCtrl_Weapon.wepid;
}
function onSetGuiText(GuiBitmapCtrl_WeaponName){
InventoryGuiMLTextCtrl_WeaponName.text = GuiBitmapCtrl_WeaponName.wepname;
}