Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Weapons -IRC -Playerlist etc (https://forums.graalonline.com/forums/showthread.php?t=66703)

Omini 06-16-2006 06:22 AM

Weapons -IRC -Playerlist etc
 
I'm trying to make a Q Menu, but when I categorize the weapons then try displaying them, I always get shown these (in this order)

Quote:

Originally Posted by Weapons
-IRC
-Playerlist
-F2LogWindow
-F1HelpWindow
-IRC_Installer
-LoadingScreen3D
-IRCEvents

Then my weapons start getting listed. Is there any way to avoid this?

ApothiX 06-16-2006 06:51 AM

PHP Code:

this.systemweapons = { "-IRC""-Playerlist""-F2LogWindow""-F1HelpWindow""-IRC_Installer""-LoadingScreen3D""-IRCEvents" };

temp.playeractualweapons NULL;
for(
temp.checkweaponplayer.weapons) {
  if(
this.systemweapons.index(temp.checkweapon) < 0) {
    
temp.playeractualweapons.add(temp.checkweapon);
  }


?

Andy0687 06-16-2006 06:54 AM

Quote:

Originally Posted by Omini
I'm trying to make a Q Menu, but when I categorize the weapons then try displaying them, I always get shown these (in this order)

Then my weapons start getting listed. Is there any way to avoid this?

Not sure if youve tried it but just dont display any weapons with a - in the front.

PHP Code:

if (obj.substring(0,1) != "-") {


Not sure of any of your code or what you have or havent tried, when you are looking at the weapon-name just make sure the first mark isnt a dash, if it is, just skip over it.

ApothiX 06-16-2006 06:59 AM

Quote:

Originally Posted by Andy0687
Not sure if youve tried it but just dont display any weapons with a - in the front.

PHP Code:

if (obj.substring(0,1) != "-") {


Not sure of any of your code or what you have or havent tried, when you are looking at the weapon-name just make sure the first mark isnt a dash, if it is, just skip over it.

Good advice, -Weapons are supposed to be invisible anyway. However, you should use if(obj.starts("-")) instead of the substring variation.

Omini 06-16-2006 11:36 AM

Yeah I've got this in

PHP Code:

function GetWeaponList()
  {
  
thiso.weapons_systems.clear();
  
thiso.weapons_guns.clear();
  
thiso.weapons_ammo.clear();
  
thiso.weapons_player.clear();
  
thiso.weapons_toys.clear();
  
thiso.weapons_other.clear();
  for(
i=0;i<player.weapons.size();i++) {
    if(
player.weapons[i].name.starts("-")) {
      
thiso.weapons_systems.add(i);
    }
    elseif(
player.weapons[i].name.starts("Guns/")) {
      
thiso.weapons_guns.add(i);
    }
    elseif(
player.weapons[i].name.starts("Ammo/")) {
      
thiso.weapons_ammo.add(i);
    }
    elseif(
player.weapons[i].name.starts("Player/")) {
      
thiso.weapons_player.add(i);
    }
    elseif(
player.weapons[i].name.starts("Toys/")) {
      
thiso.weapons_toys.add(i);
    }
    else {
      
thiso.weapons_other.add(i);
    }
  }


I'll try what Okie said then get back to you.

Edit:

Ok so I tried this
PHP Code:

function GetWeaponList()
  {
  
this.systemweapons = { "-IRC""-Playerlist""-F2LogWindow""-F1HelpWindow""-IRC_Installer""-LoadingScreen3D""-IRCEvents" };

  
temp.playeractualweapons NULL;
  for(
temp.checkweaponplayer.weapons) {
    if(
this.systemweapons.index(temp.checkweapon) < 0) {
      
temp.playeractualweapons.add(temp.checkweapon);
    }
  } 


And the bit where it shows the weapon names is (Within the GUI Window Ctrl etc etc, it was all working somewhat fine)

PHP Code:

new GuiScrollCtrl(QMenu_ItemList) {
      
awake true;
      
canmove true;
      
height QMenu_Window.height-40;
      
vscrollbar "dynamic";
      
hscrollbar "alwaysOff";
      
profile "GuiRedScrollProfile";
      
scriptlogmissingfunctions true;
      
visible true;
      
width QMenu_Window.width-80;
      
70;
      
28;
      
      for (
w=0;w<temp.playeractualweapons.size();w++) {
        new 
GuiTextCtrl("QMenu_Weapon"@w) {
          
2;
          
11;
          
width 200;
          
height 20;
          
useownprofile true;
          
profile.fontcolor = {1,1,1};
          
text temp.playeractualweapons[w].name;
        }
      }
    } 

Any suggestions?

Andy0687 06-17-2006 04:54 AM

Quote:

Originally Posted by ApothiX
Good advice, -Weapons are supposed to be invisible anyway. However, you should use if(obj.starts("-")) instead of the substring variation.

Is either more processor intensive then the other?
Just wondering.

Substring was the first thing that popped into my head that would have worked, so thanks for that.

Quote:

Originally Posted by Omini
newstuff+code

Sorry, is something still wrong or broken?

ApothiX 06-17-2006 04:58 AM

Quote:

Originally Posted by Andy0687
Is either more processor intensive then the other?
Just wondering.

Probably not, but obj.starts() looks a bit neater than extracting a substring and comparing it, IMO.

Loriel 06-17-2006 06:32 AM

Quote:

Originally Posted by Andy0687
Is either more processor intensive then the other?

I believe so. Creating a new string object that represents the substring is probably less performant than just checking the beginning of a pre-existing string against another pre-existing string.

Omini 06-17-2006 09:08 AM

Quote:

Originally Posted by Andy0687
Sorry, is something still wrong or broken?

Yes. It's still listing those weapons first before the actual string.

Admins 06-17-2006 05:53 PM

Should be obj.name.starts("-") and "this.systemweapons.index(temp.checkweapon.nam e) < 0"

Omini 06-17-2006 07:30 PM

I don't quite catch what you mean... what am I meant to do with the obj.name.starts("-")?

ApothiX 06-17-2006 09:47 PM

Your problem is that you are using temp.variables in a function. temp.variables only exist during a single execution, and are only in the scope of where you create them, I believe.

Change the temp.playeractualweapons to this. and it should work. (Except in the new GuiBlah() you must use 'thiso.' instead of 'this.')


All times are GMT +2. The time now is 06:28 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.