My scripts won't run (though they're in autorun/client). They run only when i maybe change something, it gives an error, and then i fix it, only then it's compiled in the game. Why?
"My shit doesn't work until I fix it what the fuck is happening"
You got it all wrong. My scripts won't run, I need to make any change in it for it to work. For example, i start my server, script isn't running, but when i create an error and fix it the script runs. It's like it doesn't know it's there until i make a change in it
Perhaps you could show us the code?
It sounds to me like you have some conditions that aren't true or perhaps missing hooks.
[QUOTE=Netheous;44959158]Perhaps you could show us the code?
It sounds to me like you have some conditions that aren't true or perhaps missing hooks.[/QUOTE]
The code works. The fact that if i delete the file and paste it again it WILL work.
I always get this for some reason. It's why I fail at making shops. The files with the custom functions dont load and when I open the shop, I cant buy it because itll return that TakePoints is a nil function. Would like a solution too please
[QUOTE=RedNinja;44959177]The code works. The fact that if i delete the file and paste it again it WILL work.[/QUOTE]
Working and erroring are two different things.
[QUOTE=Sm63;44959181]I always get this for some reason. It's why I fail at making shops. The files with the custom functions dont load and when I open the shop, I cant buy it because itll return that TakePoints is a nil function. Would like a solution too please[/QUOTE]
Load order. Use one file in autorun to load each file using include and AddCSLuaFile. Like this:
[code]
if SERVER then
AddCSLuaFile()
AddCSLuaFile( "sh_player_ext.lua" )
AddCSLuaFile( "store.lua" )
AddCSLuaFile( "weapons.lua" )
AddCSLuaFile( "scoreboard_colors.lua" )
AddCSLuaFile( "hooks.lua" )
AddCSLuaFile( "perks.lua" )
AddCSLuaFile( "vgui/menu.lua" )
// AddCSLuaFile() other clientsides and shareds
include( "store.lua" )
include( "rewards.lua" )
include( "sh_player_ext.lua" )
include( "weapons.lua" )
include( "scoreboard_colors.lua" )
include( "hooks.lua" )
include( "perks.lua" )
// include() other serversides and shareds
end
if CLIENT then
include( "store.lua" )
include( "sh_player_ext.lua" )
include( "weapons.lua" )
include( "scoreboard_colors.lua" )
include( "hooks.lua" )
include( "perks.lua" )
include( "vgui/menu.lua" )
// include() other clientsides and shareds
end
[/code]
The order in which you include() them matters.
Sounds like autorefresh triggers this. Try adding a timer before the function which isn't running.
[QUOTE=Mors Quaedam;44959298]Sounds like autorefresh triggers this. Try adding a timer before the function which isn't running.[/QUOTE]
What do you mean?
This may be the same issue I was having with loading order. Handsome Matt's suggested PostGamemodeLoaded hook. See if that will help.
[url]http://wiki.garrysmod.com/page/GM/PostGamemodeLoaded[/url]
[QUOTE=RedNinja;44959434]What do you mean?[/QUOTE]
Autorefreshing the lua makes the script work, so try adding a delay using timer.Simple() before the code is run.
Sorry, you need to Log In to post a reply to this thread.