habe die letzte Woche an einer Permission Include gearbeitet, die selbständig in sqllite abspeichert.
Mit Hilfe Dieser Include habe ich es nun auf meinen Server hinbekommen, dass ich jederzeit neue AdminGruppen erstellen und die Rechte der einzelnen Gruppen ändern kann.
Später sollen auch einzelne Spieler Permissions erhalten können.
Die Gruppen und Prmissions können in Gruppen eingeteilt und auch als Gruppen gehandelt werden:
Beispiel für einige Permissions:
CreatePermission("admin.main.aduty", "/aduty", "Gehe als Admin onduty");
CreatePermission("admin.kickban.kick", "/kick [ID/Name]", "Kicke den Spieler vom Server");
CreatePermission("admin.kickban.ban", "/ban [ID/Name]", "Banne den Spieler vom Server");
CreatePermission("admin.kickban.tban", "/tban [ID/Name] [Zeit]", "Banne den Spieler für eine festgelegte Zeit vom Server");
CreatePermission("admin.kickban.unban", "/unban [Name]", "Entbanne den Spieler mit dem Namen vom Server");
wie man sieht wurden hier die Permissions in Gruppen eingeteilt. dadurch ist es möglich mehrere Permissions auf einmal zu handeln in dem man beispielsweise admin.kickban.* oder admin.* nutzt.
Auch sieht man, dass direkt an die Permissions Befehle und Beschreibungen drangehangen können.
Mithilfe dieses Systems kann man direkt alle Commands für einen Spieler anzeigen lassen oder nur Commands ener Spezziellen Permission Gruppe:
ShowPlayerCommands(playerid,"Kick/Ban Help","admin.kickban.*");
sollen für eine Permission mehrere commands aufgelistet werden oder soll man eine Hilfe command angezeigt bekommen wenn man irgend eine Permission einer Permission Group hat, so kann man das mit Permissionlinks realisieren, hier ein Beispiel aus meinen DayZ Server:
// Mithilfe dieses Codes kann jemand mit spec rechten auch direkt specoff.
CreatePermission("admin.spec", "/spec [Name/ID]", "Beobachte den angegebenen Spieler.");
CreatePermissionLink("admin.specoff", "admin.spec", "/specoff", "Beende das Beobachten des Spielers.");
Hier mal ein Auszug aus der Dukomentation innerhalb der Include:
/*
native CreatePermission(name[45],cmd[30],Desc[128])
Registers an Permission, so that you can Use it for Commands and more. Use this in OnGamemodeInit
Params:
name: The Permissionname, the Name could get Permission Groups by deviding Groups and Name with an ".".
cmd: The Command the Permission is needed for. If there is no commad just leave Blank
desc: An description what the Command is used for. Is usefull if you use ShowCmdList(playerid,premgrp[])
Returns: 1 If Permission got Created and 0 If it wasn't Possbile to Create the Permission
*/
/*
native CreatePermissionLink(name[45],cmd[30],Desc[128])
Registers an Permission as Link, so that this Cmd is directly useable for an allready created Permission
Params:
name: The Permissionname, the Name could get Permission Groups by deviding Groups and Name with an ".".
linkname: The Permissionname, you want to link with if you want to check if the player has any Permission of an Group write like this: "admin.*"
cmd: The Command the Permission is needed for. If there is no commad just leave Blank
desc: An description what the Command is used for. Is usefull if you use ShowCmdList(playerid,premgrp[])
Returns: 1 If Permission got Created and 0 If it wasn't Possbile to Create the Permission
*/
/*
native HasPermission(playerid,const name[45])
Checks if an Player has an Permission
Params:
playerid: The playerid, you want to check the Permission for.
permission: The Premssionname you wants to check, if you want to check if the player has any Permission of an Group write like this: "admin.*"
Returns: 1 If user has the Permission and 0 if the User don't have the Permission.
*/
/*
native GivePermission(playerid,name[45])
Gives an Player an Permission with storing it. (For Admin Systems and more)
Params:
playerid: The playerid, you want to give the Permission.
permission: The Premssionname you wants to give to the Player, if you want to give the player all Permission of an Group write like this: "admin.*"
Returns: 0 if it wasn't possible to give the Permission and 1 if the Permission was given.
*/
/*
native GivePermissionEx(playerid,name[45])
Gives an Player an Permission without Saving the Data forever
Params:
playerid: The playerid, you want to give the Permission.
permission: The Premssionname you wants to give to the Player, if you want to give the player all Permission of an Group write like this: "admin.*"
Returns: 0 if it wasn't possible to give the Permission and 1 if the Permission was given.
*/
/*
native AddGroup(gname[60])
Creates an Group with storing it. (For Admin Systems and more)
Params:
gname: The GroupName the Group will get. Give an name like admin.Administrator or admin.ProjectLeader to let an Player only be in one admin. Group.
It's also Useable to use admin. or similar if you want to Use ShowGroups(playerid,gname[],Callback[])
ordernum: Used for sorting the Groups when loading
Returns: GroupId or -1 if not able to Create.
*/
/*
native RemoveGroup(groupid)
Deletes an Group with all Data forever
Params:
groupid: The Group you want to delete.
Returns: 1 if Group was deleted
*/
/*
native GiveGroupPermission(groupid,name[45])
Gives an Group an Permission with storing it. (For Admin Systems and more)
Params:
groupid: The groupid, you want to give the Permission. Get the groupid by using GetGroupId(groupname[])
name: The Premssionname you wants to give to the Player.
Returns: 0 if it wasn't possible to give the Permission and 1 if the Permission was given.
*/
/*
native RemoveGroupPermission(groupid,name[45])
Removes an Group an Permission with storing it. (For Admin Systems and more)
Params:
groupid: The groupid, you want to give the Permission. Get the groupid by using GetGroupId(groupname[])
permission: The Premssionname you wants to give to the Player.
Returns: 0 if it wasn't possible to give the Permission and 1 if the Permission was given.
*/
/*
native GetGroupId(groupname[60])
Get the GroupId of an GroupName
Params:
groupname: The Groupname you want to get the Permission for.
Returns: -1 if Group wasn't found, returns the Groupid if found
*/
/*
native GetGroupOrder(groupid)
Get the Ordernumber of an Group.
Params:
groupid: The Groupid you want to get the Ordernumber for. Get the groupid by using GetGroupId(groupname[])
Returns: -1 if Group wasn't found, returns the Ordernum if found
*/
/*
native ChangeGroupOrder(groupid,ordernum)
Change the Ordernumber of an Group.
Params:
groupid: The Groupid you want to change the Ordernumber for. Get the groupid by using GetGroupId(groupname[])
ordernum: The new Ordernumber.
Returns: 0 if Group wasn't found or 1 if sucsessfully changed
*/
/*
native GetGroupName(groupid,groupname[],length)
Get the GroupId of an GroupName
Params:
groupid: The Groupid you want to get the Name for.
groupname: The String the Name should be written in.
lenght: The length of the String. Use sizeof()
Returns: -1 if Group wasn't found, returns the Ordernum if found
*/
/*
native PutInGroup(playerid,groupid)
Put an player in a Group
Params:
playerid: The playerid, you want to put in the Group.
groupid: The groupid, you want to give the Player. Get the groupid by using GetGroupId(groupname[])
Returns: 1 if Player was put sucsessfully into the Group.
*/
/*
native RemoveFromGroup(playerid,groupid)
Removes an Player from an Group
Params:
playerid: The playerid, you want to remove from the Group.
groupid: The groupid, you want to remove the Player from. Get the groupid by using GetGroupId(groupname[])
Returns: 1 if Player was removed sucsessfully from the Group.
*/
/*
native GetPlayerGroup(playerid,groupname[60])
Get the Group of an player.
Params:
playerid: The playerid, you want to get the Group.
groupname: The name you want to search for an Group. Search for admin.* if you want to get the next admin. Group of the Player
Returns: -1 if Player has no group.
*/
/*
native IsInGroup(playerid,groupid)
Get the GroupId of an GroupName
Params:
playerid: The playerid, you want to check.
groupid: The groupid, you want to check if the player is in. Get the groupid by using GetGroupId(groupname[])
Returns: 1 if the player is in the Group.
*/
/*
native LoadPlayerPermission(playerid,auth[80])
Loads all permissions of an Player including Group Permissions and more. If authstring not exist the Input gets Created.
Can be used when Player Login.
Params:
playerid: The Playerid you want to load the data to.
auth: The string the Player gets identificated by (Leave Blank for PlayerName). Can be used for User-Sqlid of the Gamemode, the Name, a Password or other.
Returns: 1 if Player Permissions loaded.
*/
/*
native ShowPlayerPermissions(playerid,target)
Shows an Player all Permissions of an target as an Dialog.
Params:
playerid: The playerid that will get shown the Dialog
target: The playerid of the Player you wnat to get the Permissions.
Returns: 0 if one of the Player is'nt Connected.
*/
/*
native ShowPlayerCommands(playerid,cap[64]="Commands",const permission[45]="")
Shows an Player all Commands as an Dialog.
Params:
playerid: The playerid that will get all Commands and Descriptions
cap: The Caption shown in the Dialog
permission: The Permission you want to show the Command for. Leave Blank for all Permissions or use like amdin.* for all admin. Permissions.
Returns: 0 if the Player is'nt Connected.
*/
/*
native ShowPlayerGroups(playerid,cap[64]="Groups",const groupname[60]="",callback[60]="",bool:newgroup=false)
Shows an Player all Permissions of an target as an Dialog.
Params:
playerid: The playerid that will get all Groups listed
cap: The Caption shown in the Dialog
groupname: The Group you want to show. Leave Blank for all Groups or use like amdin.* for all admin. Groups.
callback: The Callback that will be called when User selects an Group, Callback will give parameters (playerid,groupname[60],groupid,bool:newgroup)
newgroup: If set to True at the End of the Dialog will be an List named (New Group) when clicking on it, player can put an new Groupname inside.
Returns: 0 if the Player is'nt Connected.
*/
/*
native ShowPlayerGroupPermission(playerid,groupid,cap[64]="Group-Permissions",const permission[60]="",callback[60]="",bool:allprem=false)
Shows an Player all Permissions of an target as an Dialog.
Params:
playerid: The playerid that will get all Group Permission Listed
groupid: The Group you want to get the Permissions from.
cap: The Caption shown in the Dialog
permission: The Permissions you want to show. Leave Blank for all Permissions or use like amdin.* for all admin. Permissions.
callback: The Callback that will be called when User selects an Group, Callback will give parameters (playerid,groupid,permission[45],bool:haspermission)
allprem: If set to True The Dialog will also show the Permissions the Group don't has in red.
Returns: 0 if the Player is'nt Connected.
*/
Ich würde gerne wissen, ob sowas auch für andere Scripter Interessant ist, die vl. sogar so wie ich generft davon sind beim hinzufügen eines neuen Admin rnaks oder ähnliches wiedermal alle Admincmds durchgehen zu müssen...
//Goldkiller: Premission, ernsthaft ? Es heißt permission .
Goldkiller: Danke dir dafür dass du mich auf diesen Groben fehler aufmerksam gemacht hast habe nun alles geändert.