Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-17-2006, 05:40 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
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?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #2  
Old 05-17-2006, 06:52 PM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
deletefile("path/to/file")
Reply With Quote
  #3  
Old 05-18-2006, 01:36 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Didnt work.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #4  
Old 05-19-2006, 01:19 AM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
Has to be serverside.
Reply With Quote
  #5  
Old 05-19-2006, 05:18 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
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
}
}

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #6  
Old 05-20-2006, 08:10 AM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
Then something is wrong thats beyond what we can see here.

NPC Code:

deletefile(str) - returns boolean ¹


¹ Script Functions: NPC-Server
Reply With Quote
  #7  
Old 05-21-2006, 06:38 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
I sent a message to Stefan, hopefully he´ll look into it and/or tell us whats wrong.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #8  
Old 05-21-2006, 08:43 PM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
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.
Reply With Quote
  #9  
Old 05-21-2006, 08:56 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Odd. Maybe something with the folder options? Doubt it though since its able to read info from the text files.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #10  
Old 05-23-2006, 05:50 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
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?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #11  
Old 05-23-2006, 05:57 PM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
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!
Reply With Quote
  #12  
Old 05-24-2006, 08:29 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
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?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #13  
Old 05-25-2006, 02:12 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #14  
Old 05-25-2006, 08:24 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Ok, I got it to work when I moved the files to a folder thats not a sub-folder to levels/.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #15  
Old 05-25-2006, 08:48 PM
Warcaptain Warcaptain is offline
Banned
Warcaptain's Avatar
Join Date: Jun 2001
Location: Virginia, USA
Posts: 2,086
Warcaptain is on a distinguished road
Send a message via ICQ to Warcaptain Send a message via AIM to Warcaptain Send a message via Yahoo to Warcaptain
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.
Reply With Quote
  #16  
Old 05-25-2006, 09:08 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
I know. I tried using deletelevel() on other files aswell, didnt work though.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #17  
Old 05-30-2006, 12:27 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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).
Reply With Quote
  #18  
Old 05-30-2006, 09:58 PM
Yen Yen is offline
Banned
Yen's Avatar
Join Date: Oct 2005
Location: Nova Scotia, Canada
Posts: 1,085
Yen is an unknown quantity at this point
Send a message via AIM to Yen Send a message via MSN to Yen
Couldn't we rename another type of file to a .nw or .graal using a script, then delete it?
Reply With Quote
  #19  
Old 05-30-2006, 10:55 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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.
__________________
Skyld
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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