AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [Help] 3 Things (https://forums.alliedmods.net/showthread.php?t=183865)

shavit 04-27-2012 18:44

[Help] 3 Things
 
im making a plugin, and i need 2 things.
1. im using a timer any 60 seconds/round_start hook that will check if there are admin in the server, if yes it will do something, else it will do something else.
how im checking if there is admin with admflag_generic? and if it will i can do something?
2. im making a command, that if im doing sm_ct 1 it will do something, and if sm_ct 0 something else, i never used arguments and didnt tried, i can have a guide or an public example? also if there are not args it will do something else.
3. how to make that to do something to SOURCETV and not to bots? if i can do only for both its ok, because i want to spectate the sourcetv any round and i dont know how to target it.

Thanks!

TnTSCS 04-27-2012 19:36

Re: [Help] 3 Things
 
1. Use CheckCommandAccess maybe - and yes, you can do something with timers

2. Yes, you can check if there are arguments to the string - something like if(args < 1) return;
Use GetCmdArg and store the command in a string - then do something if the string matches what you want it to match

3. I guess it depends on what you want to do to sourcetv... but IsClientSourceTV is what you need.

shavit 04-27-2012 20:19

Re: [Help] 3 Things
 
Quote:

Originally Posted by TnTSCS (Post 1697731)
1. Use CheckCommandAccess maybe - and yes, you can do something with timers

2. Yes, you can check if there are arguments to the string - something like if(args < 1) return;
Use GetCmdArg and store the command in a string - then do something if the string matches what you want it to match

3. I guess it depends on what you want to do to sourcetv... but IsClientSourceTV is what you need.

1. i dont know how to use 1 properly.
2. everytime im using arguments i get error/warning or its compiling and not working ingame.
3. works well :).

thetwistedpanda 04-27-2012 20:28

Re: [Help] 3 Things
 
http://docs.sourcemod.net/api/

TnTSCS 04-27-2012 20:56

Re: [Help] 3 Things
 
shavit - what you're asking for is pretty basic stuff - all of which is covered in one way or another in the documentation link thetwistedpanda provided.

mcpan313 04-28-2012 00:18

Re: [Help] 3 Things
 
PHP Code:

#include <sourcemod>

public OnPluginStart()
{
    
RegConsoleCmd("sm_ct"Command_Test);
    
    
CreateTimer(60.0Timer_FindAdminDoSth_TIMER_REPEAT);
}

public 
Action:Command_Test(clientargs)
{
    if (
args != 1)
    {
        
ReplyToCommand(client"Usage: !sm_ct [argument]");
        return 
Plugin_Handled;
    }
    
    
decl String:buffer[2];
    
GetCmdArg(1buffersizeof(buffer));
    new 
value StringToInt(buffer);
    
    switch (
value)
    {
        case 
0:
        {
            
// !sm_ct 0
        
}
        case 
1:
        {
            
// !sm_ct 1
        
}
    }
    
    return 
Plugin_Handled;
}

public 
Action:Timer_FindAdminDoSth(Handle:timer)
{
    for (new 
1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && !IsFakeClient(i) && (GetUserFlagBits(i) & ADMFLAG_GENERIC))
        {
            
// stuff.
        
}
    }



shavit 04-28-2012 06:09

Re: [Help] 3 Things
 
Quote:

Originally Posted by mcpan313 (Post 1697818)
PHP Code:

#include <sourcemod>

public OnPluginStart()
{
    
RegConsoleCmd("sm_ct"Command_Test);
    
    
CreateTimer(60.0Timer_FindAdminDoSth_TIMER_REPEAT);
}

public 
Action:Command_Test(clientargs)
{
    if (
args != 1)
    {
        
ReplyToCommand(client"Usage: !sm_ct [argument]");
        return 
Plugin_Handled;
    }
    
    
decl String:buffer[2];
    
GetCmdArg(1buffersizeof(buffer));
    new 
value StringToInt(buffer);
    
    switch (
value)
    {
        case 
0:
        {
            
// !sm_ct 0
        
}
        case 
1:
        {
            
// !sm_ct 1
        
}
    }
    
    return 
Plugin_Handled;
}

public 
Action:Timer_FindAdminDoSth(Handle:timer)
{
    for (new 
1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && !IsFakeClient(i) && (GetUserFlagBits(i) & ADMFLAG_GENERIC))
        {
            
// stuff.
        
}
    }



Thank you, please close the thread :).


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

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