PtokaX forum

Development Section => Your Developing Problems => Topic started by: ruler on 04 June, 2005, 13:47:38

Title: (LUA 5)How can i check permissions
Post by: ruler on 04 June, 2005, 13:47:38
Does anyone know what code is needed to get permissions of a user?
i used it so that if i changed a users profiles(permissions) then it not load up their zRight clicker with that command also disabling the command from the script without having to edit the script.
this is part of the old working script...

function zRightclicker(user,data)
bit = GetProfileName(GetItemByName(user.sName).iProfile)
   num,pro,indx = nil,nil,nil
      for line in io.lines("../Profiles.dat") do
      s,e,num,pro,indx=string.find(line,"(.+)%|(.+)%|(%d+)")
         if (bit == pro) then
         bit = indx
                  break end
      end
if string.sub(bit, 2,2) == "1" then
user:SendData("$UserCommand 1 3 InBuilt\\Drop User$<%[mynick]> !drop %[nick]||")
end
if string.sub(bit, 4,4) == "1" then
user:SendData("$UserCommand 1 2 InBuilt\\Ban User$<%[mynick]> !ban %[nick] %[line:Enter Reason]||")
user:SendData("$UserCommand 1 2 InBuilt\\Ban Nick$<%[mynick]> !nickban %[nick] ||")
user:SendData("$UserCommand 1 2 InBuilt\\UnBan User$<%[mynick]> !unban %[nick] ||")
end
end

im sure that there is an easier way of accessing/editing the permissions for example like the code...

GetProfileName(GetItemByName(user.sName).iProfile))

any ideas?

thanks guys and gals  :D


p.s.  the reason is because of the way the .dat files have been changed in the newer hubsoft version
Title:
Post by: jiten on 04 June, 2005, 14:42:29
With this one you'll get the Profile name of "user":
GetProfileName(GetItemByName(user.sName).iProfile)) Have a look at "Scripting-Interface.txt" shipped with the new PtokaX (in its main folder).

Best regards,

jiten
Title:
Post by: Dessamator on 04 June, 2005, 15:14:49
zright clicker already does that on its own at least the newest one :)
Title:
Post by: ruler on 04 June, 2005, 16:53:53
thanks for the reply but its not what i was trying to do.
ive read that text file with the ptokax hub so many times that i know it word for word now.
im trying to get the ' Permissions ' via command as i did in the script i posted just earlier. that was a working script from the .0.3.3.0 16.06 build version but with the new hubsoft there are no .dat files as they have now been changed to .xml files.
im just trying to find another way of getting the ' Permissions ' by using one or a combination of the profiles listed below...

GetProfiles()
GetProfileIdx(ProfileName)
GetProfileName(ProfileNumber)
GetUsersByProfile(ProfileName)

thanks
Title:
Post by: bastya_elvtars on 04 June, 2005, 17:34:22
My 2 cents:

If I were you, I would make a table. It would look like this:

userlevels={
[-1] = 1, -- Guest
[0] = 5, -- master
[1] = 4, -- op
[2] = 3, -- vip
[3] = 2 -- reg
} -- rights management

It is easy to determine that the more rights are assigned to a profile, the higher that nuber will become. So you can set another 'layer' of permission handling within the script. You can always retrieve the rightt with userlevels[user.iProfile] and you can assign a level to different things that need it. To retrieve the original PtokaX user right bits you have to parse the profiles config file.
Title:
Post by: ruler on 05 June, 2005, 09:17:28
Cheers im gonna give that a try.
with the old hubsoft it was easy to get the permissions but with the new ptokax hubsoft using .xml files makes it harder because of the way the .xml files are layed out.
it does seem strange though that you can access everything in the profiles file and not the permissions  :D  just wondering if it was left out on purpose or if PPK forgot about it when he was programming that part  8o  lol
anyway, thanks for the help guys
Title:
Post by: ruler on 05 June, 2005, 23:22:19
it was working like a charm in the old hubsoft cos when you get particular ops that get too carried away with their commands  8o  i could just goto the hub console and click on Advanced --->  Profile Manager and then untick the selected profile without having to edit the scripts  :]
also when a user enters the hub the scripts can check to see what profiles are enabled and what is not so that the zRight clicker knows what to load up for that user  ;)
anyway it would be nice to see that function back in a newer version of ptokax one day ' hint hint '  :D