Raised This Month: $305 Target: $400
 76%   Almost there!

Answer correctly or kick


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Trollface112
New Member
Join Date: Sep 2021
Old 09-12-2021 , 04:06   Answer correctly or kick
Reply With Quote #1

Hi,

I need a plugin that consists of the following ONLY for admins:

When you connect to the server, a certain random question appears in which to choose or write the answer. If the answer is correct, you can play and if it is wrong to receive a kick.

Thanks a lot !
Trollface112 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-12-2021 , 14:07   Re: Answer correctly or kick
Reply With Quote #2

Moved to suggestions/requests
__________________
Bugsy is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 09-13-2021 , 09:59   Re: Answer correctly or kick
Reply With Quote #3

hello, you can try using this code, add your questions (with answers of course) into: g_szRandomStuff, also it will activate black screenfade on the client (if he is admin) to write message, it looks like this, he has only one chance:


Code:
#include <amxmodx>
#include <amxmisc>

#define TASK_CONNECT 321
new g_iHisQuestion[ 33 ]
new msgScreenFade

enum _:AdminStuff
{
    Question[ 100 ],
    Answer[ 50 ]
}
new const g_szRandomStuff[][ AdminStuff ] =
{
    { "Who is president of USA?",       "biden" },
    { "Are you admin here?",            "yes" },
    { "On what key do you jump?",       "space" },
    { "Do you love our community?",     "yes" }
}

public plugin_init()
{
    register_plugin( "Admin Question/asnwer", "1.0", "JocA" )
    register_clcmd( "say", "said" )

    msgScreenFade = get_user_msgid("ScreenFade")
}
public said( id )
{
    if( is_user_admin( id ) )
    {
        new text[ 100 ]
        read_argv( 1, text, charsmax( text ) )
        if( g_iHisQuestion[ id ] >= 0 )
        {
            if( equal( text, g_szRandomStuff[ g_iHisQuestion[ id ] ][ Answer ] ) )
                g_iHisQuestion[ id ] = -1
            else
                server_cmd( "kick #%d ^"You didnt answer the question correctly", get_user_userid( id ) )

            return PLUGIN_HANDLED
        }
    }
    return PLUGIN_CONTINUE
}
public client_putinserver( id )
{
    g_iHisQuestion[ id ] = -1
    set_task( 3.0, "ask_him", TASK_CONNECT + id )
}
public client_disconnected( id )
{
    g_iHisQuestion[ id ] = -1
    remove_task( id + TASK_CONNECT )
}
public ask_him( task )
{
    new id = task - TASK_CONNECT
    new size = sizeof( g_szRandomStuff )
    g_iHisQuestion[ id ] = random( size )
    fade_screen( id )
    set_dhudmessage( 255, 255, 255, -1.0, -1.0, 0, 0.0, 7.0, 0.0, 0.0 )
    show_dhudmessage( id, fmt( "You must answer correct this question in chat^n(otherwise you will be kicked):^n^n%s", g_szRandomStuff[ g_iHisQuestion[ id ] ][ 0 ] ) )
}
stock fade_screen( id )
{
    message_begin( MSG_ONE_UNRELIABLE, msgScreenFade, { 0, 0, 0 }, id )
    write_short( 4096 * 5 )
    write_short( 4096 * 5 )
    write_short( 0 )
    write_byte( 0 )
    write_byte( 0 )
    write_byte( 0 )
    write_byte( 255 )
    message_end()
}
Please change my questions, they are random on purpose for the testing (question will be 3.0 seconds after he connects on the server)

PS: you need 1.8.3+ amxmodx to compile it
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...)

Last edited by JocAnis; 09-13-2021 at 10:06.
JocAnis is offline
Reply


Thread Tools
Display Modes

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 01:20.


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