Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Alternative Updates (https://forums.graalonline.com/forums/showthread.php?t=66206)

MegaMasterX90875 05-24-2006 04:06 PM

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?

xAndrewx 05-24-2006 04:28 PM

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

ApothiX 05-25-2006 02:11 PM

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);

xAndrewx 05-25-2006 03:39 PM

Good point, I never thought of it like that.

ApothiX 05-26-2006 02:16 PM

If it's written like that, though, you can tell that it is pointless :P

MegaMasterX90875 06-16-2006 02:40 AM

Reason is, to prevent downloading times, which means less download-lag.

Loriel 06-16-2006 03:51 AM

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.


All times are GMT +2. The time now is 02:49 PM.

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