The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Help] String to Int conversion
SPACoD Offline
Junior Member

Posts: 13
Threads: 4
Joined: Jan 2012
Reputation: 0
#1
[Help] String to Int conversion

Hi, everyone, I got a problem, I don't know how to convert string to int.
I want to make a code locking mechanism which is shorter than the one I made before but I can't.

Here is the code:


if(Code[1][4] == 1)
{
string Entered = StringSub(asEntity, 12, 1);
PlayGuiSound("Click", 1);
Code[1][0] = Entered; <- This line gives an error that it can't implictly convert string& to int&
Code[1][4]++;
AddDebugMessage("Entered: " + Code[1][0], false);
}

So, the buttons are called in a range from Lock_Button_0 to Lock_Button_9.
Code[1][4] is the digit you're currently entering (in this case the first).
The string "Entered" extracts the number from the name of the button (the string is the number, so I want to convert it to an integer).
Code[1][0] is the number that is set when a corresponding button is pressed (can range from 0 to 9).
I am no expert on C++, but I know some tricks Wink

If someone knows how to do this I'd be very grateful.
Greetz, SPACoD
(This post was last modified: 07-20-2012, 10:19 AM by SPACoD.)
07-20-2012, 10:14 AM
Find


Messages In This Thread
[Help] String to Int conversion - by SPACoD - 07-20-2012, 10:14 AM
RE: [Help] String to Int conversion - by SPACoD - 07-20-2012, 11:15 AM
RE: [Help] String to Int conversion - by SPACoD - 07-20-2012, 11:53 AM
RE: [Help] String to Int conversion - by Traggey - 07-20-2012, 11:32 AM



Users browsing this thread: 3 Guest(s)