Как выдать группу админу, через плагин на примере.
Код
public Action:LoginStart(client, args)
{
decl String:Login[MAX_NAME_LENGTH], String:password[PLATFORM_MAX_PATH];
GetCmdArg(1, Login, MAX_NAME_LENGTH);
GetCmdArg(2, password, PLATFORM_MAX_PATH);
SHA1String(password, password);
decl String:s_Query[MAX_NAME_LENGTH+PLATFORM_MAX_PATH+150];
FormatEx(s_Query, sizeof(s_Query), "SELECT srv_group FROM %s_admins WHERE user='%s' AND password='%s' AND expired>'UNIX_TIMESTAMP()'", DatabasePrefix, Login, password);
SQL_TQuery(Database, GetAdmin, s_Query, client, DBPrio_High);
return Plugin_Handled;
}
public GetAdmin(Handle:h_Owner, Handle:h_Query, const String:s_Error[], any:i_Client)
{
decl String:s_Grub[PLATFORM_MAX_PATH];
if (h_Query != INVALID_HANDLE && SQL_GetRowCount(h_Query) > 0)
{
while (SQL_FetchRow(h_Query))
{
SQL_FetchString(h_Query, 1, s_Grub, sizeof(s_Grub));
}
CloseHandle(h_Query);
new AdminId:id = CreateAdmin();
//Тут выдать группу с названием из s_Grub
SetUserAdmin(i_Client, id, true);
}
else
PrintToChat(i_Client, "Query failed: %s", s_Error);
}