General > Developers Corner
Ulib Name enforcer. Cant seem to fix.
thetomm2010:
So this is for and older version of Ulib forcing people to have the same name as when they first join the server. Not to sure what the "pluginEnabled" is suppose to be now and kinda just on my last limb. So any help would be great, I'm sure other people would like this too.
--- Code: ---i f ULib.pluginEnabled() then
ULib.addon = ULib.addon or {}
local usernames = {}
ULib.addon.forcename = function (iUserid, sNewname, sOldname)
if not _PlayerInfo (iUserid, "connected") then
return false, "User is not connected"
end
local login, name = ULib.getSteamLogin (iUserid), _PlayerInfo (iUserid, "name")
if not usernames[login] then
usernames[login] = name
elseif sNewname ~= usernames[login] then
_PrintMessage (iUserid, HUD_PRINTTALK, "The server forced you to keep your name.")
AddTimer (0.1, 1, ULib.cexec, iUserid, "name " .. usernames[login])
end
return true
end
HookEvent ("eventPlayerInitialSpawn", ULib.addon.forcename)
else
_Msg ("Plugin is not enabled\n")
end
--- End code ---
here is the error
--- Quote ---[ERROR] addons/ulib/lua/ulib/modules/nameforcer.lua:1: attempt to call field 'pluginEnabled' (a nil value)
1. unknown - addons/ulib/lua/ulib/modules/nameforcer.lua:1
2. include - [C]:-1
3. unknown - addons/ulib/lua/ulib/cl_init.lua:23
4. include - [C]:-1
5. unknown - addons/ulib/lua/autorun/ulib_init.lua:5
--- End quote ---
Decicus:
I believe it's pretty easy to fix this.
The first line, where it's supposed to say "if", it's saying "i f", there's a space between the 'I' and the 'F' that shouldn't be there, just remove that and save, and it should in theory work (correct me if I'm wrong, Lua pro's).
thetomm2010:
Not sure why the space is there but that is not suppose to be there. In the script that I use the i f is if. So unfortuately that is not it but thank you. I'm sure someone will know whats wrong tho hopefully lol.
JamminR:
This isn't for an older version of ULib.
This isn't for an older version of Gmod.
This is for an ancient version of both.
Just take the idea of it and re-write it.
Good Lua first learn project.
thetomm2010:
Lmao alright thanks
Navigation
[0] Message Index
[#] Next page
Go to full version