string variables are not working in my game?
string variables are not working in my game?
string variables are not working in my game?
I am using namespace std; and including <iostream> but this error comes up: `string' does not name a type
thanks in advance
I am using namespace std; and including <iostream> but this error comes up: `string' does not name a type
thanks in advance
For optimal assistance for your problem, it would be helpful for you to post your code here, or at least an abbreviated version which illustrates the problem lines. Without code, we can only make guesses as what is actually happening.
Also, is there any reason why you need to use the standard strings as opposed to irrlicht strings (check the core namespace in the docs)?
Also, is there any reason why you need to use the standard strings as opposed to irrlicht strings (check the core namespace in the docs)?
I was using the standard C++ string.
there's the code up to the error.
I hope that helps.
#include <irrlicht.h>
#include <iostream>
#include <string>
#include <sstream>
#include <zoidcom.h>
#include <stdlib.h>
#include <stdio.h>
#include <zoidcom.h>
#include <irrKlang.h>
#include <fstream.h>
#include <windows.h>
#include <gl/gl.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace std;
//# include <SDL/SDL.h>
//# include <SDL/SDL_mixer.h> dosent exist
//
// the client class
//
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
#include "other.cpp"
LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC);
void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC);
int e,a;
int start = 0;
string s; <- there is the error
there's the code up to the error.
I hope that helps.
#include <irrlicht.h>
#include <iostream>
#include <string>
#include <sstream>
#include <zoidcom.h>
#include <stdlib.h>
#include <stdio.h>
#include <zoidcom.h>
#include <irrKlang.h>
#include <fstream.h>
#include <windows.h>
#include <gl/gl.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
using namespace std;
//# include <SDL/SDL.h>
//# include <SDL/SDL_mixer.h> dosent exist
//
// the client class
//
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
#include "other.cpp"
LRESULT CALLBACK WndProc (HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC);
void DisableOpenGL (HWND hWnd, HDC hDC, HGLRC hRC);
int e,a;
int start = 0;
string s; <- there is the error
"string" is defined in both the irrlicht namespace irr::core:: and the std:: namespace, causing an ambiguous symbol error. You need to not use either the "core" namespace or the "std" namespace. My recommendation is to drop the std namespace and just go with irrlicht strings.
Also, you're including "zoidcom.h" twice .
Also, you're including "zoidcom.h" twice .
I'm basically wanting to read files and write files.
I need to read and write files in my game for two reasons.
1. I will need some way of storing data like player health, weapons, e.g.
2. Because the game is a online rpg I need to transfer data but the game would pause while transferring data. I thought easy way fix that would be to make a another program to download the data and write the data to a text document. Then the game would read that file quickly and not pause. It's quicker to read from a text document than with the internet.
thanks
I need to read and write files in my game for two reasons.
1. I will need some way of storing data like player health, weapons, e.g.
2. Because the game is a online rpg I need to transfer data but the game would pause while transferring data. I thought easy way fix that would be to make a another program to download the data and write the data to a text document. Then the game would read that file quickly and not pause. It's quicker to read from a text document than with the internet.
thanks
Well there's two options i guess. You can either come up with your own format, something like a text file containing the following:
Player 1
100
Axe
Sword
Which is of the format
Player name
Player Health
Weapon 1
Weapon 2
...
Weapon N
Or you could look into using irrlichts XML reader/writer, which would be much easier for you. If you look at the MeshViewer example there's a nice snippet for reading in XML files which should be clear how you can adapt it to the data you require to be stored, writing out the XML is done pretty similarly and can be read about in the API or feel free to ask again when you get to that stage!
Player 1
100
Axe
Sword
Which is of the format
Player name
Player Health
Weapon 1
Weapon 2
...
Weapon N
Or you could look into using irrlichts XML reader/writer, which would be much easier for you. If you look at the MeshViewer example there's a nice snippet for reading in XML files which should be clear how you can adapt it to the data you require to be stored, writing out the XML is done pretty similarly and can be read about in the API or feel free to ask again when you get to that stage!
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
You may want to revisit your assumptions.Jim121 wrote:I'm basically wanting to read files and write files.
I need to read and write files in my game for two reasons.
1. I will need some way of storing data like player health, weapons, e.g.
2. Because the game is a online rpg I need to transfer data but the game would pause while transferring data. I thought easy way fix that would be to make a another program to download the data and write the data to a text document. Then the game would read that file quickly and not pause. It's quicker to read from a text document than with the internet.
thanks
What will "pause" while transferring data? The server? The client?
Why would either of them "pause" while doing this? All (real time) games use either non-blocking sockets or threaded blocking sockets. Your main thread should never get blocked.
What you seem to be proposing is a horribly inefficient version of IPC when there's no need for it.
If you use a decent network library like Raknet then it will take care of sending and receiving available network data for you.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
-
- Posts: 368
- Joined: Tue Aug 21, 2007 1:43 am
- Location: The Middle of Nowhere
Why don't you use threads...
Threading allows you to run multiple chunks of code simultaneously, meaning that if you have a file loader (or network handler) in a separate thread and have it take the time it needs without causing the rest of your program to cease functioning.
Threading allows you to run multiple chunks of code simultaneously, meaning that if you have a file loader (or network handler) in a separate thread and have it take the time it needs without causing the rest of your program to cease functioning.
rogerborg wrote:Every time someone learns to use a debugger, an angel gets their wings.