Raised This Month: $ Target: $400
 0% 

[ANY] Konami Code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nergal
Veteran Member
Join Date: Apr 2012
Old 02-17-2014 , 16:18   [ANY] Konami Code?
Reply With Quote #1

hello, I am coding up a Cheat Code Maker plugin (which I'm planning on releasing here)

and part of the cheat codes I'd like to input for use is the Konami code.

incase you don't know what Konami Code is, it's a common cheat code where you press Up, Up, Down, Down, Left+Right, Left+Right, A, then B in that following sequence.

What I'm trying to achieve is the same result BUT, I want server operators to be able to make their own input sequence requirements rather than one static sequence.


Here's what I currently have but I feel it won't work out how I want it to.
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <tf2_stocks>
#include <tf2items>
#include <sdkhooks>
#include <morecolors>

new Handle:ButtonTimer[MAXPLAYERS+1] = INVALID_HANDLE;

new 
Handle:DynamicCodeCookie;
new 
Handle:StaticCodeCookie;

new 
Handle:StaticCode;

new 
Handle:Buttonz[8];
//new bool:Buttonz[] = {IN_ATTACK, IN_JUMP, IN_DUCK, IN_FORWARD, IN_BACK, IN_ATTACK2, IN_MOVELEFT, IN_MOVERIGHT};
new bool:DoInput false;
//new bool:Button[8];

//new Proplayer[MAXPLAYERS+1];
new String:symbols[36][1] = {"A""B""C""D""E""F""G""H""I""J""K""L""M""N""O""P""Q""R""S""T""U""V""W""X""Y""Z""1""2""3""4""5""6""7""8""9""0"};

public 
Plugin:myinfo =
{
    
name "CheatCoderGen",
    
author "Assyrian/Nergal",
    
description "adds cheat codes to TF2",
    
version "1.0.0.0",
    
url "http://www.sourcemod.net/"


public 
OnPluginStart()
{
    
RegAdminCmd("ccm_cheatcode"Command_CheatCodeADMFLAG_GENERIC);
    
//RegConsoleCmd("ccm_inputcode", Command_CodeInput, "command to allow players to input button codes");
    
StaticCode CreateConVar("sm_ccm_staticcode""11111""Default level for players when they join");
    
Buttonz[0] = CreateConVar("sm_ccm_inputsequence1""IN_ATTACK""input #1 'konami code style' that must be done correctly for player to get reward");
    
Buttonz[1] = CreateConVar("sm_ccm_inputsequence2""IN_ATTACK""input #2 'konami code style' that must be done correctly for player to get reward");
    
Buttonz[2] = CreateConVar("sm_ccm_inputsequence3""IN_ATTACK""input #3 'konami code style' that must be done correctly for player to get reward");
    
Buttonz[3] = CreateConVar("sm_ccm_inputsequence4""IN_ATTACK""input #4 'konami code style' that must be done correctly for player to get reward");
    
Buttonz[4] = CreateConVar("sm_ccm_inputsequence5""IN_ATTACK""input #5 'konami code style' that must be done correctly for player to get reward");
    
Buttonz[5] = CreateConVar("sm_ccm_inputsequence6""IN_ATTACK""input #6 'konami code style' that must be done correctly for player to get reward");
    
Buttonz[6] = CreateConVar("sm_ccm_inputsequence7""IN_ATTACK""input #7 'konami code style' that must be done correctly for player to get reward");
    
Buttonz[7] = CreateConVar("sm_ccm_inputsequence8""IN_ATTACK""input #8 'konami code style' that must be done correctly for player to get reward");

    
DynamicCodeCookie RegClientCookie("dynamic_code""dynamic code, changes everytime it's used"CookieAccess_Protected);
    
StaticCodeCookie RegClientCookie("static_code""static code, never changed till Server Op changes it"CookieAccess_Protected);
    
AutoExecConfig(true"CheatCoderMaker");
    
}
public 
OnConfigsExecuted()
{
    
Button[0] = GetConVarInt(Buttonz[0]);
    
Button[1] = GetConVarInt(Buttonz[1]);
    
Button[2] = GetConVarInt(Buttonz[2]);
    
Button[3] = GetConVarInt(Buttonz[3]);
    
Button[4] = GetConVarInt(Buttonz[4]);
    
Button[5] = GetConVarInt(Buttonz[5]);
    
Button[6] = GetConVarInt(Buttonz[6]);
    
Button[7] = GetConVarInt(Buttonz[7]);
}

public 
Action:Command_CodeInput(clientargs)
{
    
DoInput true;
    
ButtonTimer[client] = CreateTimer(GetConVarFloat(TimeForInputCode), Timer_RevertInputBoolclientTIMER_FLAG_NO_MAPCHANGE);
    return 
Plugin_Handled;
}
public 
Action:Timer_RevertInputBool(Handle:hTimerany:client)
{
    
DoInput false;
    
ClearTimer(ButtonTimer[client]);
    return 
Plugin_Continue;
}

public 
Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    if (!
IsValidClient(clientfalse) || !IsClientConnected(client) || !IsClientInGame(client) || !IsPlayerAlive(client))
        return 
Plugin_Continue;
    
//new Float:time = GetGameTime();
    
if (DoInput == true)
    {
        for (new 
0<= 7i++) //checks if the sequence is all set to true
        
{
            if (
Button[i]) continue;
            else break;
        }
    }

What I've currently tried, in the code above, it so use bool'd arrays that have each IN_KEY input in each array that'll set to true.
__________________

Last edited by nergal; 02-17-2014 at 16:21.
nergal is offline
arthurdead
Senior Member
Join Date: Jul 2013
Old 02-17-2014 , 16:26   Re: [ANY] Konami Code?
Reply With Quote #2

konami code wut nice ideia make an cfg file with the codes
arthurdead is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-17-2014 , 16:55   Re: [ANY] Konami Code?
Reply With Quote #3

except you cant catch if a player pushes a specefic key.. OnPlayerRunCmd is if they run a bound key command. so if you bound t to +attack if the player holds T it will register as IN_ATTACK1
Mitchell is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 02-17-2014 , 16:59   Re: [ANY] Konami Code?
Reply With Quote #4

you want all the keys to be press at the same time or executed one after each others? If this is the case, you need to check the time, make sure it lower than x sec (mili sec?) check the other after ward and etc. I will write an example about it, give me 1 or 2 hours.

Last edited by Mathias.; 02-17-2014 at 17:00.
Mathias. is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 02-17-2014 , 16:59   Re: [ANY] Konami Code?
Reply With Quote #5

Quote:
Originally Posted by Mitchell View Post
except you cant catch if a player pushes a specefic key.. OnPlayerRunCmd is if they run a bound key command. so if you bound t to +attack if the player holds T it will register as IN_ATTACK1
I don't mind that, as long as they do that input.
__________________
nergal is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 02-17-2014 , 17:02   Re: [ANY] Konami Code?
Reply With Quote #6

Quote:
Originally Posted by Black-Rabbit View Post
you want all the keys to be press at the same time or executed one after each others? If this is the case, you need to check the time, make sure it lower than x sec (mili sec?) check the other after ward and etc. I will write an example about it, give me 1 or 2 hours.
executed one after another.

The DoInput bool is so that they must execute each key in a sequence in a certain amount of time.
__________________

Last edited by nergal; 02-17-2014 at 17:02.
nergal is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 02-17-2014 , 17:03   Re: [ANY] Konami Code?
Reply With Quote #7

Quote:
Originally Posted by arthurdead View Post
konami code wut nice ideia make an cfg file with the codes
I'd do it a different way if I knew how....
__________________
nergal is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 02-17-2014 , 17:14   Re: [ANY] Konami Code?
Reply With Quote #8

TIP: Use add quote to do multiple quotes and not spam your thread.
How are you going to catch the users pressing letter keys is what i was asking. plus arrow keys, infering if you dont want w/a/s/d to be the up/left/down/right keys
Mitchell is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 02-17-2014 , 17:29   Re: [ANY] Konami Code?
Reply With Quote #9

Quote:
Originally Posted by Mitchell View Post
TIP: Use add quote to do multiple quotes and not spam your thread.
How are you going to catch the users pressing letter keys is what i was asking. plus arrow keys, infering if you dont want w/a/s/d to be the up/left/down/right keys
I was hoping to just use IN_KEY buttons like IN_ATTACK or IN_FOWARD. like that.

have a bool:button[8] array to {IN_ATTACK, IN_BACK, IN_FORWARD.... etc};

one way I figured for this was to have a convar list each IN_KEY by each array position then apply it in OnPlayerRunCMD
__________________

Last edited by nergal; 02-17-2014 at 17:31.
nergal is offline
arthurdead
Senior Member
Join Date: Jul 2013
Old 02-17-2014 , 17:31   Re: [ANY] Konami Code?
Reply With Quote #10

Quote:
Originally Posted by nergal View Post
I was hoping to just use IN_KEY buttons like IN_ATTACK or IN_FOWARD. like that.

have a bool:button[8] array to {IN_ATTACK, IN_BACK, IN_FORWARD.... etc};
PHP Code:
// These defines are for client button presses.
#define IN_ATTACK        (1 << 0)
#define IN_JUMP            (1 << 1)
#define IN_DUCK            (1 << 2)
#define IN_FORWARD        (1 << 3)
#define IN_BACK            (1 << 4)
#define IN_USE            (1 << 5)
#define IN_CANCEL        (1 << 6)
#define IN_LEFT            (1 << 7)
#define IN_RIGHT        (1 << 8)
#define IN_MOVELEFT        (1 << 9)
#define IN_MOVERIGHT        (1 << 10)
#define IN_ATTACK2        (1 << 11)
#define IN_RUN            (1 << 12)
#define IN_RELOAD        (1 << 13)
#define IN_ALT1            (1 << 14)
#define IN_ALT2            (1 << 15)
#define IN_SCORE        (1 << 16)       /**< Used by client.dll for when scoreboard is held down */
#define IN_SPEED        (1 << 17)    /**< Player is holding the speed key */
#define IN_WALK            (1 << 18)    /**< Player holding walk key */
#define IN_ZOOM            (1 << 19)    /**< Zoom key for HUD zoom */
#define IN_WEAPON1        (1 << 20)    /**< weapon defines these bits */
#define IN_WEAPON2        (1 << 21)    /**< weapon defines these bits */
#define IN_BULLRUSH        (1 << 22)
#define IN_GRENADE1        (1 << 23)    /**< grenade 1 */
#define IN_GRENADE2        (1 << 24)    /**< grenade 2 */
#define IN_ATTACK3        (1 << 25) 
thats all you can catch
arthurdead 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 23:35.


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