Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   File Deletion (https://forums.graalonline.com/forums/showthread.php?t=66078)

xXziroXx 05-17-2006 05:40 PM

File Deletion
 
How can I delete a file on RC with a script? The only alternative that I could find was:


NPC Code:
requestfiledeletion( "filepath/filename" )





But like Skyld said when I asked him; thats a function with the scripted Client RC.


Whatever, but can anyone tell me how its done?

Warcaptain 05-17-2006 06:52 PM

deletefile("path/to/file")

xXziroXx 05-18-2006 01:36 PM

Didnt work.

Warcaptain 05-19-2006 01:19 AM

Has to be serverside.

xXziroXx 05-19-2006 05:18 PM

Quote:

Originally Posted by Warcaptain
Has to be serverside.

Duh.


Heres what I tried (file and location are not the same for *security* reasons or whatever):

NPC Code:

function onActionServerside()
{
if (params[0] == "DeleteFile") {
echo( "wee"); //Confirms that it get this far
deletefile( "levels/folder/filename.txt" ); // Yes, im trying to delete a .txt
sendtorc("/refreshfilelist"); // Updating the folder
}
}


Warcaptain 05-20-2006 08:10 AM

Then something is wrong thats beyond what we can see here.

NPC Code:

deletefile(str) - returns boolean ¹


¹ Script Functions: NPC-Server

xXziroXx 05-21-2006 06:38 PM

I sent a message to Stefan, hopefully he´ll look into it and/or tell us whats wrong.

Warcaptain 05-21-2006 08:43 PM

I have used this before, and I just tested it on my NPC-Server and it works.

Perhaps something was done to my NPC-Server? I doubt it would be just mine though.. so maybe Stefan can help.

xXziroXx 05-21-2006 08:56 PM

Odd. Maybe something with the folder options? Doubt it though since its able to read info from the text files.

xXziroXx 05-23-2006 05:50 PM

Ok, lets show a more detailed explanation on what im trying to do then. First, the script!


Note: not the actuall script, but I tried this and the file wont get deleted.

NPC Code:

function onActionServerSide()
{
if (params[0] == "deletefile") {
echo( "Deleting file...");
deletefile( "levels/items/Weapons/phantombane.txt");
}
}
//#CLIENTSIDE
function onCreated()
{
triggeraction( 0, 0, "serverside", name, "deletefile");
}




Then, lets /find the file on RC!


PHP Code:

/find phantombane.txt

......

items/Weapons/phantombane.txtdownloadable45 byte2006-05-21 18:44:57 


Ok, next step: lets add the NPC to myself and check if it gets deleted!


PHP Code:

xXziroXx loaded attributes of player xXziroXx
xXziroXx set attributes of player xXziroXx
Deleting file
... 


Ah, now the file should be deleted, right? But.. its still in the folders! Lets check with /find..


PHP Code:

/find phantombane.txt

......

items/Weapons/phantombane.txtdownloadable45 byte2006-05-21 18:45:31 



So, does anyone have a clue what im doing wrong if anything?

Warcaptain 05-23-2006 05:57 PM

Only thing I can think of, is that you can't delete files in the levels folder.

I delete files regularly from my manadb/items/*.arc folder and it works fine.

-performs a deletion-

See!

xXziroXx 05-24-2006 08:29 PM

Ok, so I added myself rights for a new folder!

PHP Code:

items

And from there, I could delete the file I tried to delete.. but the problem is, now I cant use loadlines from the documents there since the folder isnt listed in server options.. and as far as I know, you can only add subfolders to leves/ in the folder options.

So if im wrong, and you can add other folders there, please tell me how to do.. if not, am I screwed when it comes to deleting a file?

ApothiX 05-25-2006 02:12 PM

The file doesn't have to be in the folder config for you to be able to use loadlines and such. Just specify the entire path to it.

xXziroXx 05-25-2006 08:24 PM

Ok, I got it to work when I moved the files to a folder thats not a sub-folder to levels/.

Warcaptain 05-25-2006 08:48 PM

Quote:

Originally Posted by xXziroXx
Ok, I got it to work when I moved the files to a folder thats not a sub-folder to levels/.


Yeah, just like I thought. :)

You use deletelevel() to delete things in the levels folder.. at least you can delete levels that way.

xXziroXx 05-25-2006 09:08 PM

I know. I tried using deletelevel() on other files aswell, didnt work though.

Admins 05-30-2006 12:27 AM

deletefile() is not allowed to delete files in the levels folder, for security reasons, since there is no system for script rights yet. deletelevel() can be used for deleting level files (.nw, .graal).

Yen 05-30-2006 09:58 PM

Couldn't we rename another type of file to a .nw or .graal using a script, then delete it?

Skyld 05-30-2006 10:55 PM

Quote:

Originally Posted by Yen
Couldn't we rename another type of file to a .nw or .graal using a script, then delete it?

Quote:

Originally Posted by Stefan
deletefile() is not allowed to delete files in the levels folder,

It seems to depend upon the directory, not the file extension. So, unless you could rename inside levels/, then it again wouldn't work.


All times are GMT +2. The time now is 08:18 PM.

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