Search in a file map?
#1

Hello, is there a way to search for files in scriptfiles.
I made a race system. Now I want a list with all races ingame(/loadrace).
So how can I detect the saved races?
Thanks.
Reply
#2

yea you can use fread (FILE READ)

https://sampwiki.blast.hk/wiki/Fread

That should help you mate!


-Lorenc
Reply
#3

Код:
cmd(listraces, playerid, params[])
{
	new j = 0;
	new filename[64];
	new insert[65];
	new string[128];
	while(ffind("maps/*.txt", filename, sizeof filename, j))
	{
	  format(insert, 65, "|%s", filename);
		for(new x = 0; x < 128; x++)
		{
			if(string[x] != '\0') continue;
			if(strlen(string) + strlen(insert) <= 128)
			{
				strins(string, insert, x);
			}
			else goto add;
		}
		add:
		SendClientMessage(playerid, COLOR_GRAD1, string);
		strdel(string, 0, 128);
		return 1;
	}
	if(strlen(string)) SendClientMessage(playerid, COLOR_GRAD1, string);
}
You need the YSF plugin to use ffind. You also need zcmd. Adjust to your code.
Reply
#4

Quote:
Originally Posted by big comfy couch
Код:
cmd(listraces, playerid, params[])
{
	new j = 0;
	new filename[64];
	new insert[65];
	new string[128];
	while(ffind("maps/*.txt", filename, sizeof filename, j))
	{
	  format(insert, 65, "|%s", filename);
		for(new x = 0; x < 128; x++)
		{
			if(string[x] != '\0') continue;
			if(strlen(string) + strlen(insert) <= 128)
			{
				strins(string, insert, x);
			}
			else goto add;
		}
		add:
		SendClientMessage(playerid, COLOR_GRAD1, string);
		strdel(string, 0, 128);
		return 1;
	}
	if(strlen(string)) SendClientMessage(playerid, COLOR_GRAD1, string);
}
You need the YSF plugin to use ffind. You also need zcmd. Adjust to your code.
You maybe dont need zcmd. You could use DCMD too i think.

Код:
dcmd_listraces(playerid, params[])
{
	new j = 0;
	new filename[64];
	new insert[65];
	new string[128];
	while(ffind("maps/*.txt", filename, sizeof filename, j))
	{
	  format(insert, 65, "|%s", filename);
		for(new x = 0; x < 128; x++)
		{
			if(string[x] != '\0') continue;
			if(strlen(string) + strlen(insert) <= 128)
			{
				strins(string, insert, x);
			}
			else goto add;
		}
		add:
		SendClientMessage(playerid, COLOR_GRAD1, string);
		strdel(string, 0, 128);
		return 1;
	}
	if(strlen(string)) SendClientMessage(playerid, COLOR_GRAD1, string);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)