AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   does_function_exist(is_file_precached()) == 0 (https://forums.alliedmods.net/showthread.php?t=10593)

genesis 02-24-2005 03:56

does_function_exist(is_file_precached()) == 0
 
my server happens to precache many files, and I want to cut back the number of precaches per connect:

you have to precache a model before you use it but is there any way to do something like this:

1st Scenario

Code:
on error resume next entity_set_model(victim, "models/predator.mdl") next

or can I do something like this
I hear file_exists only checks the server is this true?
2nd Scenario
Code:
if file_exists("models/predator.mdl") {               entity_set_model(victim, "models/predator.mdl") }

3rd Scenario

Code:
is_file_precached("models/predator.mdl")         entity_set_model(victim, "models/predator.mdl")

^^ I doubt there is even a function for scenario 3, but that is a great function to have, I think we should get that function if it doesnt exist.

Johnny got his gun 02-24-2005 07:42

Your plugins precache the files. Comment out the plugins to have less stuff to precache.

Twilight Suzuka 02-24-2005 12:04

You could easily do all this.

When you go to precache something, check if its availible on the server, then precache it and set a global bool to true if it can be precached, or to false if it cant.

Then you can just check the bool if its precached or not, and make changes accordingly. No need for a whole new function.

genesis 02-24-2005 14:17

I think you're missing the point, basically I want to
entity_set_model(victim, "models/predator.mdl")
only if the CLIENT has the file, i think part of the problem is that

precache_model() both downloads file for client and loades it into memory on server/client.

it would be nice to be able to precache just load to memory if the file exists, and have a separate function to handling all downloading of files.

Johnny got his gun 02-24-2005 14:43

I totally misinterpreted.

No there's no such thing. But doing it like TZ suggested is of course possible. But serverside you cannot see what files a client has.

XxAvalanchexX 02-24-2005 15:09

If Small had associative arrays, an is_file_precached thing would be easily do-able, just catch PrecacheModel, PrecacheSound, and PrecacheGeneric with FakeMeta.

Yes it is true that file_exists is only for the server.

xeroblood 02-24-2005 18:12

You could essentially mimic Associative arrays using Parallel arrays..

TotalNoobScripter 02-24-2005 19:03

Quote:

Originally Posted by xeroblood
You could essentially mimic Associative arrays using Parallel arrays..

please dont confuse the noobs :D

v3x 02-24-2005 19:26

If you want to see if a function exists... I'd suggest you'd..
:rtfm:

Twilight Suzuka 02-24-2005 19:44

Not helpful vex.

Also, precaching something FORCES both the client and the server to have it, thus eliminating the problem.

Or you could use force_unmodified to make sure they have the same file.

But other then that, you cannot limit functionality depending on whether or not they have a file.


All times are GMT -4. The time now is 13:58.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.