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

Rules Menu w/ Accept or Deny


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
derptestt
Senior Member
Join Date: Jul 2015
Old 08-13-2015 , 14:35   Rules Menu w/ Accept or Deny
Reply With Quote #1

I'm trying to make a simple rules menu that pops up when the player joins the server. I would like it to give an Accept or Deny. Accept = enter server. Deny = kicks user from server. I'm also trying to figure out how to freeze the player until he presses accept or deny.

The menu and sm_rules does work. Deny does not seem to kick from teh server. It doesn't popup on join, and the accept/deny choice are on the wrong numbers. Am I going about it the wrong way?

PHP Code:
#include <sourcemod>

#pragma semicolon 1

public OnPluginStart()
{
    
RegConsoleCmd("sm_rules"Rules);
}

public 
Action:Rules(clientargs)
{
    new 
Handle:rules CreateMenu(RulesFunctionMenuAction_Select MenuAction_End MenuAction_DisplayItem);
    
SetMenuTitle(rules"Server Rules");
    
AddMenuItem(rules"1""Testing"ITEMDRAW_DISABLED);
    
AddMenuItem(rules"2""Da"ITEMDRAW_DISABLED);
    
AddMenuItem(rules"3""Rules"ITEMDRAW_DISABLED);
    
AddMenuItem(rules"4""Testing"ITEMDRAW_DISABLED);
    
AddMenuItem(rules"ACCEPT""Accept");
    
AddMenuItem(rules"DENY""Deny");
    
DisplayMenu(rulesclientMENU_TIME_FOREVER);
}

public 
RulesFunction(Handle:menuMenuAction:actionclientitem)
{

    
char name[32];
    
int target = -1;
    
GetCmdArg(1namesizeof(name));
 
    for (
int i=1i<=MaxClientsi++)
    {
        if (!
IsClientConnected(i))
        {
            continue;
        }
        
char other[32];
        
GetClientName(iothersizeof(other));
        if (
StrEqual(nameother))
        {
            
target i;
        }
    }
    
    switch(
action)
    {
        case 
MenuAction_Select:
        {
            
decl String:item_name[64];
            
GetMenuItem(menuitemitem_namesizeof(item_name));
            if(
StrEqual(item_name"ACCEPT"))
            {
                
CloseHandle(menu);
            }
            else if(
StrEqual(item_name"DENY"))
            {
                
ServerCommand("kickid %d"GetClientUserId(target));
            }
        }
    }


Last edited by derptestt; 08-13-2015 at 14:37.
derptestt is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-13-2015 , 14:44   Re: Rules Menu w/ Accept or Deny
Reply With Quote #2

Code:
ServerCommand("kickid %d", GetClientUserId(target));
See also: KickClient.

You also need to remove the menu's exit button.

Incidentally, isn't there already a plugin that does this?
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 08-13-2015 at 14:45.
Powerlord is offline
derptestt
Senior Member
Join Date: Jul 2015
Old 08-13-2015 , 14:57   Re: Rules Menu w/ Accept or Deny
Reply With Quote #3

I haven't seen a plugin that implements an Accept or Deny function that kicks you.

Is this better?
PHP Code:
#include <sourcemod>

#pragma semicolon 1

public OnPluginStart()
{
    
RegConsoleCmd("sm_rules"Rules);
}

public 
Action:Rules(clientargs)
{
    new 
Handle:rules CreateMenu(RulesFunctionMenuAction_Select MenuAction_DisplayItem);
    
SetMenuTitle(rules"Server Rules");
    
AddMenuItem(rules"1""Testing"ITEMDRAW_DISABLED);
    
AddMenuItem(rules"2""Da"ITEMDRAW_DISABLED);
    
AddMenuItem(rules"3""Rules"ITEMDRAW_DISABLED);
    
AddMenuItem(rules"4""Testing"ITEMDRAW_DISABLED);
    
AddMenuItem(rules"ACCEPT""Accept");
    
AddMenuItem(rules"DENY""Deny");
    
DisplayMenu(rulesclientMENU_TIME_FOREVER);
}

public 
OnClientPostAdminCheck(client)
{
    
DisplayMenu(rulesclientMENU_TIME_FOREVER);
}

public 
RulesFunction(Handle:menuMenuAction:actionclientitem)
{    
    switch(
action)
    {
        case 
MenuAction_Select:
        {
            
decl String:item_name[64];
            
GetMenuItem(menuitemitem_namesizeof(item_name));
            if(
StrEqual(item_name"ACCEPT"))
            {
                
CloseHandle(menu);
            }
            else if(
StrEqual(item_name"DENY"))
            {
                
KickClient(client"You didn't accept the rules.");
            }
        }
    }


Last edited by derptestt; 08-13-2015 at 15:13.
derptestt is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 08-13-2015 , 16:11   Re: Rules Menu w/ Accept or Deny
Reply With Quote #4

Check the TF2BWR source code on how they do the client freezing thing.

If a player joins the robots team then they are frozen unless the sm_tf2bwr_freeze cvar is set to 0. Using that info, trace their source code to see how they made a client frozen and unable to move.

Also, don't use servercommand if there is already a native (KickClient) to do the same thing since it's a security hazard. You only touch servercommand if you want to run a console command that there is no other alternative way of running (and even then, sanitize your input string prior to running it).

Last edited by Potato Uno; 08-13-2015 at 16:14.
Potato Uno is offline
derptestt
Senior Member
Join Date: Jul 2015
Old 08-13-2015 , 16:54   Re: Rules Menu w/ Accept or Deny
Reply With Quote #5

Thx Potato Uno, I can just freeze the movement of the client entity now that I think about it.

PHP Code:
public OnClientPostAdminCheck(client)
{
    
DisplayMenu(rulesclientMENU_TIME_FOREVER);

This line code not work, any idea why?
Also, is there a way to not display the number of the rules in the menu. For example

|Rules Menu Title|
Rule 1
Rule 2
Rule 3
1. Accept
2. Deny
(1 accepting and 2 denying)
derptestt is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 08-13-2015 , 17:12   Re: Rules Menu w/ Accept or Deny
Reply With Quote #6

try this

PHP Code:
#include <sourcemod>

#pragma semicolon 1

public OnPluginStart()
{
    
RegConsoleCmd("sm_rules"Rules);
}

public 
Action:Rules(clientargs)
{
    
ShowRules(client);
}

public 
OnClientPostAdminCheck(client)
{
    
ShowRules(client);
}

public 
ShowRules(client)
{
    new 
Handle:rules CreateMenu(RulesFunctionMenuAction_Select MenuAction_DisplayItem);
    
SetMenuTitle(rules"Server Rules\nTesting\nDa\Rules\nTesting");
    
AddMenuItem(rules"ACCEPT""Accept");
    
AddMenuItem(rules"DENY""Deny");
    
DisplayMenu(rulesclientMENU_TIME_FOREVER);
}

public 
RulesFunction(Handle:menuMenuAction:actionclientitem)
{
    switch (
action)
    {
        case 
MenuAction_Select:
        {
            
decl String:item_name[64];
            
GetMenuItem(menuitemitem_namesizeof(item_name));
            if (
StrEqual(item_name"ACCEPT"))
            {
                
CloseHandle(menu);
            }
            else if (
StrEqual(item_name"DENY"))
            {
                
KickClient(client"You didn't accept the rules.");
            }
        }
    }

Miu is offline
derptestt
Senior Member
Join Date: Jul 2015
Old 08-13-2015 , 17:15   Re: Rules Menu w/ Accept or Deny
Reply With Quote #7

Quote:
Originally Posted by Miu View Post
try this

PHP Code:
#include <sourcemod>

#pragma semicolon 1

public OnPluginStart()
{
    
RegConsoleCmd("sm_rules"Rules);
}

public 
Action:Rules(clientargs)
{
    
ShowRules(client);
}

public 
OnClientPostAdminCheck(client)
{
    
ShowRules(client);
}

public 
ShowRules(client)
{
    new 
Handle:rules CreateMenu(RulesFunctionMenuAction_Select MenuAction_DisplayItem);
    
SetMenuTitle(rules"Server Rules\nTesting\nDa\Rules\nTesting");
    
AddMenuItem(rules"ACCEPT""Accept");
    
AddMenuItem(rules"DENY""Deny");
    
DisplayMenu(rulesclientMENU_TIME_FOREVER);
}

public 
RulesFunction(Handle:menuMenuAction:actionclientitem)
{
    switch (
action)
    {
        case 
MenuAction_Select:
        {
            
decl String:item_name[64];
            
GetMenuItem(menuitemitem_namesizeof(item_name));
            if (
StrEqual(item_name"ACCEPT"))
            {
                
CloseHandle(menu);
            }
            else if (
StrEqual(item_name"DENY"))
            {
                
KickClient(client"You didn't accept the rules.");
            }
        }
    }

plugin.sp(23) : error 027: invalid character constant
I'm going to try it w/o the \n

EDIT 1: Worked kind of w/o the \n. The kick function and accept function works, but it doesn't pop up when you join the server. Does public OnClientPostAdminCheck(client) conflict with CS:GO or kztimer mod? I already tried OnClientAuthorization too.

Last edited by derptestt; 08-13-2015 at 17:19.
derptestt is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 08-13-2015 , 17:33   Re: Rules Menu w/ Accept or Deny
Reply With Quote #8

ok! try this maybe

PHP Code:
#include <sourcemod>

#pragma semicolon 1

public OnPluginStart()
{
    
RegConsoleCmd("sm_rules"Rules);
}

public 
Action:Rules(clientargs)
{
    
ShowRules(client);
}

public 
OnClientPostAdminCheck(client)
{
    
CreateTimer(5.0Timer_ShowRulesclient);
}

public 
Action:Timer_ShowRules(Handle:Timerclient)
{
    
ShowRules(client);
}

public 
ShowRules(client)
{
    new 
Handle:rules CreateMenu(RulesFunctionMenuAction_Select MenuAction_DisplayItem);
    
SetMenuTitle(rules"Server Rules\nTesting\nDa\nRules\nTesting");
    
AddMenuItem(rules"ACCEPT""Accept");
    
AddMenuItem(rules"DENY""Deny");
    
DisplayMenu(rulesclientMENU_TIME_FOREVER);
}

public 
RulesFunction(Handle:menuMenuAction:actionclientitem)
{
    switch (
action)
    {
        case 
MenuAction_Select:
        {
            
decl String:item_name[64];
            
GetMenuItem(menuitemitem_namesizeof(item_name));
            if (
StrEqual(item_name"ACCEPT"))
            {
                
CloseHandle(menu);
            }
            else if (
StrEqual(item_name"DENY"))
            {
                
KickClient(client"You didn't accept the rules.");
            }
        }
    }

Miu is offline
derptestt
Senior Member
Join Date: Jul 2015
Old 08-13-2015 , 17:45   Re: Rules Menu w/ Accept or Deny
Reply With Quote #9

Quote:
Originally Posted by Miu View Post
ok! try this maybe

PHP Code:
#include <sourcemod>

#pragma semicolon 1

public OnPluginStart()
{
    
RegConsoleCmd("sm_rules"Rules);
}

public 
Action:Rules(clientargs)
{
    
ShowRules(client);
}

public 
OnClientPostAdminCheck(client)
{
    
CreateTimer(5.0Timer_ShowRulesclient);
}

public 
Action:Timer_ShowRules(Handle:Timerclient)
{
    
ShowRules(client);
}

public 
ShowRules(client)
{
    new 
Handle:rules CreateMenu(RulesFunctionMenuAction_Select MenuAction_DisplayItem);
    
SetMenuTitle(rules"Server Rules\nTesting\nDa\nRules\nTesting");
    
AddMenuItem(rules"ACCEPT""Accept");
    
AddMenuItem(rules"DENY""Deny");
    
DisplayMenu(rulesclientMENU_TIME_FOREVER);
}

public 
RulesFunction(Handle:menuMenuAction:actionclientitem)
{
    switch (
action)
    {
        case 
MenuAction_Select:
        {
            
decl String:item_name[64];
            
GetMenuItem(menuitemitem_namesizeof(item_name));
            if (
StrEqual(item_name"ACCEPT"))
            {
                
CloseHandle(menu);
            }
            else if (
StrEqual(item_name"DENY"))
            {
                
KickClient(client"You didn't accept the rules.");
            }
        }
    }

I tried that too haha! I tried to set a timer. I think the KZTimer menu just overrides every menu. Oh well NOt that important of a plugin. Thanks for trying.

EDIT: NVM, the server rules titles worked. It just doesn't pop up when you join the game. Also, it displays the exit menu option. I thought I deleted that, hmm.

Last edited by derptestt; 08-13-2015 at 17:49.
derptestt is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 08-13-2015 , 18:00   Re: Rules Menu w/ Accept or Deny
Reply With Quote #10

isn't there an exceptions list kinda thing for kztimer?
Miu 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:10.


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