File System
#1

Can someone help me with the file system?

I need it so i can put someones name on it and it lets them spawn as a certain class. But without their name on it they can't use that class. I've searched the WIKI and forums, haven't found anything that was good enough to help me. Thanks.
Reply
#2

*BUMP*
Reply
#3

It would be like this:
The file:
Код:
User1 User2 User3 ... User76
Then you would read it with your script, and if player name is found, he has ability to spawn with a class.
I would do it with these comands

Код:
public OnPlayerConnect(playerid)
{
	new PNameC[MAX_PLAYER_NAME];
	GetPlayerName(playerid,PNameC,sizeof(PNameC));
	new File:cFile = fopen("classfile.ini",io_read);
	//I would read it as text in whole.
	new cStr[1000],cStr2[MAX_PLAYER_NAME+2];
	fread(cFile,cStr,sizeof(cStr));
	format(cStr2,sizeof(cStr2),"i'%s'",PNameC);
	if(!sscanf(cStr,cStr2))
	{
	  //Allow using other skins
	}
	return 1;
}
Now i'll give it a test to see if it works. - It doesn't because it doesn't mind not finding something.

Sorry, it seems that i can't help you.. althought you could use strfind(cStr," User "); But strfind may be slow, and renember that you have to format user's name in spaces, otherwise - one and onetwo will make confusion in script. cause they will be separated by spaces, but you will not be searching " one ", you will search "one" and then onetwo fits!

Код:
	new PNameC[MAX_PLAYER_NAME];
	GetPlayerName(playerid,PNameC,sizeof(PNameC));
	new File:cFile = fopen("classfile.ini",io_read);
	//I would read it as text in whole.
	new cStr[1000],cStr2[MAX_PLAYER_NAME+2];
	fread(cFile,cStr,sizeof(cStr));
	format(cStr2,sizeof(cStr2)," %s ",PNameC);
	SendClientMessage(playerid,0x000000FF,cStr2);
	if(strfind(cStr,cStr2) != -1)
	{
		SendClientMessage(playerid,0x000000FF,"Pass");
	  //Allow using other skins
	}
Works - tested
My classfile.ini:
Код:
 RSX RSX3 VSD RSX2
Reply
#4

How do i add classes to the list. For temp use i have this under OnPlayerRequestSpawn.

Код:
	if(classid == 286)
	{
		if(strcmp( Name, "[HPS]HellBeast", false) == 0)
		{
			return 1;
		}
		else
		{
		  GameTextForPlayer(playerid, "~R~You do not have permissions to use this class!", 5000, 5);
	  	return 0;
		}
	}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)