Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Checking Files (https://forums.graalonline.com/forums/showthread.php?t=74731)

Crow 06-19-2007 08:06 PM

Checking Files
 
Is there a way to check if a certain file exists on the server before its downloaded by the player? With a script of course..

Chompy 06-19-2007 08:19 PM

Quote:

Originally Posted by Crow (Post 1319861)
Is there a way to check if a certain file exists on the server before its downloaded by the player? With a script of course..

hmm, downloaded as in see the image and poof have it in your graal directory or downloaded by gupd package?

Crow 06-19-2007 08:24 PM

Before its downloaded in any way. When its in the Graal folder, I can check it with ->

PHP Code:

filesize(string) 

Or something else. But I want to check if it exists and is downloadable from the server before the client tries to do that.

Chompy 06-19-2007 08:25 PM

I don't think it's possible to check that

Crow 06-19-2007 08:38 PM

Ok, lemme explain further :P I want to script a head changing system like on GK, something similar to "/head #". But I dont want to allow images which dont exist. How would I do that then? :/

Chompy 06-19-2007 08:40 PM

Quote:

Originally Posted by Crow (Post 1319873)
Ok, lemme explain further :P I want to script a head changing system like on GK, something similar to "/head #". But I dont want to allow images which dont exist. How would I do that then? :/

use fileexists? :)
Or was you hoping for something built-in or on the clientside?

godofwarares 06-19-2007 11:05 PM

Quote:

Originally Posted by Crow (Post 1319873)
Ok, lemme explain further :P I want to script a head changing system like on GK, something similar to "/head #". But I dont want to allow images which dont exist. How would I do that then? :/

Give (npcserver) read rights to your heads folder, and use this to check if it exists:

PHP Code:

function doesFileExist(file)
{
  
file.loadLines(file);

  if (
file.size() >= 0)
  {
    return 
true;
  } else {
    return 
false;
  }



Inverness 06-19-2007 11:38 PM

Last time I tried fileexists() it didn't work, but that was outside the levels folder, perhaps you will have more luck with a downloadable file.

Admins 06-20-2007 12:16 AM

The recommended function to use is
headexists(filename) - tells you if the image is downloadable and can be used as head for the player

Rapidwolve 06-20-2007 12:18 AM

I had the same problem for my system to check if an image didn't exist on an external webserver (like a website). I was shocked when I found out that Graal can't check that. x_X

zokemon 06-20-2007 12:37 AM

A clientside function for checking if a file can be downloaded would be nice...
I hate using getimgwidth() when showing an image and having it be wrong because the image isn't downloaded yet...

Crow 06-20-2007 03:22 PM

Thanks a ton all of you :)


All times are GMT +2. The time now is 04:21 AM.

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