Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Loading the class folder (https://forums.graalonline.com/forums/showthread.php?t=134263381)

iBeatz 05-29-2011 04:35 PM

Loading the class folder
 
I've been trying all sorts of ways trying to load and list the classes folder, but I just can't get it. It won't even load the contents of the folder.

I've made a constant variabe CLASS_FOLDER, with the class folder specified as classes/*.txt, but it won't load them.
I know there is nothing wrong with the rest of my script, as everything else is functioning apart from this line.

PHP Code:

temp.cls.loadfolder(CLASS_FOLDER,false); 

Can anyone tell me why? Is there something different about the class folder than all the other folders that I should be aware of?

Skyld 05-29-2011 04:40 PM

Does the NPC-Server have read rights to that folder?

fowlplay4 05-29-2011 04:40 PM

It's scripts/* not classes.

DB-NPCS: npcs/*
Weapons: weapons/*

Folder Rights Example (NPC-Server will need at least r rights):

rw weapons/*.txt
rw scripts/*.txt
rw npcs/*.txt
-rw npcs/npclocalnpc*.txt (Hides putnpc2 npcs)

These are strictly NC Folders:

CLASSES/*
WEAPONS/*
NPCS/*

iBeatz 05-29-2011 04:44 PM

Thanks fowlplay. :oo:

iBeatz 05-29-2011 04:47 PM

Now that I've asked that question, I may as well ask this one..
How would you go about loading the contents of one of those script files?

fowlplay4 05-29-2011 05:03 PM

Quote:

Originally Posted by iBeatz (Post 1652007)
Now that I've asked that question, I may as well ask this one..
How would you go about loading the contents of one of those script files?

This can apply to nearly every kind of file on your server not just the text files in the scripts folder.

As Array of Lines:

PHP Code:

temp.folder "scripts/";
temp.filename "your_class.txt";
temp.lines.loadlines(temp.folder temp.filename);
for (
temp.linetemp.lines) {
  
// processes line by line


As String:

PHP Code:

temp.folder "scripts/";
temp.filename "your_class.txt";
temp.data.loadstring(temp.folder temp.filename);
for (
temp.0temp.temp.data.length(); temp.i++) {
  
// process each character
  
temp.temp.data[temp.i];



iBeatz 05-29-2011 05:49 PM

Everytime I use loadlines() or loadstring(), it just returns 0.

I'm triggering the server from the clientside, with the name of the script file being carried over from the serverside as the second parameter.
The first parameter defines if it's a weapon or a script.

PHP Code:

 if(params[0] == "LoadScript"){
  if(
params[1] == "weapon"){
   
temp.filename params[2];
   
temp.scr.loadlines("weapons/"@temp.filename@".txt");
   
findPlayer("Graal749838").chat temp.scr;
  }
 } 

This always returns 0 to my chat. I've even tried it with a full string, but still noting works.

cbk1994 05-29-2011 05:59 PM

What filename are you using? Keep in mind you need to escape it if it has special characters, and weapons are named weaponWeaponName.txt.

iBeatz 05-29-2011 11:40 PM

Ah. I forgot the weapon prefix for weapon scripts. I was using a substring. Thanks cbk.

iBeatz 05-30-2011 12:12 PM

Okay, now I really am at my wit's end with this...
Okay, I have a GuiTextList with all the weapon names listed without the weapon prefix, without the .txt and the special characters escaped.
So, I press a GuiButton to send the selected text to the serverside using triggerserver(), which is fine.
Say, for example, I selected "Personal/iBeatz/Test" in the GuiTextList:

PHP Code:

triggerserver("gui",name,"LoadScript","weapon",Category_List.getSelectedText()); 

Then it is called on the serverside like so:

PHP Code:

function onActionServerSide(){
 if(
params[0] == "LoadScript"){
  if(
params[1] == "weapon"){
   
temp.sname params[2];
   
temp.scr.loadlines("weapons/weapon"@temp.sname@".txt");
   
findPlayer("Graal749838").chat "weapons/weapon"@temp.sname@".txt";
  }
 }


I'm frustrated because temp.scr always ends up as 0, but my chat is always the string I want.
I have also tried this with a script file as well, and still nothing works.
This is so annoying... !pissed!

fowlplay4 05-30-2011 03:45 PM

It's because the forward slashes (and other special/unsafe characters) get encoded.

Personal/iBeatz/Test is actually stored as weaponPersonal%047iBeatz%047Test.txt in the weapons folder.

Testbed might not have the folder rights necessary to read the raw script files either.

iBeatz 05-30-2011 03:50 PM

Wow. Why does everything have to be so complicated...?
Thanks once again.


All times are GMT +2. The time now is 09:05 PM.

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