GTAMP.com

Grand Theft Auto Multiplayer
It is currently Sun Jun 16, 2019 1:19 pm

All times are UTC




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: C++ Help
PostPosted: Tue Sep 22, 2015 9:50 pm 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 459
Location: Poland / Szczecin
Hi, does anyone code throught c++ ? I have a snipped and need to add 1 loop and 1 "function".
Looking for somebody who want to help.
Cheers!


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 5:47 am 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1348
Location: GTAMP.com
I'm a noob at C++ but I think even I can do that.


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 8:34 am 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 459
Location: Poland / Szczecin
Syntax: [ Download ] [ Hide ]
Using C Syntax Highlighting
#include <cstdlib>
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;

int main() {

    int n;
    int num_attempts = 4;
    //int time
    string your_attempt = " ";
    int y;

    cout << "ROBCO INDUSTRIES (™) TERMLINK PROTOCOL" << endl;
    cout << "ENTER PASSWORD NOW" << endl;


    cout << endl;
    cout << num_attempts << " ATTEMPT(S) LEFT: ";
    for (n = 0; n<num_attempts; n++) {
        cout << "■";
    } cout << endl;
    cout << endl;
    cout << "0xF4F0 VIRAL 0xF5BC MINES" << endl;
    cout << "0cF4FC DARED 0xF5C8 LIKES" << endl;
    cout << "0xF508 WIRES 0xF5D4 PARTS" << endl;
    cout << "0xF514 LINES 0xF5E0 HAREM" << endl;
    cout << "0xF520 LIVES 0xF5EC LINED" << endl;
    cout << "0xF52C SORTS 0xF5F8 WARNS" << endl;
    cout << "0xF538 AGREE 0xF604 THREW" << endl;
    cout << "0xF544 FARMS 0xF610 SIDES" << endl;

    do {
        if (num_attempts > 0) {
            cout << " > ";
            cin >> your_attempt;
            if (your_attempt != "AGREE") {
                if (your_attempt == "VIRAL" || your_attempt == "LINES" || your_attempt == "LIVES" || your_attempt == "SORTS" || your_attempt == "FARMS" || your_attempt == "MINES" || your_attempt == "LIKES" || your_attempt == "PARTS" || your_attempt == "LINED" || your_attempt == "WARNS" || your_attempt == "SIDES") {
                    cout << "Incorrect! " << "1/5 Characters Right" << endl;
                }
                else { cout << "Incorrect! " << "2/5 Characters Right" << endl; }
            }
        }
        num_attempts = num_attempts - 1;
        cout << num_attempts << " ATTEMPT(S) LEFT: ";
        for (n = 0; n<num_attempts; n++) {
            cout << "■";
        } cout << endl;
    } while (your_attempt != "AGREE" && num_attempts != 0);

    if (your_attempt == "AGREE") {
        cout << "Exact Match! +75 XP" << endl;
    }
    else {
        cout << "You have been temporarily locked out! Contact the Administrator!" << endl;
    }
    system("PAUSE");
    return 0;
}
Parsed in 0.017 seconds, using GeSHi 1.0.8.10


OK so i need to do a loop that if you get answer wrong four times you will be blocked for 3 minutes and when you are correct you get that text plus your CD-ROM drive will open. I dont want to make this program quit - if you wont get an answer - time loop and back to the beggining if you got it the result (text + opening of cd rom) just freeze - do not shut down this program.

That will be fine!

One other thing - if somebody want to - you can re-doo script that counts letters (here i just have words that has 2 same letters that the right one) i't would be great to add other words and make program count them and show other results like comparing "key word" 'pedestrian' to 'lesbian' >output> wrong password 5/10 Characters Right. But its optional :)

Anyway i dont care that this is hardcoded.


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 8:56 am 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1348
Location: GTAMP.com
You could surround it with an infinite do while loop.

Syntax: [ Download ] [ Hide ]
Using C++ Syntax Highlighting
int main() {

do {

.......

} while (1);
   
    system("PAUSE");
    return 0;
}
 
Parsed in 0.006 seconds, using GeSHi 1.0.8.10


That doesn't use a function but it's easy enough to add one.


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 9:03 am 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 459
Location: Poland / Szczecin
OK WORKED - but still it loops itself and i want to get an result and thats it - no repetition (otherwise 3min of break and then return).


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 9:15 am 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1348
Location: GTAMP.com
This will exit if you type AGREE or loop after 3 minutes if you get it wrong.

Syntax: [ Download ] [ Hide ]
Using C++ Syntax Highlighting
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
 
using namespace std;

int main() {

    string your_attempt = " ";
   
    while (your_attempt != "AGREE") {
        int n;
        int num_attempts = 4;
        long lockout_time;
        int y;
           
        cout << "ROBCO INDUSTRIES (™) TERMLINK PROTOCOL" << endl;
        cout << "ENTER PASSWORD NOW" << endl;

        cout << endl;
        cout << num_attempts << " ATTEMPT(S) LEFT: ";
        for (n = 0; n<num_attempts; n++) {
            cout << "?";
        } cout << endl;
        cout << endl;
        cout << "0xF4F0 VIRAL 0xF5BC MINES" << endl;
        cout << "0cF4FC DARED 0xF5C8 LIKES" << endl;
        cout << "0xF508 WIRES 0xF5D4 PARTS" << endl;
        cout << "0xF514 LINES 0xF5E0 HAREM" << endl;
        cout << "0xF520 LIVES 0xF5EC LINED" << endl;
        cout << "0xF52C SORTS 0xF5F8 WARNS" << endl;
        cout << "0xF538 AGREE 0xF604 THREW" << endl;
        cout << "0xF544 FARMS 0xF610 SIDES" << endl;
   
        do {
            if (num_attempts > 0) {
                cout << " > ";
                cin >> your_attempt;
                if (your_attempt != "AGREE") {
                    if (your_attempt == "VIRAL" || your_attempt == "LINES" || your_attempt == "LIVES" || your_attempt == "SORTS" || your_attempt == "FARMS" || your_attempt == "MINES" || your_attempt == "LIKES" || your_attempt == "PARTS" || your_attempt == "LINED" || your_attempt == "WARNS" || your_attempt == "SIDES") {
                        cout << "Incorrect! " << "1/5 Characters Right" << endl;
                    }
                    else { cout << "Incorrect! " << "2/5 Characters Right" << endl; }
                }
            }
            num_attempts = num_attempts - 1;
            cout << num_attempts << " ATTEMPT(S) LEFT: ";
            for (n = 0; n<num_attempts; n++) {
                cout << "?";
            } cout << endl;
        } while (your_attempt != "AGREE" && num_attempts != 0);
   
        if (your_attempt == "AGREE") {
            cout << "Exact Match! +75 XP" << endl;
        }
        else {
            cout << "You have been temporarily locked out! Contact the Administrator!" << endl;
           
            time_t now = time(NULL);
            lockout_time=now+180;
            while (now<lockout_time) {
                now = std::time(NULL);
                cout << lockout_time-now << " until lockout ends" << endl;
            }
        }
    }
   
    system("PAUSE");
    return 0;
}
 
Parsed in 0.025 seconds, using GeSHi 1.0.8.10


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 9:40 am 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1348
Location: GTAMP.com
Updated with timer.


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 10:01 am 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 459
Location: Poland / Szczecin
Nicely done - but how to prevent it from closing? And i mean "forever" not loop just print msg and then freez program.


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 10:05 am 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1348
Location: GTAMP.com
You can add an infinite while loop. I also made it only update the time remaining each second. It was showing each millisecond before. I hope you learn this and don't just copy it for homework. I haven't played Fallout 3 but I saw this hacking game in a video of it.

Syntax: [ Download ] [ Hide ]
Using C++ Syntax Highlighting
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
 
using namespace std;

int main() {

    string your_attempt = " ";
   
    while (your_attempt != "AGREE") {
        int n;
        int num_attempts = 4;
        int lockout_time;
        int y;
        time_t now;
        int old;
       
        cout << "ROBCO INDUSTRIES (™) TERMLINK PROTOCOL" << endl;
        cout << "ENTER PASSWORD NOW" << endl;
        cout << endl;
        cout << num_attempts << " ATTEMPT(S) LEFT: ";
        for (n = 0; n<num_attempts; n++) {
            cout << "?";
        } cout << endl;
        cout << endl;
        cout << "0xF4F0 VIRAL 0xF5BC MINES" << endl;
        cout << "0cF4FC DARED 0xF5C8 LIKES" << endl;
        cout << "0xF508 WIRES 0xF5D4 PARTS" << endl;
        cout << "0xF514 LINES 0xF5E0 HAREM" << endl;
        cout << "0xF520 LIVES 0xF5EC LINED" << endl;
        cout << "0xF52C SORTS 0xF5F8 WARNS" << endl;
        cout << "0xF538 AGREE 0xF604 THREW" << endl;
        cout << "0xF544 FARMS 0xF610 SIDES" << endl;
   
        do {
            if (num_attempts > 0) {
                cout << " > ";
                cin >> your_attempt;
                if (your_attempt != "AGREE") {
                    if (your_attempt == "VIRAL" || your_attempt == "LINES" || your_attempt == "LIVES" || your_attempt == "SORTS" || your_attempt == "FARMS" || your_attempt == "MINES" || your_attempt == "LIKES" || your_attempt == "PARTS" || your_attempt == "LINED" || your_attempt == "WARNS" || your_attempt == "SIDES") {
                        cout << "Incorrect! " << "1/5 Characters Right" << endl;
                    }
                    else { cout << "Incorrect! " << "2/5 Characters Right" << endl; }
                }
            }
            num_attempts = num_attempts - 1;
            cout << num_attempts << " ATTEMPT(S) LEFT: ";
            for (n = 0; n<num_attempts; n++) {
                cout << "?";
            } cout << endl;
        } while (your_attempt != "AGREE" && num_attempts != 0);
   
        if (your_attempt == "AGREE") {
            cout << "Exact Match! +75 XP" << endl;
        }
        else {
            cout << "You have been temporarily locked out! Contact the Administrator!" << endl;
       
            now = time(NULL);
            lockout_time=now+180;
       
            while (now<lockout_time) {
                now = time(NULL);
                if (now && now!=old) {
                    cout << lockout_time-now << " until lockout ends" << endl;
                    old = now;
                }
            }
        }
    }
   
    //system("PAUSE");
    while(1){}
    return 0;
}
Parsed in 0.025 seconds, using GeSHi 1.0.8.10


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 10:37 am 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 459
Location: Poland / Szczecin
Well something went wrong : P

About copying - I want to start to learn this language same way i have learned gta2 scripting. But now i'm having problems with time and you know that time is what you need when you learn language.


Attachments:
woah.png
woah.png [ 246.73 KiB | Viewed 26158 times ]
Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 10:54 am 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1348
Location: GTAMP.com
Does it do that every time? Might need to initalise some variables or change NULL to 0.

I'm installing Visual Studio now. It worked fine in mingw.

I initialised "now" variable and changed NULL to 0.

Syntax: [ Download ] [ Hide ]
Using C++ Syntax Highlighting
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>
 
using namespace std;

int main() {

    string your_attempt = " ";
   
    while (your_attempt != "AGREE") {
        int n;
        int num_attempts = 4;
        int lockout_time;
        int y;
        time_t now = time(0);
        int old;
       
        cout << "ROBCO INDUSTRIES (™) TERMLINK PROTOCOL" << endl;
        cout << "ENTER PASSWORD NOW" << endl;
        cout << endl;
        cout << num_attempts << " ATTEMPT(S) LEFT: ";
        for (n = 0; n<num_attempts; n++) {
            cout << "?";
        } cout << endl;
        cout << endl;
        cout << "0xF4F0 VIRAL 0xF5BC MINES" << endl;
        cout << "0cF4FC DARED 0xF5C8 LIKES" << endl;
        cout << "0xF508 WIRES 0xF5D4 PARTS" << endl;
        cout << "0xF514 LINES 0xF5E0 HAREM" << endl;
        cout << "0xF520 LIVES 0xF5EC LINED" << endl;
        cout << "0xF52C SORTS 0xF5F8 WARNS" << endl;
        cout << "0xF538 AGREE 0xF604 THREW" << endl;
        cout << "0xF544 FARMS 0xF610 SIDES" << endl;
   
        do {
            if (num_attempts > 0) {
                cout << " > ";
                cin >> your_attempt;
                if (your_attempt != "AGREE") {
                    if (your_attempt == "VIRAL" || your_attempt == "LINES" || your_attempt == "LIVES" || your_attempt == "SORTS" || your_attempt == "FARMS" || your_attempt == "MINES" || your_attempt == "LIKES" || your_attempt == "PARTS" || your_attempt == "LINED" || your_attempt == "WARNS" || your_attempt == "SIDES") {
                        cout << "Incorrect! " << "1/5 Characters Right" << endl;
                    }
                    else { cout << "Incorrect! " << "2/5 Characters Right" << endl; }
                }
            }
            num_attempts = num_attempts - 1;
            cout << num_attempts << " ATTEMPT(S) LEFT: ";
            for (n = 0; n<num_attempts; n++) {
                cout << "?";
            } cout << endl;
        } while (your_attempt != "AGREE" && num_attempts != 0);
   
        if (your_attempt == "AGREE") {
            cout << "Exact Match! +75 XP" << endl;
        }
        else {
            cout << "You have been temporarily locked out! Contact the Administrator!" << endl;
       
            now = time(NULL);
            lockout_time=now+180;
       
            while (now<lockout_time) {
                now = time(0);
                if (now && now!=old) {
                    cout << lockout_time-now << " until lockout ends" << endl;
                    old = now;
                }
            }
        }
    }
   
    //system("PAUSE");
    while(1){}
    return 0;
}
 
Parsed in 0.025 seconds, using GeSHi 1.0.8.10


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 11:09 am 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 459
Location: Poland / Szczecin
Errors, shouldn't we give those ints some value?


Attachments:
333333.png
333333.png [ 4.86 KiB | Viewed 26156 times ]
Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 11:35 am 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1348
Location: GTAMP.com
Yes change int old; to int old=0;


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 11:57 am 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 459
Location: Poland / Szczecin
Okey, so far so good - its working as i wanted. Last one thing - I discovered that you can type whatever you want for example: 'poop' and it still return 2/5 letter info - The result i wanted should be only for words from code, otherwise it should return other text like: WRONG.


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 12:23 pm 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1348
Location: GTAMP.com
You could use http://www.cplusplus.com/reference/string/string/find/ to find letters in the strings.

Since the position of the letters is fixed, you don't need to use find, you could use:
http://www.cplusplus.com/reference/stri ... ng/substr/
http://www.cplusplus.com/reference/stri ... g/compare/

If you aren't expected to use those then you could make another word list with just words that share 2 letters.


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 12:58 pm 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 459
Location: Poland / Szczecin
im going to make list that just share 2 letters. And hardcode them. So if you put something else than they you will recive other communicate.


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 1:34 pm 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1348
Location: GTAMP.com
I ended up not using find, substr or compare. This version can show any number of correct letters and doesn't use word lists.

Image

Syntax: [ Download ] [ Hide ]
Using C++ Syntax Highlighting
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>

using namespace std;

int main() {

    string your_attempt = " ";
    string password = "AGREE";

    while (your_attempt != password) {

        int num_attempts = 4;
        int n = 0;
        int correct_letters = 0;
        time_t lockout_time = 0;
        time_t old = 0;
        time_t now = 0;

        cout << "ROBCO INDUSTRIES (™) TERMLINK PROTOCOL" << endl;
        cout << "ENTER PASSWORD NOW" << endl;
        cout << endl;
        cout << num_attempts << " ATTEMPT(S) LEFT: ";
        for (n = 0; n<num_attempts; n++) {
            cout << "?";
        } cout << endl;
        cout << endl;
        cout << "0xF4F0 VIRAL 0xF5BC MINES" << endl;
        cout << "0cF4FC DARED 0xF5C8 LIKES" << endl;
        cout << "0xF508 WIRES 0xF5D4 PARTS" << endl;
        cout << "0xF514 LINES 0xF5E0 HAREM" << endl;
        cout << "0xF520 LIVES 0xF5EC LINED" << endl;
        cout << "0xF52C SORTS 0xF5F8 WARNS" << endl;
        cout << "0xF538 AGREE 0xF604 THREW" << endl;
        cout << "0xF544 FARMS 0xF610 SIDES" << endl;

        do {
            if (num_attempts > 0) {
                cout << " > ";
                cin >> your_attempt;
                your_attempt.resize(5);

                if (your_attempt != password) {
                    correct_letters = 0;
                    for (int i = 0; i < password.size(); i++) {
                        if (your_attempt[i] == password[i]) {
                            correct_letters++;
                        }
                    }

                    cout << "Incorrect! " << correct_letters << "/5 Characters Right" << endl;
                }
            }
            if (your_attempt != password) {
                num_attempts = num_attempts - 1;
                cout << num_attempts << " ATTEMPT(S) LEFT: ";
                for (n = 0; n < num_attempts; n++) {
                    cout << "?";
                } cout << endl;
            }
        } while (your_attempt != password && num_attempts != 0);

        if (your_attempt == password) {
            cout << "Exact Match! +75 XP" << endl;
        }
        else {
            cout << "You have been temporarily locked out! Contact the Administrator!" << endl;

            now = time(0);
            lockout_time = now + 180;

            while (now<lockout_time) {
                now = time(0);
                if (now && now != old) {
                    cout << lockout_time - now << " seconds until lockout ends" << endl;
                    old = now;
                }
            }
        }
    }

    //system("PAUSE");
    while (1){}
    return 0;
}
 
Parsed in 0.022 seconds, using GeSHi 1.0.8.10


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 5:36 pm 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 459
Location: Poland / Szczecin
THANKS~!
Ok, So now i can change password and hints to whatever i want but it has to have 5 letters, yes? Or at least the same ammount of letters so i can change just outcome for "/xletters"

Am i right?

LESBIAN WOMBAD <3 *_*


Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 9:02 pm 
Offline
Lunatic

Joined: Sat Jul 19, 2008 2:14 pm
Posts: 459
Location: Poland / Szczecin
Tried to update that code and got error:

Syntax: [ Download ] [ Hide ]
Using C++ Syntax Highlighting
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>
#include <ctime>

using namespace std;

int main() {

    string your_attempt = " ";
    string password = "SKAZANI";

    while (your_attempt != password) {

        int num_attempts = 4;
        int n = 0;
        int correct_letters = 0;
        time_t lockout_time = 0;
        time_t old = 0;
        time_t now = 0;

        cout << "DR. WADDLES (™) PMS (PROTECTING MEMORY SYSTEM) " << endl;
        cout << "WPISZ HASLO:" << endl;
        cout << endl;
        cout << num_attempts << " ZOSTALO PROB: ";
        for (n = 0; n<num_attempts; n++) {
            cout << "▀";
        } cout << endl;
        cout << endl;
         
       
        cout << " _____ _____ _____ _____ _ _ _ _____ _____ _____ _____ "<< endl;
        cout << "|  |  |  _  |  |  |     | | | |  _  |   | |     |   __|" << endl;
        cout << "|     |     |    -|  |  | | | |     | | | |-   -|   __|" << endl;
        cout << "|__|__|__|__|__|__|_____|_____|__|__|_|___|_____|_____|" << endl;
        cout << "" << endl;
        cout << " _____ _____ _____ _____ _____ _____ _____ __    _____ " << endl;
        cout << "|_   _|   __| __  |     |     |   | |  _  |  |  |  _  |" << endl;
        cout << "  | | |   __|    -| | | |-   -| | | |     |  |__|     |" << endl;
        cout << "  |_| |_____|__|__|_|_|_|_____|_|___|__|__|_____|__|__|" << endl;
        cout << "" << endl;

        cout << "- BRAK POLSKICH ZNAKOW + WIELKIE LITERY" << endl;
        cout << "__________________________________________" << endl;
        cout << "0xF68C ..;$##$%^FRA    0xF68D $SARKAZM$$$$" << endl;
        cout << "0xF698 SZKA%#$%{}!@    0xF699 {}^%#@@#!SKA" << endl;
        cout << "0xF6A4 <:%#%@#{}@!#    0xF6B5 ZANI>>,@{#:@" << endl;
        cout << "0xF6S7 ..^ZASUWKA#@    0xF6S6 %#@!@$@*#$%@" << endl;
        cout << "0xF5H9 ###!!#~~~SZM    0xF4H8 }|}|}|}@@#!!" << endl;
        cout << "0xF7S9 ATKA%:??>>]Z    0xF987 ####!@^&KARW" << endl;
        cout << "0xF789 ASYPKA./[ZAK    0xF123 ASZ##~!@#%KA" << endl;
        cout << "0xF1Z3 WASY^^^[][]@    0xF444 SIARZ_.~*.*~" << endl;
        cout << "0xF1Z4 [_%%!!<>>>>|    0xF001 #####;[.,:{$" << endl;
        cout << "0xF2B3 ~!!@!@**^^%$    0xF003 <][[;;<>^$%$" << endl;
        cout << "0xF3B3 <,?EKSTAZA*%    0xF006 *APASZKI$%#@" << endl;
        cout << "0xF3C4 &#$%##^&{ {[    0xF009 (&*(&^%SZKAR" << endl;
        cout << "0xF4A1 /*-*SZAKALE|    0xF112 AD#^$KATUSZA" << endl;
        cout << "__________________________________________" << endl;

        do {
            if (num_attempts > 0) {
                cout << " > ";
                cin >> your_attempt;
                your_attempt.resize(5);

                if (your_attempt != password) {
                    correct_letters = 0;
                    for (int i = 0; i < password.size(); i++) {
                        if (your_attempt[i] == password[i]) {
                            correct_letters++;
                        }
                    }

                    cout << "NIEPRAWIDLOWE HASLO! " << correct_letters << "/7 POPRAWNYCH ZNAKOW" << endl;
                }
            }
            if (your_attempt != password) {
                num_attempts = num_attempts - 1;
                cout << num_attempts << " ZOSTALO PROB: ";
                for (n = 0; n < num_attempts; n++) {
                    cout << "▀";
                } cout << endl;
            }
        } while (your_attempt != password && num_attempts != 0);

        if (your_attempt == password) {
            cout << "WYGRALES ZYCIE" << endl;
        }
        else {
            cout << "DOSTEP DO KONTA ZOSTAL ZABLOKOWANY NA 3 MINUTY!" << endl;

            now = time(0);
            lockout_time = now + 180;

            while (now<lockout_time) {
                now = time(0);
                if (now && now != old) {
                    cout << lockout_time - now << " SEKUND POZOSTALO" << endl;
                    old = now;
                }
            }
        }
    }

    //system("PAUSE");
    while (1) {}
    return 0;
}
Parsed in 0.029 seconds, using GeSHi 1.0.8.10


WHY?


Attachments:
error.png
error.png [ 192.08 KiB | Viewed 26127 times ]
Top
 Profile  
 
 Post subject: Re: C++ Help
PostPosted: Wed Sep 23, 2015 9:47 pm 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1348
Location: GTAMP.com
your_attempt.resize(5);

Change 5 to password length + 1 or password.size()


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group