Ulysses
General => Developers Corner => Topic started by: strategos on November 20, 2011, 05:18:27 PM
-
I'm trying to, when ulx adduser(id)/removeuser(id) is run, to auto-add them to the co-responding FAdmin group when the command is successfully run.
The format for fadmin setaccess is: Fadmin setaccess "nick/steamid" "group"
The functions adduser, adduserid, removeuser, and removeuserid have been modified
It adds them to the ulx group but it returns this (something similar each time)
[addons\ulx\lua\ulx\modules\sh\user.lua:79] attempt to perform arithmetic on a string value
function ulx.adduser( calling_ply, target_ply, group_name )
group_name = group_name:lower()
local userInfo = ULib.ucl.authed[ target_ply:UniqueID() ]
local id = ULib.ucl.getUserRegisteredID( target_ply )
if not id then id = target_ply:SteamID() end
ULib.ucl.addUser( id, userInfo.allow, userInfo.deny, group_name )
calling_ply:ConCommand("fadmin", "setaccess " + id + group_name)
ulx.fancyLogAdmin( calling_ply, "#A added #T to group #s", target_ply, group_name )
end
local adduser = ulx.command( CATEGORY_NAME, "ulx adduser", ulx.adduser )
adduser:addParam{ type=ULib.cmds.PlayerArg }
adduser:addParam{ type=ULib.cmds.StringArg, completes=ulx.group_names_no_user, hint="group", error="invalid group \"%s\" specified", ULib.cmds.restrictToCompletes }
adduser:defaultAccess( ULib.ACCESS_SUPERADMIN )
adduser:help( "Add a user to specified group." )
function ulx.adduserid( calling_ply, id, group_name )
id = id:upper() -- Steam id needs to be upper
group_name = group_name:lower()
-- Check for valid and properly formatted ID
if not checkForValidId( calling_ply, id ) then return false end
-- Now add the fool!
ULib.ucl.addUser( id, allows, denies, group_name )
calling_ply:ConCommand("fadmin", "setaccess " + id + " " + group_name)
if ULib.ucl.users[ id ] and ULib.ucl.users[ id ].name then
ulx.fancyLogAdmin( calling_ply, "#A added #s to group #s", ULib.ucl.users[ id ].name, group_name )
else
ulx.fancyLogAdmin( calling_ply, "#A added userid #s to group #s", id, group_name )
end
end
local adduserid = ulx.command( CATEGORY_NAME, "ulx adduserid", ulx.adduserid )
adduserid:addParam{ type=ULib.cmds.StringArg, hint="SteamID, IP, or UniqueID" }
adduserid:addParam{ type=ULib.cmds.StringArg, completes=ulx.group_names_no_user, hint="group", error="invalid group \"%s\" specified", ULib.cmds.restrictToCompletes }
adduserid:defaultAccess( ULib.ACCESS_SUPERADMIN )
adduserid:help( "Add a user by ID to specified group." )
function ulx.removeuser( calling_ply, target_ply )
ULib.ucl.removeUser( target_ply:UniqueID() )
calling_ply:ConCommand("fadmin", "setaccess " + tostring(target_ply:SteamID()) + " user")
ulx.fancyLogAdmin( calling_ply, "#A removed all access rights from #T", target_ply )
end
local removeuser = ulx.command( CATEGORY_NAME, "ulx removeuser", ulx.removeuser )
removeuser:addParam{ type=ULib.cmds.PlayerArg }
removeuser:defaultAccess( ULib.ACCESS_SUPERADMIN )
removeuser:help( "Permanently removes a user's access." )
function ulx.removeuserid( calling_ply, id )
id = id:upper() -- Steam id needs to be upper
-- Check for valid and properly formatted ID
if not checkForValidId( calling_ply, id ) then return false end
if not ULib.ucl.authed[ id ] and not ULib.ucl.users[ id ] then
ULib.tsayError( calling_ply, "No player with id \"" .. id .. "\" exists in the ULib user list", true )
return false
end
local name = (ULib.ucl.authed[ id ] and ULib.ucl.authed[ id ].name) or (ULib.ucl.users[ id ] and ULib.ucl.users[ id ].name)
ULib.ucl.removeUser( id )
calling_ply:ConCommand("fadmin", "setaccess " + id + " user")
if name then
ulx.fancyLogAdmin( calling_ply, "#A removed all access rights from #s", name )
else
ulx.fancyLogAdmin( calling_ply, "#A removed all access rights from #s", id )
end
end
local removeuserid = ulx.command( CATEGORY_NAME, "ulx removeuserid", ulx.removeuserid )
removeuserid:addParam{ type=ULib.cmds.StringArg, hint="SteamID, IP, or UniqueID" }
removeuserid:defaultAccess( ULib.ACCESS_SUPERADMIN )
removeuserid:help( "Permanently removes a user's access by ID." )
-
The functions adduser, adduserid, removeuser, and removeuserid have been modified
Don't modify.
ULib has hooks for during and post command.
Use them instead, and make your own addon folder.
[addons\ulx\lua\ulx\modules\sh\user.lua:79] attempt to perform arithmetic on a string value
calling_ply:ConCommand("fadmin", "setaccess " + id + group_name)
calling_ply:ConCommand("fadmin", "setaccess " + id + " " + group_name)
calling_ply:ConCommand("fadmin", "setaccess " + tostring(target_ply:SteamID()) + " user")
calling_ply:ConCommand("fadmin", "setaccess " + id + " user")
"+" is a math statement.
I'm pretty sure I know what you're trying to do with +, but that's not how you do it in Lua. :)
I'm not going to give it away and will let you search a bit on your own.
EDIT = Regarding the hooks.
See ULibCommandCalled (http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibCommandCalled) or ULibPostTranslatedCommand (http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibPostTranslatedCommand)
That will allow you to monitor for any of the normal ULX commands, and run things in addition to them.
-
Ahh, that's harsh Jam. hah! .. I really hope that he can figure out what he needs to use instead of "+".. you know .. so that he can finish his script and get it up and running.
-
Too much coding in E2 :D
-
Ahh, that's harsh Jam. hah!
I know, I'm so mean.
Seriously though, I don't know how many times I learned something new from (Lua/Glua/insert any scripting language I know enough to be dangerous with here) while searching for a solution to something else.
A bit of searching, even through other ulx code examples, shouldn't take toooo long.
:)
-
Instead of doing that I'm just going to give overriding Fadmin to ulx usergroups a shot.
-
Strategos, you're going from a right track to something perhaps even more challenging.
The code examples you're showing should, with a bit of proper syntax, work.
-
I said the following to Strategos in steam chat. (Its only slightly edited so excuse me for any grammar and or spelling mistakes.)
So what you do is check with ULX what rank they are in ULX (Using Gamemode.PlayerInitialSpawn), check if they are in a certain file (the file will be edited by the lua).
If they are not it will rank them and add thier SteamID to that file and put what ever rank they are beside it so it will look like STEAM_0:0:8767896.Admin
Every time some one joins, it will check their rank and steamID,
if they are already in the list under the same rank it wont do any thing how ever if their rank has changed it will go in the file look for the line that their steam ID is at
and change the rank name beside it, afcorse it will rank them in FAdmin before doing that.
So that is my idea, on how you can intergrade it.
I the following commands will help you.
http://wiki.garrysmod.com/?title=Gamemode.PlayerInitialSpawn
http://wiki.garrysmod.com/?title=File.Write
http://wiki.garrysmod.com/?title=File.Append
http://wiki.garrysmod.com/?title=File.Read
Good Luck. (Don't worry I am thinking of making the script. :P)
Also a question, would Player.IsUserGroup return what group a person is in ULX, if the server is running ULX?
Also how would I turn this...
"superadmin"
{
"can_target" "!%officer, !%owner"
"team"
{
"color_green" "0"
"health" "200"
"color_red" "255"
"order" "4"
"index" "23"
"name" "Superadmins"
"color_blue" "0"
}
"allow"
{
"All of thier commands"
}
"inherit_from" "admin"
}
"user"
{
"can_target" "%user"
"team"
{
"color_red" "255"
"color_green" "212"
"order" "9"
"index" "28"
"name" "User"
"color_blue" "0"
}
"allow"
{
"All of thier commands"
}
}
"moderator"
{
"team"
{
"color_green" "129"
"color_red" "255"
"name" "Moderator"
"health" "101"
"order" "6"
"index" "25"
"maxHealth" "101"
"color_blue" "255"
}
"can_target" "!%officer,!%owner,!%admin,!%superadmin"
"allow"
{
"All of thier commands"
}
"inherit_from" "vip"
}
"admin"
{
"can_target" "!%superadmin,!%officer,!%owner"
"team"
{
"color_green" "255"
"health" "150"
"color_red" "0"
"order" "5"
"index" "24"
"name" "Admins"
"color_blue" "0"
}
"allow"
{
"All of thier commands"
"sbox_weapons" "access tag"
"weapons" "access tag"
}
"inherit_from" "moderator"
}
into this...
"superadmin"
"user"
"moderator"
"admin"
The above transformation, makes it easier to get a list of all the created ranks built in, and custom.
-
IsUserGroup is passed a string and returns true if the user belongs to that group you specify and false if they do not. This function is implemented by Garry.
GetUserGroup (http://ulyssesmod.net/docs/files/lua/ulib/shared/sh_ucl-lua.html#Player:GetUserGroup) is implemented by us and should have been included in default gmod, in my opinion.
To get a list of groups, just take a peek at ULib.ucl.groups. The information stored below ULib.ucl is what ULib uses for all access control. Feel free to read from these tables, but do not change any of them or you may get strange behavior. :)
-
I decided to kind of bump this, because it seems that more and more users are switching to RP, and better FAdmin compatibility never hurt any one.
I am going to start working on this gain as soon as I can.
-
I decided to kind of bump this, because it seems that more and more users are switching to RP, and better FAdmin compatibility never hurt any one.
I am going to start working on this gain as soon as I can.
Better off with just removing FAdmin.