Raised This Month: $ Target: $400
 0% 

Simply: needing 2 things into vars and dont get it!


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
XCoder
Member
Join Date: Mar 2006
Location: Worldwide
Old 05-02-2010 , 06:51   Simply: needing 2 things into vars and dont get it!
Reply With Quote #1

Hello Guys,

I'll hope someone of the AMXMODX Heros can help me.

Following, i'm learning amxmodx and at the moment i'm trying to get 2 vars out of a txt file, (mymaps.txt)

Following is inside:
Code:
mario_air		"\minplayers\5\maxplayers\32\"
mario_land		"\minplayers\4\maxplayers\32\"
mario_world		"\minplayers\8\maxplayers\32\"
mario_xmas		"\minplayers\4\maxplayers\32\"
My Problem is now that i need the the two numbers:
"\minplayers\5\maxplayers\32\"

The Code-Part for it: (mapchooser like)
Code:
new fp=fopen(filename,"r");
	
	while (!feof(fp))
	{
		buff[0]='^0';
		
		fgets(fp, buff, charsof(buff));
		
		parse(buff, szText, charsof(szText));
		
		
		
		if (szText[0] != ';' &&
			ValidMap(szText) &&
			!equali(szText, g_lastMap) &&
			!equali(szText, currentMap))
		{
			ArrayPushString(g_mapName, szText);
			++g_mapNums;
		}
		
	}
	
	fclose(fp);
The ValidMap() is at the moment the standard of mapchooser.amxx

Code:
stock bool:ValidMap(mapname[])
{
	if ( is_map_valid(mapname) )
	{
		return true;
	}
	// If the is_map_valid check failed, check the end of the string
	new len = strlen(mapname) - 4;
	
	// The mapname was too short to possibly house the .bsp extension
	if (len < 0)
	{
		return false;
	}
	
	// HERE SHOULD MY ADDING GOES.....
	if (-------------------)
	{
		return false;
	}
	
	if ( equali(mapname[len], ".bsp") )
	{
		// If the ending was .bsp, then cut it off.
		// the string is byref'ed, so this copies back to the loaded text.
		mapname[len] = '^0';
		
		// recheck
		if ( is_map_valid(mapname) )
		{
			return true;
		}
	}
	
	return false;
}
Above i comment the Part where the code should go.
mapname[len] contains the whole part of the line i hope, so how i can get these two numbers out of mapname[len]?

I realy hope someone can helps me out!

(Sorry for my broken english, ill do my best)

//// ADDED:
Aye..., may i should say what i want to "if" too...
The first Number (minplayers) should go with if(get_playersnum() >= minplayers && maxplayers >= get_playersnum())...
Like this!


Greetings

Last edited by XCoder; 05-02-2010 at 07:02.
XCoder is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode