How to use resource.addfile

Where do I call this command? It’s lua, but how do I execute this, and for everymap unlike .res files.
thx


resource.AddFile("materials/vgui/xhair.vmt")

That’s an example from a crosshair we use. Adjust the path accordingly. Make a file called resources.lua, or whatever you want to name it, put it in autorun. Actually, anywhere should work, but I usually place them in autorun.

where is the autorun folder?
nm
orangebox\garrysmod\lua\autorun

[editline]2nd January 2012[/editline]

Hmm why didn’t it work?

I have a stalker player model addon


resource.AddFile("addons\JokerStalker\materials\models\stalkerexo\act_st_exoskel_tank_ex_dolg.vmt")  
resource.AddFile("addons\JokerStalker\materials\models\stalkerexo\act_st_exoskel_tank_ex_dolg.vtf")
resource.AddFile("addons\JokerStalker\materials\models\stalkerexo\act_st_exoskel_tank_specnaz.vmt") 
resource.AddFile("addons\JokerStalker\materials\models\stalkerexo\act_st_exoskel_tank_specnaz.vtf") 
resource.AddFile("addons\JokerStalker\materials\models\stalkerexo\act_st_exoskel_tank_svoboda.vmt") 
resource.AddFile("addons\JokerStalker\materials\models\stalkerexo\act_st_exoskel_tank_svoboda.vtf") 
resource.AddFile("addons\JokerStalker\materials\models\stalkerexo\act_st_exoskelet_loner_tank.vmt") 
resource.AddFile("addons\JokerStalker\materials\models\stalkerexo\act_st_exoskelet_loner_tank.vtf") 
resource.AddFile("addons\JokerStalker\models\stalker_exo\exo_specna.dx80.vtx")
resource.AddFile("addons\JokerStalker\models\stalker_exo\exo_specna.dx90.vtx") 
resource.AddFile("addons\JokerStalker\models\stalker_exo\exo_specna.mdl")  
resource.AddFile("addons\JokerStalker\models\stalker_exo\exo_specna.phy")  
resource.AddFile("addons\JokerStalker\models\stalker_exo\exo_specna.sw.vtx")  
resource.AddFile("addons\JokerStalker\models\stalker_exo\exo_specna.vvd")  
resource.AddFile("addons\JokerStalker\models\stalker_exo\exosk_dolg.dx80.vtx")  
resource.AddFile("addons\JokerStalker\models\stalker_exo\exosk_dolg.dx90.vtx")  
resource.AddFile("addons\JokerStalker\models\stalker_exo\exosk_dolg.mdl")  
resource.AddFile("addons\JokerStalker\models\stalker_exo\exosk_dolg.phy")  
resource.AddFile("addons\JokerStalker\models\stalker_exo\exosk_dolg.sw.vtx")  
resource.AddFile("addons\JokerStalker\models\stalker_exo\exosk_dolg.vvd") 
resource.AddFile("addons\JokerStalker\materials\models\merk\act_glass_universal.vmt")  
resource.AddFile("addons\JokerStalker\materials\models\merk\act_glass_universal.vtf")  
resource.AddFile("addons\JokerStalker\materials\models\merk\act_stalker_specnaz.vmt")  
resource.AddFile("addons\JokerStalker\materials\models\merk\act_stalker_specnaz.vtf")  
resource.AddFile("addons\JokerStalker\models\Stalker_AntiGas_Killer.dx80.vtx")  
resource.AddFile("addons\JokerStalker\models\Stalker_AntiGas_Killer.dx90.vtx")  
resource.AddFile("addons\JokerStalker\models\stalker_antigas_killer.mdl")  
resource.AddFile("addons\JokerStalker\models\Stalker_AntiGas_Killer.phy")  
resource.AddFile("addons\JokerStalker\models\Stalker_AntiGas_Killer.sw.vtx")  
resource.AddFile("addons\JokerStalker\models\stalker_antigas_killer.vvd")  
resource.AddFile("addons\JokerStalker\models\Stalker_AntiGas_Killer_de.dx80.vtx")  
resource.AddFile("addons\JokerStalker\models\Stalker_AntiGas_Killer_de.dx90.vtx")

Nothing happens, all the same files are on the webserver for fastdl as well as well as the updated cache

I made a new file in the lua autorun folder called resources.lua

[editline]2nd January 2012[/editline]

Appparently not supposed to have addons\jokerstalker

So i changed it to this


resource.AddFile("materials\models\stalkerexo\act_st_exoskel_tank_ex_dolg.vmt")  
resource.AddFile("materials\models\stalkerexo\act_st_exoskel_tank_ex_dolg.vtf")
resource.AddFile("materials\models\stalkerexo\act_st_exoskel_tank_specnaz.vmt") 
resource.AddFile("materials\models\stalkerexo\act_st_exoskel_tank_specnaz.vtf") 
resource.AddFile("materials\models\stalkerexo\act_st_exoskel_tank_svoboda.vmt") 
resource.AddFile("materials\models\stalkerexo\act_st_exoskel_tank_svoboda.vtf") 
resource.AddFile("materials\models\stalkerexo\act_st_exoskelet_loner_tank.vmt") 
resource.AddFile("materials\models\stalkerexo\act_st_exoskelet_loner_tank.vtf") 
resource.AddFile("models\stalker_exo\exo_specna.dx80.vtx")
resource.AddFile("models\stalker_exo\exo_specna.dx90.vtx") 
resource.AddFile("models\stalker_exo\exo_specna.mdl")  
resource.AddFile("models\stalker_exo\exo_specna.phy")  
resource.AddFile("models\stalker_exo\exo_specna.sw.vtx")  
resource.AddFile("models\stalker_exo\exo_specna.vvd")  
resource.AddFile("models\stalker_exo\exosk_dolg.dx80.vtx")  
resource.AddFile("models\stalker_exo\exosk_dolg.dx90.vtx")  
resource.AddFile("models\stalker_exo\exosk_dolg.mdl")  
resource.AddFile("models\stalker_exo\exosk_dolg.phy")  
resource.AddFile("models\stalker_exo\exosk_dolg.sw.vtx")  
resource.AddFile("models\stalker_exo\exosk_dolg.vvd") 
resource.AddFile("materials\models\merk\act_glass_universal.vmt")  
resource.AddFile("materials\models\merk\act_glass_universal.vtf")  
resource.AddFile("materials\models\merk\act_stalker_specnaz.vmt")  
resource.AddFile("materials\models\merk\act_stalker_specnaz.vtf")  
resource.AddFile("models\Stalker_AntiGas_Killer.dx80.vtx")  
resource.AddFile("models\Stalker_AntiGas_Killer.dx90.vtx")  
resource.AddFile("models\stalker_antigas_killer.mdl")  
resource.AddFile("models\Stalker_AntiGas_Killer.phy")  
resource.AddFile("models\Stalker_AntiGas_Killer.sw.vtx")  
resource.AddFile("models\stalker_antigas_killer.vvd")  
resource.AddFile("models\Stalker_AntiGas_Killer_de.dx80.vtx")  
resource.AddFile("models\Stalker_AntiGas_Killer_de.dx90.vtx")

But still doesn’t work. I then went ahead and tried to move the actual content around out of the addons, didn’t work.

Even did this on the webserver, and updated the cache. What gives?

[editline]2nd January 2012[/editline]

Ok works now, not sure which fixed it

I removed the spaces after each line
I also removed all the resources.lua except in the autorun/server one

most importantly probably I used the \ instead of /

here is the final


resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_ex_dolg.vmt")
resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_ex_dolg.vtf")
resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_specnaz.vmt")
resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_specnaz.vtf")
resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_svoboda.vmt")
resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_svoboda.vtf")
resource.AddFile("materials/models/stalkerexo/act_st_exoskelet_loner_tank.vmt")
resource.AddFile("materials/models/stalkerexo/act_st_exoskelet_loner_tank.vtf")
resource.AddFile("models/stalker_exo/exo_specna.dx80.vtx")
resource.AddFile("models/stalker_exo/exo_specna.dx90.vtx")
resource.AddFile("models/stalker_exo/exo_specna.mdl")
resource.AddFile("models/stalker_exo/exo_specna.phy")
resource.AddFile("models/stalker_exo/exo_specna.sw.vtx")
resource.AddFile("models/stalker_exo/exo_specna.vvd")
resource.AddFile("models/stalker_exo/exosk_dolg.dx80.vtx")
resource.AddFile("models/stalker_exo/exosk_dolg.dx90.vtx")
resource.AddFile("models/stalker_exo/exosk_dolg.mdl")
resource.AddFile("models/stalker_exo/exosk_dolg.phy")
resource.AddFile("models/stalker_exo/exosk_dolg.sw.vtx")
resource.AddFile("models/stalker_exo/exosk_dolg.vvd")
resource.AddFile("materials/models/merk/act_glass_universal.vmt")
resource.AddFile("materials/models/merk/act_glass_universal.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz.vmt")
resource.AddFile("materials/models/merk/act_stalker_specnaz.vtf")
resource.AddFile("models/Stalker_AntiGas_Killer.dx80.vtx")
resource.AddFile("models/Stalker_AntiGas_Killer.dx90.vtx")
resource.AddFile("models/stalker_antigas_killer.mdl")
resource.AddFile("models/Stalker_AntiGas_Killer.phy")
resource.AddFile("models/Stalker_AntiGas_Killer.sw.vtx")
resource.AddFile("models/stalker_antigas_killer.vvd")
resource.AddFile("models/Stalker_AntiGas_Killer_de.dx80.vtx")
resource.AddFile("models/Stalker_AntiGas_Killer_de.dx90.vtx")

Some missing textures, i just went all out, wasting bandwidth and time, but it works


resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_ex_dolg.vmt")
resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_ex_dolg.vtf")
resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_specnaz.vmt")
resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_specnaz.vtf")
resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_svoboda.vmt")
resource.AddFile("materials/models/stalkerexo/act_st_exoskel_tank_svoboda.vtf")
resource.AddFile("materials/models/stalkerexo/act_st_exoskelet_loner_tank.vmt")
resource.AddFile("materials/models/stalkerexo/act_st_exoskelet_loner_tank.vtf")
resource.AddFile("models/stalker_exo/exo_specna.dx80.vtx")
resource.AddFile("models/stalker_exo/exo_specna.dx90.vtx")
resource.AddFile("models/stalker_exo/exo_specna.mdl")
resource.AddFile("models/stalker_exo/exo_specna.phy")
resource.AddFile("models/stalker_exo/exo_specna.sw.vtx")
resource.AddFile("models/stalker_exo/exo_specna.vvd")
resource.AddFile("models/stalker_exo/exosk_dolg.dx80.vtx")
resource.AddFile("models/stalker_exo/exosk_dolg.dx90.vtx")
resource.AddFile("models/stalker_exo/exosk_dolg.mdl")
resource.AddFile("models/stalker_exo/exosk_dolg.phy")
resource.AddFile("models/stalker_exo/exosk_dolg.sw.vtx")
resource.AddFile("models/stalker_exo/exosk_dolg.vvd")
resource.AddFile("materials/models/merk/act_glass_universal.vmt")
resource.AddFile("materials/models/merk/act_glass_universal.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz.vmt")
resource.AddFile("materials/models/merk/act_stalker_specnaz.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz_de_n.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz_fr_n.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz_mp_de.vmt")
resource.AddFile("materials/models/merk/act_stalker_specnaz_mp_de.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz_mp_fr.vmt")
resource.AddFile("materials/models/merk/act_stalker_specnaz_mp_fr.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz_mp_uk.vmt")
resource.AddFile("materials/models/merk/act_stalker_specnaz_mp_uk.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz_mp_us.vmt")
resource.AddFile("materials/models/merk/act_stalker_specnaz_mp_us.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz_n.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz_uk_n.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz_us_n.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz2.vmt")
resource.AddFile("materials/models/merk/act_stalker_specnaz2.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz2_n.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz3.vmt")
resource.AddFile("materials/models/merk/act_stalker_specnaz3.vtf")
resource.AddFile("materials/models/merk/act_stalker_specnaz3_n.vtf")
resource.AddFile("models/Stalker_AntiGas_Killer_us.dx80.vtx")
resource.AddFile("models/Stalker_AntiGas_Killer_us.dx90.vtx")
resource.AddFile("models/stalker_antigas_killer_us.mdl")
resource.AddFile("models/Stalker_AntiGas_Killer_us.sw.vtx")
resource.AddFile("models/stalker_antigas_killer_us.vvd")
resource.AddFile("models/Stalker_AntiGas_Killer_us.phy")
resource.AddFile("models/Stalker_AntiGas_Killer_uk.dx80.vtx")
resource.AddFile("models/Stalker_AntiGas_Killer_uk.dx90.vtx")
resource.AddFile("models/stalker_antigas_killer_uk.mdl")
resource.AddFile("models/Stalker_AntiGas_Killer_uk.sw.vtx")
resource.AddFile("models/stalker_antigas_killer_uk.vvd")
resource.AddFile("models/Stalker_AntiGas_Killer_uk.phy")
resource.AddFile("models/Stalker_AntiGas_Killer_fr.dx80.vtx")
resource.AddFile("models/Stalker_AntiGas_Killer_fr.dx90.vtx")
resource.AddFile("models/stalker_antigas_killer_fr.mdl")
resource.AddFile("models/Stalker_AntiGas_Killer_fr.sw.vtx")
resource.AddFile("models/stalker_antigas_killer_fr.vvd")
resource.AddFile("models/Stalker_AntiGas_Killer_fr.phy")
resource.AddFile("models/Stalker_AntiGas_Killer_de.dx80.vtx")
resource.AddFile("models/Stalker_AntiGas_Killer_de.dx90.vtx")
resource.AddFile("models/stalker_antigas_killer_de.mdl")
resource.AddFile("models/Stalker_AntiGas_Killer_de.sw.vtx")
resource.AddFile("models/stalker_antigas_killer_de.vvd")
resource.AddFile("models/Stalker_AntiGas_Killer_de.phy")
resource.AddFile("models/Stalker_AntiGas_Killer3.dx80.vtx")
resource.AddFile("models/Stalker_AntiGas_Killer3.dx90.vtx")
resource.AddFile("models/stalker_antigas_killer3.mdl")
resource.AddFile("models/Stalker_AntiGas_Killer3.sw.vtx")
resource.AddFile("models/stalker_antigas_killer3.vvd")
resource.AddFile("models/Stalker_AntiGas_Killer3.phy")
resource.AddFile("models/Stalker_AntiGas_Killer2.dx80.vtx")
resource.AddFile("models/Stalker_AntiGas_Killer2.dx90.vtx")
resource.AddFile("models/stalker_antigas_killer2.mdl")
resource.AddFile("models/Stalker_AntiGas_Killer2.sw.vtx")
resource.AddFile("models/stalker_antigas_killer2.vvd")
resource.AddFile("models/Stalker_AntiGas_Killer2.phy")
resource.AddFile("models/Stalker_AntiGas_Killer.dx80.vtx")
resource.AddFile("models/Stalker_AntiGas_Killer.dx90.vtx")
resource.AddFile("models/stalker_antigas_killer.mdl")
resource.AddFile("models/Stalker_AntiGas_Killer.sw.vtx")
resource.AddFile("models/stalker_antigas_killer.vvd")
resource.AddFile("models/Stalker_AntiGas_Killer.phy")


Something you might want to remember

resource.AddFile(“models/stalker_antigas_killer.mdl”)

Will include .dx80, dx90, vvd, sw, phy and

resource.AddFile(“materials/models/merk/act_glass_universal.vmt”)

Will auto include the .vtf file

is there anyway to do this without typing each individual file path?

[editline]15th May 2012[/editline]

like adding my whole addons folder or somthing?


(User was banned for this post ("Dumb bump" - Gran PC))