hi, i try to create a Wanted HUD! looks like that:
https://www2.pic-upload.de/img/35944497/wanted.png
i need a code pls help
Use Functions/Player/Shared/getDarkRPVar
to get the information if a player is wanted, and when he is make a window like this on the picture with either textures or Category
my code:
addons/myaddon/lua/autorun/wantedhud
if Player:getDarkRPVar("wanted") then
surface.SetTextPos(580,876)
surface.SetTextColor(Color(255,0,0))
draw.DrawText("You are wanted!")
end
ERROR:
[ERROR] lua/client.lua:1: attempt to index global 'Player' (a function value)
1. unknown - lua/client.lua:1
change addons/myaddon/lua/autorun/wantedhud
to
addons/myaddon/lua/autorun/client/wantedhud
you put it in autorun itself, which will make it execute on client and server. for server the player does not exist, so you get the first error.
and the second i dont know because i dont know your whole code
couldn't you just do "addons/myaddon/lua/autorun/cl_wantedhud"?
you can do both. either make a client/server folder, or name them cl_ or sv_ but the folder option gives you a better overview of everything
@beaner can you contribute instead of disregarding everyone's comments? Would be more informative.
Your question is a yes or no question and I anwered with a no. Is that not enough? All files in lua/autorun will be run on both realms with no exceptions, adding "cl_" or "sv_" to the start of the file name doesn't do anything.
print(debug.getinfo(1).source, CLIENT, SERVER)
https://i.imgur.com/MFli4IA.png
kinda have to disagree with that, because just to be sure, and to answer his question right i went into gmod and tryd it out. Made a file that uses clientside only functions and put it in autorun so its executed client and serverside. worked on client, obviously, server gaved errors. renamed the file.lua to cl_file.lua and it worked. n oserverside error, only clientside run. so...yea
The only way you can run a file Shared without errors, is by doing a simple:
if SERVER then return end
Same thing server side.
then why did my test worked with cl_ and sv_?
That's a pretty neat trick thanks for sharing. I overlooked the fact that it was in the autorun folder @beaner
thanks to all the people who helped me
Code tags fix for Chrome
i have problems with Chrome
Custom CSS doesn't work for me neither
Doesnt work for me, too.
But formatting the code would be easy in notepad++ or sublime after copying..
maybe facepunch need something like codeshare so a "live" feature
Yeah, CSS code is still broken, i'm using Stylus right now for it.
Sorry, you need to Log In to post a reply to this thread.