Question reading Ummu info

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
10,538
Reaction score
4,369
Points
203
Location
Dallas, TX
I want to read what ID the Ummu has and if "Capt" then do something. Not sure on how to read the MiscID?

Code:
char*
if ((Crew.GetCrewMiscIdByName(char*CrewName))=="Capt");	i3=1

here is from the UMMUsdk.h
char* GetCrewMiscIdByName(char*CrewName); // return: Empty string on error or MiscID (a-z A-Z 0-9 characters only)
 
Code:
if(_stricmp(Crew.GetCrewMiscIdByName(/*YouMustgiveaNameHere*/),"Capt")==0)
{
// do somethings

}
Best

Dan
 
The key thing to remember when dealing with string variables in C++ is that they are pointers, so you cannot test for string equality just by using "==" because each pointer points to a different address in memory, and so unless the pointers themselves match the "==" test will return false. What you have to do is compare the contents of each string and see if they match. As tricky as it may seem, understanding how pointers work is absolutely critical to learning C++, so I highly recommend working through a good C++ book to learn exactly how pointers work -- otherwise much of the language won't make sense. Personally I recommend [ame="http://www.amazon.com/How-Program-7th-Paul-Deitel/dp/0136117260/ref=sr_1_3?ie=UTF8&s=books&qid=1257478156&sr=8-3"]C++ How to Program[/ame].

Now, to answer your question, as I said you need to compare the contents of each string and see if they match:

Code:
// this assumes 'pName' points to a valid crew member name
const char *pMiscID = Crew.GetCrewMiscIdByName(pName);
if (strcmp(pMiscID, "Capt") == 0)
{
    // this is the captain ....
}
What strcmp does is compare the bytes pointed to by each pointer. If the strings are identical, the function returns zero.

EDIT:
Dan beat me to it. :) If you want a case-insensitive comparison instead of a case-sensitive one, you should use _stricmp as Dan showed. Thinking about it, it probably is better to do a case-insensitive check on UMMu misc IDs...
 
Thanks. I think I got it. There is just 1 slot. So it is slot0. I am getting the ID of the crew person and if it is Capt then add mesh

if ((Crew.GetCrewMiscIdBySlotNumber(0))=="Capt")SetMeshVisibilityMode( 2, MESHVIS_ALWAYS );
else SetMeshVisibilityMode( 2, MESHVIS_NEVER ); // return: Empty string on error or MiscID
 
if ((Crew.GetCrewMiscIdBySlotNumber(0))=="Capt")SetMeshVisibilityMode( 2, MESHVIS_ALWAYS );
else SetMeshVisibilityMode( 2, MESHVIS_NEVER ); // return: Empty string on error or MiscID

That won't work -- remember, you cannot use "==" to compare two strings. You need to use _stricmp or strcmp instead.
 
Thanks
This works fine:
Code:
if (strcmp(p1MiscID, "Capt") == 0)
{
SetMeshVisibilityMode( 2, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( 2, MESHVIS_NEVER ); 
const char *p2MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p2MiscID, "Ast") == 0)
{
SetMeshVisibilityMode( 1, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( 1, MESHVIS_NEVER );
 
Take care a "Sci" type (scientific) or any other type (Doc, Vip etc) would never show with your code. Just catch the captain and consider all other as astronauts.

Dan
 
Thanks. I actually have this for all of them I just show a snippet.

This is for the Space 1999 buggy. I may repaint it white and put a nasa logo on it.
 
Last edited:
Okay, then remember to have also a "else" choice because misc id are not limited to the list, if someone want to enter "ZTR" he can. (in this case display a white spacesuit)
 
I thought I had this down. here is where the meshes are defined. the first is the vessel the rest the sitting ummus.
Code:
// visual specs
BUG = AddMesh (oapiLoadMeshGlobal ("NASABUGGY1"));
SetMeshVisibilityMode (BUG, MESHVIS_ALWAYS);

BUG1 = AddMesh (oapiLoadMeshGlobal ("UmmuBug1"));
SetMeshVisibilityMode (BUG1, MESHVIS_NEVER);

BUG2 = AddMesh (oapiLoadMeshGlobal ("UmmuBug1P"));
SetMeshVisibilityMode (BUG2, MESHVIS_NEVER);

BUG3 = AddMesh (oapiLoadMeshGlobal ("UmmuBug1SEC"));
SetMeshVisibilityMode (BUG3, MESHVIS_NEVER);

BUG4 = AddMesh (oapiLoadMeshGlobal ("UmmuBug1VIP"));
SetMeshVisibilityMode (BUG4, MESHVIS_NEVER);

BUG5 = AddMesh (oapiLoadMeshGlobal ("UmmuBug1MED"));
SetMeshVisibilityMode (BUG5, MESHVIS_NEVER);

BUG6 = AddMesh (oapiLoadMeshGlobal ("UmmuBug1SCI"));
SetMeshVisibilityMode (BUG6, MESHVIS_NEVER);

BUG7 = AddMesh (oapiLoadMeshGlobal ("UmmuBug1TECH"));
SetMeshVisibilityMode (BUG7, MESHVIS_NEVER);

Then we check to see which Ummu is aboard and then make that mesh appear else it is not seen.

Code:
{
const char *pMiscID = Crew.GetCrewMiscIdBySlotNumber(0);
if (strcmp(pMiscID, "") == 0)
{
SetMeshVisibilityMode( BUG1, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG1, MESHVIS_NEVER ); 	// return: Empty string on error or MiscID
const char *p1MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p1MiscID, "Capt") == 0)
{
SetMeshVisibilityMode( BUG2, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG2, MESHVIS_NEVER ); 
const char *p2MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p2MiscID, "Ast") == 0)
{
SetMeshVisibilityMode( BUG1, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG1, MESHVIS_NEVER ); 

const char *p3MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p3MiscID, "Sec") == 0)
{
SetMeshVisibilityMode( BUG3, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG3, MESHVIS_NEVER ); 
const char *p4MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p4MiscID, "Vip") == 0)
{
SetMeshVisibilityMode( BUG4, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG4, MESHVIS_NEVER ); 
const char *p5MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p5MiscID, "Sci") == 0)
{
SetMeshVisibilityMode( BUG6, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG6, MESHVIS_NEVER ); 
const char *p6MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p6MiscID, "Med") == 0)
{
SetMeshVisibilityMode( BUG5, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG5, MESHVIS_NEVER ); 

const char *p7MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p7MiscID, "Bio") == 0)
{
SetMeshVisibilityMode( BUG6, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG6, MESHVIS_NEVER );

const char *p8MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p8MiscID, "Doc") == 0)
{
SetMeshVisibilityMode( BUG5, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG5, MESHVIS_NEVER );

const char *p9MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p9MiscID, "Geo") == 0)
{
SetMeshVisibilityMode( BUG6, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG6, MESHVIS_NEVER );

const char *p10MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p10MiscID, "Exo") == 0)
{
SetMeshVisibilityMode( BUG6, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG6, MESHVIS_NEVER );

const char *p11MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p11MiscID, "Clim") == 0)
{
SetMeshVisibilityMode( BUG6, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG6, MESHVIS_NEVER );

const char *p12MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p12MiscID, "APhy") == 0)
{
SetMeshVisibilityMode( BUG6, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG6, MESHVIS_NEVER );

const char *p13MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p13MiscID, "Chem") == 0)
{
SetMeshVisibilityMode( BUG6, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG6, MESHVIS_NEVER );

const char *p14MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p14MiscID, "Eng") == 0)
{
SetMeshVisibilityMode( BUG7, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG7, MESHVIS_NEVER );

const char *p15MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p15MiscID, "Min") == 0)
{
SetMeshVisibilityMode( BUG7, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG7, MESHVIS_NEVER );

const char *p16MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p16MiscID, "Tech") == 0)
{
SetMeshVisibilityMode( BUG7, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG7, MESHVIS_NEVER );

const char *p17MiscID = Crew.GetCrewMiscIdBySlotNumber(0);

if (strcmp(p17MiscID, "Spe") == 0)
{
SetMeshVisibilityMode( BUG7, MESHVIS_ALWAYS ); 
}
else  SetMeshVisibilityMode( BUG7, MESHVIS_NEVER );
}


All but the BUG7 ones appear. The mesh is good as I have tried in in another setting. But if the BUG7 mesh is to appear it doesn't. And it only appears if the MiscID ="Spe". if the MiscId ="Eng", "Min", and/or "Tech" then no mesh.
 
Last edited:
Back
Top