News:

MFG's Character of the Month: October 2026 Nominations

Main Menu

Using C++

Started by Saohc, January 30, 2010, 05:40:43 AM

Previous topic - Next topic

Saohc

I'm trying to make a password system for my full game, but in order to do that..

I need help..

What's the full code required in order to have password system?

Like that Chrono_Strife guy told me in the hidden character topic..

"Double click it.
Text box shows up.
Input a password in said txtbox.
Press 'OK'
If valid, change a line in the select.def, or use a different select.def.
Pop-Up a Message that says "xxxxx has been unlocked!"
Exit program."

How can I program this in C++?

Chronojiuj

Spoiler (click to show)


The Aboriginal One

This is way beyond that page's scope.

What GUI is it in? console? GUI? which GUI? WxWindows? Microsoft API? SDL?
Accusare nemo se debet nisi coram Veridis
DYNOMITE

Tony 3rd

this is a very basic piece of code that you can use.
its not complete, since i never got that far into C++ to the point of dealing with files.



and just a quick reminder: don't forget to set the variables you will have to use.

#include <stdio.h>

int main()
{
   char password;
   
do{

   printf("Enter the Password or type exit to close:");
   scanf("%c", &password);
     if(password="char1){
           <insert here nice piece of code that allows you to alter a txt file. you will have to google for a tutorial>
          }else if (password = "char2"){
           <insert here another nice piece of code that allows you to alter a txt file. you will have to google for a tutorial>
          }else if (password = "char3"){
           <insert here another nice piece of code that allows you to alter a txt file. you will have to google for a tutorial>
          }
}while(password !=exit)
}


This piece of code will show in a command prompt. if you want to do something that will show on a regular windows, I would recommend you to use Visual C++. its makes it easier to do the kind of input interface you want to do. you just have to adapt the code to the window code.

Saohc

Which type of file should I have it as?

.xml or something?

text file?

Style sheet?


BTW:

I have Visual Basic C++ 2008

Foobs

Don't delete your own post. Is the same as bumping.

Saohc

I'm just asking what type of file to do this as..

Valodim

I'm usually not a naysayer on such things, but your only hopes is finding someone who codes it for you and gives you the executable file. Or maybe try a different coding language, I can assure you that you are wasting your time with C++ here.

Saohc

Well no one's going to bother to code for me (you can guess why..)

and I don't what file type to do it as...

Because it has to be able to work with MUGEN..

and if C++ won't work for me, then what will?

Byakko

Stop deleting and reposting your post. Edit it.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.

Valodim

the file type is .cpp

The Aboriginal One

Quote from: Luigi1632 on January 30, 2010, 06:39:42 PM
Because it has to be able to work with MUGEN..
and if C++ won't work for me, then what will?

C++ would work, you just need to learn intermediate level C++ and Windows GUI. Besides, your program is obviously flawed, seeing is we can just simply add the character in the select.def if we do not want to go through it all.
Accusare nemo se debet nisi coram Veridis
DYNOMITE

Saohc

and Tony 3rd said I need to learn a tutorial on how to make it where it alter the select.def

Some kind of code that is required..

Byakko

#13
the C++ program would show a window that asks for a password, and if the password is correct, it would then modify the select.def to add the hidden characters. How ? Learn to code in C++, that's how.
You will most likely waste a lot of time learning enough C++ to do that properly. It's not "some kind of code", you're coding an application (and then you'll have to compile it). A simple one, that just reads and input and modifies a file, but nonetheless, it's not just "some kind of code" where you can just wake up one morning and decide you'll learn an entirely new coding language (when you obviously have very little idea of what coding is in general) just for that.

Short story : if you really think it's worth all that waste, LEARN. Google it, search for a lot of tutorials, read them, experiment.
If I struggled to the end of my determination, to the end of my way of life with my followers, if the result is ruin, then this ruin is inevitable. Grieve. Shed tears. But you cannot regret.

The Aboriginal One

It is true. It'll take some days to learn C++, being it's not a simple language like mugen's scripting language. This is probably your first Object Oriented language as well. It will take some time for you to learn it.
Accusare nemo se debet nisi coram Veridis
DYNOMITE

Saohc

I know...

It's not like Game Maker where it's 1,2,3, and you're finished..


Hero

Visual C++ 2006 Edition.

Write the code in cpp, compile, execute, if it´s allright, copy the exe file.

Thats all,
Quote from: Tony 3rd on January 30, 2010, 06:10:03 AM
this is a very basic piece of code that you can use.
its not complete, since i never got that far into C++ to the point of dealing with files.



and just a quick reminder: don't forget to set the variables you will have to use.

#include <stdio.h>

int main()
{
    char password;
   
do{

    printf("Enter the Password or type exit to close:");
    scanf("%c", &password);
      if(password="char1){
            <insert here nice piece of code that allows you to alter a txt file. you will have to google for a tutorial>
           }else if (password = "char2"){
            <insert here another nice piece of code that allows you to alter a txt file. you will have to google for a tutorial>
           }else if (password = "char3"){
            <insert here another nice piece of code that allows you to alter a txt file. you will have to google for a tutorial>
           }
}while(password !=exit)
}


This piece of code will show in a command prompt. if you want to do something that will show on a regular windows, I would recommend you to use Visual C++. its makes it easier to do the kind of input interface you want to do. you just have to adapt the code to the window code.

This appear to be like C, not C++. But works anyway...

#include <iostream>
#include <string.h>
using namespace std;

void main ()
{
   char password[8]; //<-declarating a password of 8 characters, can be as larger as you want
   char truepassword[8]; // <- same
   truepassword = [g,t,y,h,j,u,i,k]; // here is the password, set it you want


that`s is just a little piece of the code, the rest is like Tony 3rd posted, replacing

    printf("Enter the Password or type exit to close:");
    scanf("%c", &password);

   for

   cout<<"Enter the Password or type exit to close: "<<endl;
   cin>>password;

    if (password = 'char3')  --use simple quotes, not double quotes

Usually, you should use Java for this, because is more easy to modify (and even create) files. C++ is not a completely Objetc Oriented Language, but a hybrid.

See ya
   

Saohc

i have 50 passwords for the game..

do I need seperate sections for each one?

and I have Visual Basic 2008, if you would like to know..

and don't exactly give me tidbits..

i just want the full code for doing this..

Iced

you dont want to learn you want the fullcode done for you, you want others to do the code.

and for some reason you keep posting, deleting your message and repeating the post
Quote from: Luigi1632 on January 30, 2010, 11:48:54 PM
i have 50 passwords for the game..

do I need seperate sections for each one?

and I have Visual Basic 2008, if you would like to know..

and don't exactly give me tidbits..

i just want the full code for doing this..

sup, strangeness?

Saohc

Well they are just giving me little tidbits, not the full thing..

i'm also trying to work on my original characters a bit..(for the fullgame, that is..)

and I cannot release this full game until everything is done and that there is a way to unlock characters(easily, instead of having to go to data and find select.def..)


and I may consider releasing the first version of the full game to a certain group of people..