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

add user flag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
szogun
Senior Member
Join Date: Apr 2016
Old 05-14-2017 , 10:29   add user flag
Reply With Quote #1

I have a small problem, namely what time a plugin adds its log error

PHP Code:
L 05/14/2017 03:36:18SourceMod error session started
L 05
/14/2017 03:36:18Info (map "de_mirage") (file "errors_20170514.log")
L 05/14/2017 03:36:18: [SMException reportedClient index -1 is invalid
L 05
/14/2017 03:36:18: [SMBlamingLosowyVip.smx
L 05
/14/2017 03:36:18: [SMCall stack trace:
L 05/14/2017 03:36:18: [SM]   [0AddUserFlags
L 05
/14/2017 03:36:18: [SM]   [1Line 47LosowyVip.sp::Event_RoundStart
L 05
/14/2017 08:18:41Error log file session closed
PHP Code:
#include <sourcemod>

public Plugin:myinfo =
{
    
name "LosowyVip",
    
author "Hanys",
    
description "Plugin losuje losowa osobe ktora otrzyma flage",
    
version "1.0",
    
url "http://hanys.dispark.pl"
}

new 
Handle:Random_round;
new 
Handle:Random_player;
new 
Rounds 0;

public 
OnPluginStart()
{
    
CreateConVar("sm_randomvip""1.0""Losowy VIP"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
    
Random_round CreateConVar("random_round""0""W ktorej rundzie ma losowac losowego vip'a (Uwaga: Rozgrzewka liczona jest jako 1 runda!) 0:Losowy vip wylaczony"FCVAR_NOTIFY);
    
Random_player CreateConVar("random_player""0""Ile osob wymaganych jest do wylosowania losowego vip'a"FCVAR_NOTIFY);
    
    
    
AutoExecConfig(true"sm_vip_random");
    
    
HookEvent("round_start"Event_RoundStart);
    
HookEvent("cs_win_panel_match"RestartRound);
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
winner GetRandomPlayer(3);
    new 
g_random_round GetConVarInt(Random_round);
    
    
Rounds Rounds 1;
    
    if (
Rounds == g_random_round)
    
    {
        if (
winner == -1)
        
        {
            
            
PrintToChatAll("\x04[\x04VIP\x01] \x06Na serwerze znajduje sie za malo graczy do wylosowania losowego VIP'a\x01");
            
        }
        
AddUserFlags(winnerAdmin_Custom1);
        
        
PrintToChatAll("[\x04VIP\x01] \x06Trwa losowanie VIP'a...\x01");
        
PrintToChatAll("[\x04VIP\x01] \x06-----\x01");
        
PrintToChatAll("[\x04VIP\x01] \x06-----\x01");
        
PrintToChatAll("[\x04VIP\x01] \x06-----\x01");
        
PrintToChatAll("[\x04VIP\x01] \x06Losowym VIP'em zostaje \x02%N\x01\x06! Gratulujemy!\x01"winner);
        
    }
}

public 
Action:RestartRound(Handle:event, const String:name[], bool:dontBroadcast)
{
    
Rounds 0;
}

stock GetRandomPlayer(team)
{
    
    new 
g_random_player GetConVarInt(Random_player);
    new 
clients[MaxClients 1], clientCount;
    
    for (new 
1<= MaxClientsi++)
    if (
IsClientInGame(i))
    
clients[clientCount++] = i;
    
    if (
clientCount <= g_random_player)
    return -
1;
    
    return 
clients[GetRandomInt(0clientCount 1)];

szogun is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 05-14-2017 , 19:29   Re: add user flag
Reply With Quote #2

Do you mean the timestamp, because it's right there. If your asking why your getting -1 error, you should probably indent your code/enclose with brackets in GetRandomPlayer() otherwise its going to return -1 all the time.
__________________

Last edited by Chaosxk; 05-14-2017 at 19:30.
Chaosxk is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-16-2017 , 04:43   Re: add user flag
Reply With Quote #3

If you're adding flags to users, it's recommended that you do it in a OnClientPostAdminFilter block as that's why it exists.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
BassPower
Member
Join Date: Mar 2011
Location: Lithuania
Old 05-16-2017 , 14:21   Re: add user flag
Reply With Quote #4

hi all - how setuserflagbits more flags

SetUserFlagBits(client, FlagToBit(Admin_Reservation));
SetUserFlagBits(client, FlagToBit(Admin_Custom1));

and check on csgo adminmenu - only Admin_Custom1 add no reservation i try

SetUserFlagBits(client, FlagToBit(Admin_Reservation & Admin_Custom1));
and
SetUserFlagBits(client, FlagToBit(Admin_Reservation || Admin_Custom1));

any help?

Last edited by BassPower; 05-16-2017 at 14:21.
BassPower is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 05-16-2017 , 15:14   Re: add user flag
Reply With Quote #5

PHP Code:
SetUserFlagBits(clientGetUserFlagBits(client)|ADMFLAG_RESERVATION|ADMFLAG_CUSTOM1); 
__________________
Chaosxk 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 15:05.


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