Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   RC NPC-Control (Ingame) (https://forums.graalonline.com/forums/showthread.php?t=69079)

KuJi 09-30-2006 08:35 PM

RC NPC-Control (Ingame)
 
1 Attachment(s)
Okay.. this was my first attempt to make an NPC-Control ingame. It's about 309 lines or so. Picture Included.

Rep is a nice way to thank me btw =).. maybe I'll add some other cool thingys. Anywa.. tell me if its useful VIA poll.

PHP Code:

// NPC Made by KuJi - V1.0
//#CLIENTSIDE
function onCreated()
{
  
requesttext("clientrc"1);
  
  
onShowGUI();
}

function 
onShowGUI()

  if (
NC_Window != NULL)
  {
    
NC_Window.destroy();
  }
  
  new 
GuiWindowCtrl(NC_Window)
  {
    
height               460;
    
profile              GuiBlueWindowProfile;
    
text                 "NC Control (V1.0 by KuJi) ";
    
width                577;
    
x                    150;
    
y                    150;
    
    
visible              false;
    
    new 
GuiTabCtrl(NC_Tab)
    {
      
profile "GuiBlueTabProfile";
      
extent = {38025};
      
position = {18335};
      
      
horizSizing "width";
      
clearrows();
    }
    
    new 
GuiScrollCtrl(NC_Frame1)
    {
      
profile        GuiBlueScrollProfile;
      
extent         = {175431};
      
position       = {623};
      
      
hScrollBar     "dynamic";
      
vScrollBar     "dynamic";
      
vertSizing     "height";
      
      
useownprofile  true;
      
profile.opaque false;
      
      new 
GuiTreeViewCtrl(NC_Tree)
      {
        
profile GuiBlueTreeViewProfile;
        
0;
        
fitparentwidth true;
       
        
clearnodes();
        
addnodebypath("Classes""/");
        
addnodebypath("NPCS""/");
        
addnodebypath("Weapons""/");
      }
    }
    
    new 
GuiScrollCtrl(NC_Frame2)
    {
      
profile        GuiBlueScrollProfile;
      
extent         = {388355};
      
position       = {18260};
      
      
hScrollBar     "dynamic";
      
vScrollBar     "dynamic";
      
horizSizing    "width";
      
vertSizing     "height";
      
      
useownprofile  true;
      
profile.opaque false;
    }
    
    new 
GuiButtonCtrl(NC_Close)
    {
      
profile     GuiBlueButtonProfile;
      
extent      = {6525};
      
position    = {360423};
      
      
horizSizing "left";
      
vertSizing  "top";
      
text        "Close";
      
      
thiso.catchevent(this.name"onAction""onActionButton");
    }
    
    
    new 
GuiButtonCtrl(NC_Reload)
    {
      
profile     GuiBlueButtonProfile;
      
extent      = {6525};
      
position    = {430423};
      
      
horizSizing "left";
      
vertSizing  "top";
      
      
text        "Reload";
      
      
thiso.catchevent(this.name"onAction""onActionButton");
    }
    
    new 
GuiButtonCtrl(NC_Save)
    {
      
profile     GuiBlueButtonProfile;
      
extent      = {6525};
      
position    = {500423};
      
      
horizSizing "left";
      
vertSizing  "top";
      
      
text        "Save";
      
      
thiso.catchevent(this.name"onAction""onActionButton");
    }
  }
}

function 
NC_Tab.onSelect(tabidtabtexttabindex)
{
  for (
temp.var: NC_Tab.rows)
  {
    if (
temp.var.text == tabtext)
    {
      
temp.var.scriptedit.visible true;
    }
  }
}

function 
NC_Tab.onDeselect(tabidtabtexttabindex)
{
  for (
temp.var: NC_Tab.rows)
  {
    if (
temp.var.text == tabtext)
    {
      
temp.var.scriptedit.visible false;  
    }
  }
}


function 
NC_Tree.onDblClick(nodenodeslashpathnodedotpath)
{
  if (
nodeslashpath.starts("Classes/"))
  {
    
requesttext("class"nodeslashpath.substring(8));
  }
    elseif (
nodeslashpath.starts("Weapons/"))
  {
    
requesttext("weapon"nodeslashpath.substring(8));
  }
    elseif (
nodeslashpath.starts("NPCS/"))
  {
    
requesttext("npc"nodeslashpath.substring(5));
  }
}

function 
onReceiveText(texttypetextoptiontextlines)
{
  if (
texttype in {"classlist""npclist""weaponlist"})
  {
    
onAddScripts(textoptiontextlines);
  }
    elseif (
texttype in {"class""npc""weapon"})
  {
    
onViewScript(texttypetextoptiontextlines);
  }
}

function 
onAddScripts(temp.prefixtemp.textlines)
{
  if (
temp.prefix != NULL)
  {
    for (
temp.var: temp.textlines)
    {
      if (
temp.var != NULL)
      {
        
with (NC_Tree.addnodebypath(temp.prefix temp.var, "/"))
        {
          
image selectedimage 2;
        }
      }
    }
  }
}

function 
onViewScript(temp.texttypetemp.textoptiontemp.textlines)
{
  
temp.found NC_Tab.findtextid(temp.textoption);
  
  if (
temp.found >= 0)
  {
    
NC_Tab.setselectedbyid(temp.found);
    
    for (
temp.var: NC_Tab.rows)
    {
      if (
temp.var.id == temp.found)
      {
        
temp.var.scriptedit.setlines(temp.textlines);
      }
    }
    
    return 
true;
  }
    else
  {
    
    
with (NC_Frame2)
    {
      new 
GuiMLTextEditCtrl("NC_Edit_" temp.texttype "_" temp.textoption)
      {
        
profile            "TextEditorProfile";
        
extent             = {365225};
        
position           = {66};
        
        
horizSizing        "width";
        
vertSizing         "height";
        
        
syntaxHighlighting true;
        
wordwrap           false;
      
        
this.edittype      temp.texttype;
        
this.editoption    temp.textoption;
        
        
setlines(temp.textlines);
      }
    }
  
    
with (NC_Tab.addrow(this.tabid++, temp.textoption))
    {
      
this.scriptedit makevar("NC_Edit_" temp.texttype "_" temp.textoption);
      
NC_Tab.setselectedbyid(this.id);
    }
  } 
}

function 
onActionButton(obj)
{
  
temp.ncid NC_Tab.getselectedid();
  
  if (
temp.ncid <= -1)
  {
    return 
false;
  }
  
  switch (
obj.substring(3))
  {
    case 
"Close":
    {
      for (
temp.var: NC_Tab.rows)
      {
        if (
temp.var.id == temp.ncid)
        {
          
temp.var.scriptedit.destroy();
          
NC_Tab.removerowbyid(temp.ncid);
          
NC_Frame2.extent = {388355};
          
          break;
        }
      }
    
      break;
    }
    
    case 
"Reload":
    {
      for (
temp.var: NC_Tab.rows)
      {
        if (
temp.var.id == temp.ncid)
        {
          
requesttext(temp.var.scriptedit.edittypetemp.var.scriptedit.editoption);
          
          break;
        }
      }
      
      break;
    }
    
    case 
"Save":
    {
      for (
temp.var: NC_Tab.rows)
      {
        if (
temp.var.id == temp.ncid)
        {
          
sendtext(temp.var.scriptedit.edittypetemp.var.scriptedit.editoptiontemp.var.scriptedit.getLines());

          break;
        }
      }
    }
  }
}

function 
onKeyPressed(keycodekeychar)
{
  if (
keychar == '`')
  {
    
NC_Tree.clearnodes();
    
requesttext("classlist""Classes/");
    
requesttext("npclist""NPCS/");
    
requesttext("weaponlist""Weapons/");
    
    
NC_Window.visible = !NC_Window.visible;
  }


To Use:
Click ` to open/close it.

xAndrewx 09-30-2006 08:37 PM

Very cool, didn't bother checking the script, but looking at the screenshot it looks good and works, congradulations!

zephirot 09-30-2006 08:44 PM

Very good, keep up the good work.

KuJi 09-30-2006 08:49 PM

Yeah, I'd also like to give credit to Jagen.. the banned but wonderful scripter Jagen.

http://forums.graalonline.com/forums...ad.php?t=60379

I got the idea after viewing, but I don't recall his ever being released.. threw it together in like 8 hours.

If you think thats crazy amount of time.. I'd like to put that I watched The Matrix (1), Oceans Eleven and Oceans Twelve.. and played Bomberman with stefan and some others last night and this morning.

So in working time.. it's probally an hour.. in playing time about 8 =D

Angel_Light 10-01-2006 12:54 AM

awesome ;o

KuJi 10-01-2006 01:25 AM

Quote:

Originally Posted by Angel_Light (Post 1224335)
awesome ;o

Don't forget to rep me =D

zephirot 10-01-2006 01:35 AM

If I could.

KuJi 10-01-2006 02:38 AM

Quote:

Originally Posted by zephirot (Post 1224354)
If I could.

Hehe.

P.S. I got 29 rep =D. I'll try to add some cool stuff here later =).

Twinny 10-01-2006 04:08 AM

This is incredibly similar to what Jamilla did on UGCC x_x

[EDIT]: Apprently i'll be banned for linking to those forums but it's there in the NPC scripting part.

KuJi 10-01-2006 04:09 AM

Quote:

Originally Posted by Twinny (Post 1224413)
This is incredibly similar to what Jamilla did on UGCC x_x
BADLINK

oreally? Then I wasted my time?

I know.. I based mine off his and jagens =P. Also linking to that is not allowed in which is why I didn't.

Rapidwolve 10-01-2006 08:45 PM

How does the script write over the real script on RC

KuJi 10-01-2006 09:09 PM

Quote:

Originally Posted by Rapidwolve (Post 1224636)
How does the script write over the real script on RC

sendtext(TYPE, NAME, NEWTEXT4SCRIPT);

Skyld 10-01-2006 09:17 PM

Make the script editor background white.

Also, you'll need requesttext("clientrc", 1); for that sendtext() to work, which requires that your account as RC set up.

KuJi 10-01-2006 09:25 PM

Quote:

Originally Posted by Skyld (Post 1224651)
Make the script editor background white.

I tried everything I could think of with the transperency, wanna shed some light on it and I'll fix it up =o?

MysticalDragon 10-02-2006 01:24 AM

Great NPC A+++!

Skrobo2 10-02-2006 09:20 AM

Quote:

Originally Posted by KuJi (Post 1224655)
I tried everything I could think of with the transperency, wanna shed some light on it and I'll fix it up =o?

I don't know a whole lot about gui windows, but I think you'd need to edit that image for the window borders and such.

KuJi 10-02-2006 10:15 AM

It'd really be a lot better if I don't need to repost on revisions.. can you put a lil mod to allow forever-edit or something.

New Update: V 1.1

PHP Code:

// NPC Made by KuJi - V1.1
//#CLIENTSIDE
function onCreated()
{
  
requesttext("clientrc"1);
  
  new 
GuiMLTextEditProfile(TextEditorProfile)
  {
    
fontType        "Courier";
    
fontSize        10;
    
cursorColor     "0 0 0";
    
fillColorHL     "255 255 0";
    
fontColor       "0 0 0";
    
fontColorHL     "192 0 0"// control words like if, else etc.
    
fontColorSEL    "0 96 0"// identifiers
    
fontColorLink   "0 0 192"// strings
    
fontColorLinkHL "0 0 255"// numbers
  
}
  
  
onShowGUI();
}

function 
onShowGUI()

  if (
NC_Window != NULL)
  {
    
NC_Window.destroy();
  }
  
  new 
GuiWindowCtrl(NC_Window)
  {
    
height               460;
    
profile              GuiBlueWindowProfile;
    
text                 "NC Control (V1.0 by KuJi) ";
    
width                577;
    
x                    150;
    
y                    150;
    
    
visible              false;
    
    new 
GuiTabCtrl(NC_Tab)
    {
      
profile "GuiBlueTabProfile";
      
extent = {38025};
      
position = {18335};
      
      
horizSizing "width";
      
clearrows();
    }
    
    new 
GuiScrollCtrl(NC_Frame1)
    {
      
profile        GuiBlueScrollProfile;
      
extent         = {175431};
      
position       = {623};
      
      
hScrollBar     "dynamic";
      
vScrollBar     "dynamic";
      
vertSizing     "height";
      
      
useownprofile  true;
      
profile.opaque false;
      
      new 
GuiTreeViewCtrl(NC_Tree)
      {
        
profile GuiBlueTreeViewProfile;
        
0;
        
fitparentwidth true;
       
        
clearnodes();
        
addnodebypath("Classes""/");
        
addnodebypath("NPCS""/");
        
addnodebypath("Weapons""/");
      }
    }
    
    new 
GuiScrollCtrl(NC_Frame2)
    {
      
profile        GuiBlueScrollProfile;
      
extent         = {388355};
      
position       = {18260};
      
      
hScrollBar     "dynamic";
      
vScrollBar     "dynamic";
      
horizSizing    "width";
      
vertSizing     "height";
      
      
useownprofile  true;
      
profile.opaque false;
    }
    
    new 
GuiButtonCtrl(NC_Close)
    {
      
profile     GuiBlueButtonProfile;
      
extent      = {6525};
      
position    = {360423};
      
      
horizSizing "left";
      
vertSizing  "top";
      
text        "Close";
      
      
thiso.catchevent(this.name"onAction""onActionButton");
    }
    
    
    new 
GuiButtonCtrl(NC_Reload)
    {
      
profile     GuiBlueButtonProfile;
      
extent      = {6525};
      
position    = {430423};
      
      
horizSizing "left";
      
vertSizing  "top";
      
      
text        "Reload";
      
      
thiso.catchevent(this.name"onAction""onActionButton");
    }
    
    new 
GuiButtonCtrl(NC_Save)
    {
      
profile     GuiBlueButtonProfile;
      
extent      = {6525};
      
position    = {500423};
      
      
horizSizing "left";
      
vertSizing  "top";
      
      
text        "Save";
      
      
thiso.catchevent(this.name"onAction""onActionButton");
    }
  }
}

function 
NC_Tab.onSelect(tabidtabtexttabindex)
{
  for (
temp.var: NC_Tab.rows)
  {
    if (
temp.var.text == tabtext)
    {
      
temp.var.scriptedit.visible true;
    }
  }
}

function 
NC_Tab.onDeselect(tabidtabtexttabindex)
{
  for (
temp.var: NC_Tab.rows)
  {
    if (
temp.var.text == tabtext)
    {
      
temp.var.scriptedit.visible false;  
    }
  }
}


function 
NC_Tree.onDblClick(nodenodeslashpathnodedotpath)
{
  if (
nodeslashpath.starts("Classes/"))
  {
    
requesttext("class"nodeslashpath.substring(8));
  }
    elseif (
nodeslashpath.starts("Weapons/"))
  {
    
requesttext("weapon"nodeslashpath.substring(8));
  }
    elseif (
nodeslashpath.starts("NPCS/"))
  {
    
requesttext("npc"nodeslashpath.substring(5));
  }
}

function 
onReceiveText(texttypetextoptiontextlines)
{
  if (
texttype in {"classlist""npclist""weaponlist"})
  {
    
onAddScripts(textoptiontextlines);
  }
    elseif (
texttype in {"class""npc""weapon"})
  {
    
onViewScript(texttypetextoptiontextlines);
  }
}

function 
onAddScripts(temp.prefixtemp.textlines)
{
  if (
temp.prefix != NULL)
  {
    for (
temp.var: temp.textlines)
    {
      if (
temp.var != NULL)
      {
        
with (NC_Tree.addnodebypath(temp.prefix temp.var, "/"))
        {
          
image selectedimage 2;
        }
      }
    }
  }
}

function 
onViewScript(temp.texttypetemp.textoptiontemp.textlines)
{
  
temp.found NC_Tab.findtextid(temp.textoption);
  
  if (
temp.found >= 0)
  {
    
NC_Tab.setselectedbyid(temp.found);
    
    for (
temp.var: NC_Tab.rows)
    {
      if (
temp.var.id == temp.found)
      {
        
temp.var.scriptedit.setlines(temp.textlines);
      }
    }
    
    return 
true;
  }
    else
  {
    
    
with (NC_Frame2)
    {
      new 
GuiMLTextEditCtrl("NC_Edit_" temp.texttype "_" temp.textoption)
      {
        
profile            "TextEditorProfile";
        
extent             = {365225};
        
position           = {66};
        
        
horizSizing        "width";
        
vertSizing         "height";
        
        
syntaxHighlighting true;
        
wordwrap           false;
      
        
this.edittype      temp.texttype;
        
this.editoption    temp.textoption;

        
setlines(temp.textlines);
      }
    }
  
    
with (NC_Tab.addrow(this.tabid++, temp.textoption))
    {
      
this.scriptedit makevar("NC_Edit_" temp.texttype "_" temp.textoption);
      
NC_Tab.setselectedbyid(this.id);
    }
  } 
}

function 
onActionButton(obj)
{
  
temp.ncid NC_Tab.getselectedid();
  
  if (
temp.ncid <= -1)
  {
    return 
false;
  }
  
  switch (
obj.substring(3))
  {
    case 
"Close":
    {
      for (
temp.var: NC_Tab.rows)
      {
        if (
temp.var.id == temp.ncid)
        {
          
temp.var.scriptedit.destroy();
          
NC_Tab.removerowbyid(temp.ncid);
          
NC_Frame2.extent = {388355};
          
          break;
        }
      }
    
      break;
    }
    
    case 
"Reload":
    {
      for (
temp.var: NC_Tab.rows)
      {
        if (
temp.var.id == temp.ncid)
        {
          
requesttext(temp.var.scriptedit.edittypetemp.var.scriptedit.editoption);
          
          break;
        }
      }
      
      break;
    }
    
    case 
"Save":
    {
      for (
temp.var: NC_Tab.rows)
      {
        if (
temp.var.id == temp.ncid)
        {
          
sendtext(temp.var.scriptedit.edittypetemp.var.scriptedit.editoptiontemp.var.scriptedit.getLines());

          break;
        }
      }
    }
  }
}

function 
onKeyPressed(keycodekeychar)
{
  if (
keychar == '`')
  {
    
NC_Tree.clearnodes();
    
requesttext("classlist""Classes/");
    
requesttext("npclist""NPCS/");
    
requesttext("weaponlist""Weapons/");
    
    
NC_Window.visible = !NC_Window.visible;
  }


This fixes the colors for people who haven't used the texteditor yet.. it'll make them the colors I had in the pic. Sorry about that =o.

P.S. I did take those right out of texteditor =o

TrueMOD 12-23-2006 11:28 PM

hi i am a noob in gui scripting so i ask here
i added an delete button but dont know how i can
delete a file can anyone help me please

(i tried it with requestfiledeletion(str); but it doesnt work)

excaliber7388 12-23-2006 11:45 PM

Too bad Joey's banned :\

Yen 12-23-2006 11:45 PM

Needs more flag reading/editting, in my opinion.

Chompy 12-23-2006 11:52 PM

Quote:

Originally Posted by excaliber7388 (Post 1256608)
Too bad Joey's banned :\

He has an other account.

Skyld 12-24-2006 12:12 AM

Quote:

Originally Posted by Yen (Post 1256610)
Needs more flag reading/editting, in my opinion.

There is already support for editing NPC's flag lists; my Scripted RC already uses it.

excaliber7388 12-24-2006 12:16 AM

Quote:

Originally Posted by Skyld (Post 1256621)
There is already support for editing NPC's flag lists; my Scripted RC already uses it.

Sounds like fun *nudge*
;)


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

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