Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-24-2006, 04:06 PM
MegaMasterX90875 MegaMasterX90875 is offline
Retired Graalian (2009)
MegaMasterX90875's Avatar
Join Date: Feb 2006
Location: North Carolina
Posts: 132
MegaMasterX90875 is on a distinguished road
Send a message via AIM to MegaMasterX90875
Alternative Updates

I'm working on a server and I've come up with an idea to keep from overwriting files (using GS2, I"VE FINALLY MIGRATED TO GS2!!)
This example uses the file test.txt in the levels folder.
Can't I use
NPC Code:
function onCreated&&Fileexists(levels/test.txt)
{
selectfilefordownload(levels/test.txt);
}



Not sure, but the idea checks the player's graal folder for the file before downloading it to the client. Also, should I put this Clientside?
__________________
Mess with the best, Die like the rest.




Last edited by MegaMasterX90875; 05-24-2006 at 04:07 PM.. Reason: Forgot to add something
Reply With Quote
  #2  
Old 05-24-2006, 04:28 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by MegaMasterX90875
I'm working on a server and I've come up with an idea to keep from overwriting files (using GS2, I"VE FINALLY MIGRATED TO GS2!!)
This example uses the file test.txt in the levels folder.
Can't I use
NPC Code:
function onCreated&&Fileexists(levels/test.txt)
{
selectfilefordownload(levels/test.txt);
}



Not sure, but the idea checks the player's graal folder for the file before downloading it to the client. Also, should I put this Clientside?
NPC Code:
function onCreated() {
temp.check = this.FindFile("levels/test.txt");
if (temp.check == false) {
selectfilefordownload("levels/test.txt");
}
}
function FindFile(filedir) {
if (Fileexists(filedir))
return true;
return false;
}


I think it'd work, not too sure. Never used selectfilefordownload etc. Anyhow, this is how I would probably do it...
And no, I don't think there is a way of doing it like you said

Last edited by xAndrewx; 05-24-2006 at 11:47 PM..
Reply With Quote
  #3  
Old 05-25-2006, 02:11 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by xAndrewx
NPC Code:

function FindFile(filedir) {
if (Fileexists(filedir))
return true;
return false;
}

Hm, what is the point in doing that? You're essentially just doing:

function FindFile(filedir) return fileexists(filedir);
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #4  
Old 05-25-2006, 03:39 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Good point, I never thought of it like that.
Reply With Quote
  #5  
Old 05-26-2006, 02:16 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
If it's written like that, though, you can tell that it is pointless :P
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #6  
Old 06-16-2006, 02:40 AM
MegaMasterX90875 MegaMasterX90875 is offline
Retired Graalian (2009)
MegaMasterX90875's Avatar
Join Date: Feb 2006
Location: North Carolina
Posts: 132
MegaMasterX90875 is on a distinguished road
Send a message via AIM to MegaMasterX90875
Reason is, to prevent downloading times, which means less download-lag.
__________________
Mess with the best, Die like the rest.



Reply With Quote
  #7  
Old 06-16-2006, 03:51 AM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by MegaMasterX90875
This example uses the file test.txt in the levels folder.
Can't I use
NPC Code:
function onCreated&&Fileexists(levels/test.txt)
{
selectfilefordownload(levels/test.txt);
}

The problem is that the "new event blocks" are not simply conditional clauses, with if-condition-action stuff, but actually functions that are automatically called when an event happens. onCreated is the name of the function that the engine will call, and not the name of the flag that will be set to true while the engine is calling the script. You are declaring a function and not doing flow-control.

You will need to (and should have in GS1, see KSI-GS) nest the conditional check within the event block. A simple example is, without redundant functions, a direct translation of your code:

NPC Code:

function onCreated() {
if (fileExists("levels/test.txt"))
selectFileForDownload("levels/test.txt");
}



Quote:
Also, should I put this Clientside?
Yes. The server cannot snoop around the client's files easily.

Edit: Oh, yeah. You should surround strings with quotation marks.
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:52 AM.


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