Raised This Month: $51 Target: $400
 12% 

Solved Giving the flag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
szogun
Senior Member
Join Date: Apr 2016
Old 12-24-2018 , 07:51   Giving the flag
Reply With Quote #1

Hey, I have a small problem to give the flag to the player through the plugin

PHP Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

#define FLAG ADMFLAG_CUSTOM6 // flaga, jeżeli chcesz dwie to dajesz np. ADMFLAG_RESERVATION|ADMFLAG_CUSTOM1

#define OD 24 // OD którego grudnia ma być za free vip
#define DO 26 // do którego

#define ADVERT_TIME 60.0 // musi być do liczba z . np. 60.0, 120.0, 125.5

#define IGNORE_ADMINS true // IGNOROWAĆ ADMINISTRATORÓW? (NADAWANIE VIPA)

bool g_bEnabled false;

int g_bMialVipa[MAXPLAYERS 1];

Handle g_hTimer;

public 
Plugin myinfo 
{
    
name "[Roberrt] VIP na święta"
    
author "Roberrt"
    
description "Nadaje darmowego VIPa i informuje o tym."
    
version "1.0"
    
url "https://pluginysm.pl"
};
public 
void OnMapStart()
{
    
g_hTimer CreateTimer(ADVERT_TIMETimer_Advert_TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
}
public 
void OnMapEnd()
{
    if (
g_hTimer != INVALID_HANDLE)
    {
        
KillTimer(g_hTimer);
        
g_hTimer INVALID_HANDLE;
    }
}
public 
void OnClientAuthorized(int client)
{
    
g_bEnabled false;
    
g_bMialVipa[client] = false;
    
    
char sDay[10];
    
char sMonth[10];
    
int iDay;
    
int iMonth;
    
    
FormatTime(sDaysizeof(sDay), "%d"GetTime());
    
FormatTime(sMonthsizeof(sMonth), "%m"GetTime());
    
    
iDay StringToInt(sDay);
    
iMonth StringToInt(sMonth);
    
    if (
iMonth == 12 && iDay >= OD && iDay <= DO)
    {
        
g_bEnabled true;
        
CreateTimer(0.5Timer_VerifyClientclient);
    }
}
public 
Action Timer_Advert(Handle timer)
{
    if (!
g_bEnabled && g_hTimer != INVALID_HANDLE)
    {
        
KillTimer(g_hTimer);
        
g_hTimer INVALID_HANDLE;
    }
    else
    {
        
PrintToChatAll(" \x02[Święty Mikołaj]\x06 HOŁ HOŁ HOŁ!");
        
PrintToChatAll(" \x02[Święty Mikołaj]\x06 Jako prezent pod choinkę otrzymujecie \x10VIPa\x02!");
        
PrintToChatAll(" \x02[Święty Mikołaj]\x10 VIP\x06 skończy się pod koniec dnia %i grudnia.", DO);
        
    }
}
public 
Action Timer_VerifyClient(Handle timerint client)
{
    if (
IsValidClient(clienttrue))
    {
        
int iClientFlags GetUserFlagBits(client);
        
        if (
iClientFlags ADMFLAG_RESERVATION || ((iClientFlags ADMFLAG_GENERIC || iClientFlags ADMFLAG_ROOT) && IGNORE_ADMINS))
        {
            
g_bMialVipa[client] = true;
        }
        else
        {
            
g_bMialVipa[client] = false;
            
SetUserFlagBits(clientGetUserFlagBits(client) & FLAG);
        }
    }
}
stock bool IsValidClient(int clientbool nobots true)
{
    if (
client <= || client MaxClients || !IsClientConnected(client) || (nobots && IsFakeClient(client)))
    {
        return 
false;
    }
    return 
IsClientInGame(client);


Last edited by szogun; 12-25-2018 at 05:53.
szogun is online now
Kellan123
AlliedModders Donor
Join Date: Aug 2012
Old 12-24-2018 , 08:39   Re: Giving the flag
Reply With Quote #2

PHP Code:
#include < sourcemod >

#pragma semicolon 1

#define VIP_FLAG ADMFLAG_CUSTOM6

public Plugin myinfo =
{
    
name "Give VIP to Normal Player",
    
author "Kellan123",
    
version "1.0"
};

public 
void OnClientPostAdminCheckint iClient )
{
    if( !( 
GetUserFlagBitsiClient ) & ADMFLAG_GENERIC ) )
    {
        
int iFlags GetUserFlagBitsiClient );
        
        if( !( 
iFlags VIP_FLAG ) ) SetUserFlagBitsiClientiFlags VIP_FLAG );
    }


Last edited by Kellan123; 12-24-2018 at 08:39.
Kellan123 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-24-2018 , 19:09   Re: Giving the flag
Reply With Quote #3

I haven't read all the code, but there is a callback explicitly for adding flags to a user: OnClientPostAdminFilter
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode