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.