View Single Post
  #15  
Old 03-26-2011, 11:01 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
A weapon is not necessarily a weapon. In most cases you will have system "weapons" in addition to normal weapons.

Weapons whose names start with a dash aren't shown in the player's inventory (if you have a custom inventory, you can name them differently, of course).

Assuming you don't have a custom inventory, you'll want to create a weapon named something like -LoginWindow and place this code in it:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  new 
GuiWindowCtrl("MyWindow") {
    
profile GuiBlueWindowProfile;
  
    
width 200;
    
height 200;
    
    
text "Window";
  }

Now if you open your player's attributes and add -LoginWindow to yourself, you'll see that every time you login the window opens automatically.

Classes are a freak of GScript. I don't know a way to compare them to any other language. Since GS2 doesn't have actual class support (inheritance, custom objects, etc), classes allow you to reuse code. When you join a class to a weapon, it's essentially copying and pasting the code inside the class into the weapon so you can use any of the code in the class in that weapon.

The only way to actually run code on clientside (excepting level NPCs and DB NPCs) is with a weapon. Since DB NPCs and level NPCs are stuck to a single level, if you want to do anything clientside you will want to use a weapon.

An explanation of clientside/serverside:

Quote:
Originally Posted by cbk1994 View Post
There are essentially two different ways you script: on serverside, or on clientside. If a script is serverside, it means that the NPC-server interprets and performs the code. The advantage to this is that you know the code can't be tamperered with. If the code is clientside, it means that it is ran on the computer of the player. This has the advantage of being faster and not requiring communication with the server, but has the disadvantage of being less secure.

Since serverside is not performed for a specific player it cannot display interface graphics (HUDs, etc). It also can't handle player chat events, among others.
If you haven't seen it already, this video can be helpful in explaining NC a bit:



There are a lot of things I would change in the video now but it might be useful. Maybe I should do a follow-up of it.

Let me know if there's anything you don't understand.
__________________
Reply With Quote