15.03.2012, 10:25
(
Последний раз редактировалось JaTochNietDan; 16.03.2012 в 13:16.
)
What?
Permissions for sa-mp
Why?
To help create a unified developmental database for sa-mp
Does what?
Its permissions... I stole the idea from bukkit
Source:
Requirements:
Dini
Colors (below)
Functions for developers:
Donate
Click me!
How this works is there's the server owner who changed iPAdmin (iPermissions Admin) to 1 in their config file that's automatically created for them. Then they can access any plugin that uses that for default. Thats all a server owner needs to know
For developers or scripts like Lux admin, just use SetPerm(playerid, perm); on the player you wan't to have the perm. This automaticly sets the perm to true, GetPerm returns true or false based on if the person has that perm. In the event of a error, both of these will return 0. RemovePerm(playerid, perm) just removes the perm.
Edit:
I forgot to mention /rip reloads the permissions and can be slow on highly active servers. Im going to write a dini wrapper for a better ini processor for speed and efficiency.
I'm continuing to add functions for developers to take advantage of. If you would like one tell me or create one if you understand how. Enjoy!
Permissions for sa-mp
Why?
To help create a unified developmental database for sa-mp
Does what?
Its permissions... I stole the idea from bukkit
Source:
Код:
#include <a_samp> #include <dini> #include <colors> #undef MAX_PLAYERS #define MAX_PLAYERS 50 #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 new iPAdmin[MAX_PLAYERS]; public OnFilterScriptInit() { print("iPermissions v0.1 by iToast loaded!"); return 1; } public OnFilterScriptExit() { print("iPermissions v0.1 by iToast Un-loaded!"); return 1; } public OnPlayerConnect(playerid) { new file[128], name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "ipermissions\%s.ini", name); if(!dini_Exists(file)) { dini_Create(file); dini_BoolSet(file, "iPAdmin", 0); }else{ iPAdmin[playerid] = dini_Bool(file, "iPAdmin"); } return 1; } public OnPlayerDisconnect(playerid, reason) { iPAdmin[playerid] = 0; return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(rip, 3, cmdtext); return false; } dcmd_rip(playerid, params[]) { #pragma unused params if(iPAdmin[playerid] == 1) { new file[128], name[MAX_PLAYER_NAME]; for(new i=0;i<MAX_PLAYERS;i++) { GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "ipermissions\%s.ini", name); iPAdmin[i] = dini_Bool(file, "iPAdmin"); SendClientMessage(playerid, COLOR_GREEN, "iPermissions reloaded!"); } }else{ SendClientMessage(playerid, COLOR_RED, "You do not have permission to use this command!"); } return 1; }
Dini
Colors (below)
Код:
#define COLOR_GRAD1 0xB4B5B7FF #define COLOR_GRAD2 0xBFC0C2FF #define COLOR_GRAD3 0xCBCCCEFF #define COLOR_GRAD4 0xD8D8D8FF #define COLOR_GRAD5 0xE3E3E3FF #define COLOR_GRAD6 0xF0F0F0FF #define COLOR_GREY 0xAFAFAFAA #define COLOR_GREEN 0x33AA33AA #define COLOR_RED 0xAA3333AA #define COLOR_YELLOW 0xFFFF00AA #define COLOR_WHITE 0xFFFFFFAA #define COLOR_FADE1 0xE6E6E6E6 #define COLOR_FADE2 0xC8C8C8C8 #define COLOR_FADE3 0xAAAAAAAA #define COLOR_FADE4 0x8C8C8C8C #define COLOR_FADE5 0x6E6E6E6E #define COLOR_PURPLE 0xC2A2DAAA #define COLOR_DARKBLUE 0x2641FEAA #define COLOR_ALLDEPT 0xFF8282AA
Код:
HasPerm(playerid, perm) { new name[MAX_PLAYER_NAME], file[128]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "ipermissions\%s.ini", name); if(dini_Exists(file)) { if(dini_IsSet(perm)) { return 1; }else{ return 0; } }else{ return 0; } } SetPerm(playerid, perm) { new name[MAX_PLAYER_NAME], file[128]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "ipermissions\%s.ini", name); if(dini_Exists(file)) { dini_BoolSet(file, perm, 1); return 1; }else{ return 0; } } RemovePerm(playerid, perm) { new name[MAX_PLAYER_NAME], file[128]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "ipermissions\%s.ini", name); if(dini_Exists(file)) { if(dini_IsSet(file, perm)) { dini_Unset(file, perm); } return 1; }else{ return 0; } } SetStringPerm(playerid, perm, value) { new name[MAX_PLAYER_NAME], file[128]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "ipermissions\%s.ini", name); if(dini_Exists(file)) { dini_Set(file, perm, value); return 1; }else{ return 0; } } RemoveStringPerm(playerid, perm) { new name[MAX_PLAYER_NAME], file[128]; GetPlayerName(playerid, name, sizeof(name)); format(file, sizeof(file), "ipermissions\%s.ini", name); if(dini_Exists(file)) { if(dini_IsSet(file, perm)) { dini_Unset(file, perm); } return 1; }else{ return 0; } }
Click me!
How this works is there's the server owner who changed iPAdmin (iPermissions Admin) to 1 in their config file that's automatically created for them. Then they can access any plugin that uses that for default. Thats all a server owner needs to know
For developers or scripts like Lux admin, just use SetPerm(playerid, perm); on the player you wan't to have the perm. This automaticly sets the perm to true, GetPerm returns true or false based on if the person has that perm. In the event of a error, both of these will return 0. RemovePerm(playerid, perm) just removes the perm.
Edit:
I forgot to mention /rip reloads the permissions and can be slow on highly active servers. Im going to write a dini wrapper for a better ini processor for speed and efficiency.
I'm continuing to add functions for developers to take advantage of. If you would like one tell me or create one if you understand how. Enjoy!