GangsterAngel Posted October 5, 2005 Posted October 5, 2005 U have a small problem. im making a model preview on the player selection window. like the "Build A Jedi" model preview. i have a problem. i dont know how to get the left of '/' to get the model name. thats the only thing stopping my code from working . for example if i have "stormtrooper/default" as the 'Model' Cvar. strrchr(model,'/') would give me '/default' and i need to know what would return "stormtrooper/". Help appreciated.
razorace Posted October 5, 2005 Posted October 5, 2005 char *point = strrchr(model,'/'); point++; //advances to the character after the '/'. point = '\0'; //sets the char to be the end of life special char. //At this point, your 'model' should read "stormtrooper/". I beleive this is how the rest of the code strips the strings like.
GangsterAngel Posted October 6, 2005 Author Posted October 6, 2005 That seems to be returning (null) , thanx anyway though.
GangsterAngel Posted October 6, 2005 Author Posted October 6, 2005 point. and model is the same as the "Model" cvar.
razorace Posted October 6, 2005 Posted October 6, 2005 Point should be null, but model should have been truncated like you wanted.
ensiform Posted October 6, 2005 Posted October 6, 2005 i believe he wants to see what model is not take out model.
razorace Posted October 6, 2005 Posted October 6, 2005 Well, I told him who to do what he asked. Not sure exactly what his current problem is thou.
GangsterAngel Posted October 7, 2005 Author Posted October 7, 2005 i have the skin name, i need the model name. Quote //At this point, your 'model' should read "stormtrooper/". I beleive this is how the rest of the code strips the strings like. thats what i need, i need to get the modelname. but the code dosent seem to be working.
GangsterAngel Posted October 7, 2005 Author Posted October 7, 2005 same as the "Model" cvar. stormtrooper/default
razorace Posted October 7, 2005 Posted October 7, 2005 hmm, could have sworn that that worked. try poking around in the code a bit more. I'm sure it's in there somewhere.
GangsterAngel Posted October 14, 2005 Author Posted October 14, 2005 Got it working. //******************************* strcpy(modelStr,model); if ( ( skins = strchr( modelStr, '/' ) ) == NULL) { skins = "default"; } else { *skins++ = 0; } strcpy(skin,skins); //******************************* http://img299.imageshack.us/img299/513/ingamepreview0po.jpg
razorace Posted October 14, 2005 Posted October 14, 2005 Ah, my bad. I missed the pointer reference when setting the end of file character. IE my sample code should have been.... char *point = strrchr(model,'/'); point++; //advances to the character after the '/'. *point = '\0'; //sets the char to be the end of life special char.' Good job figuring it out.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.