SA-MP Forums Archive
need help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: need help (/showthread.php?tid=133408)



need help - aircombat - 12.03.2010

i am creating a vip system which all users should save to scriptfiles/vip but the problem is players join and no files get created in the folder , here is the code :
Код:
public OnPlayerConnect(playerid)
{
  new file[100];
	new Name[MAX_PLAYER_NAME];
	new Ip[16];
	GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  if(!dini_Exists(file)) {
		dini_Create(file);
		dini_Set(file,"Name",Name);
		dini_Set(file,"Ip",Ip);
		dini_IntSet(file,"VIP",0);
		}
  strcat(PlayerInfo[playerid][PName],					dini_Get(file,"Name"));
	strcat(PlayerInfo[playerid][Pip],					dini_Get(file,"Ip"));
	PlayerInfo[playerid][VIP] 			   = dini_Int(file,"VIP");
	return 1;
	}



Re: need help - lameguy - 12.03.2010

Quote:
Originally Posted by [AC
Etch ]
i am creating a vip system which all users should save to scriptfiles/vip but the problem is players join and no files get created in the folder , here is the code :
Код:
public OnPlayerConnect(playerid)
{
  new file[100];
	new Name[MAX_PLAYER_NAME];
	new Ip[16];
	GetPlayerName(playerid,Name,sizeof(Name)); GetPlayerIp(playerid,Ip,sizeof(Ip)); format(file,sizeof(file),PlayerFile,Name);
  if(!dini_Exists(file)) {
		dini_Create(file);
		dini_Set(file,"Name",Name);
		dini_Set(file,"Ip",Ip);
		dini_IntSet(file,"VIP",0);
		}
  strcat(PlayerInfo[playerid][PName],					dini_Get(file,"Name"));
	strcat(PlayerInfo[playerid][Pip],					dini_Get(file,"Ip"));
	PlayerInfo[playerid][VIP] 			   = dini_Int(file,"VIP");
	return 1;
	}
You don't define file path on your file string.
You have it now
Код:
format(file, sizeof(file), PlayerFile, Name);
You should use like.
Код:
format(file, sizeof(file), "vip/%s.ini", Name);
This code would create file named by players name in folder \..\scriptfiles\vip\


Re: need help - aircombat - 12.03.2010

i already defined it : #define PlayerFile "VIP/%s.ini"


Re: need help - lameguy - 12.03.2010

Quote:

format(file,sizeof(file),PlayerFile,Name);

I'm not sure if you can do it like that.
If you want to use defined value, you could define it like
#define PlayerFile "VIP/"

and use
pawn Код:
format(file, sizeof(file), "%s%s", PlayerFile, Name);



Re: need help - aircombat - 12.03.2010

still not working


Re: need help - lameguy - 12.03.2010

Well i coded it again and now it works.
pawn Код:
#define UserPath "VIP"
pawn Код:
public OnPlayerConnect(playerid)
{
  new FilePath[32];
  new Ip[16];
  GetPlayerIp(playerid,Ip,sizeof(Ip));

  format(FilePath, sizeof(FilePath), "%s/%s.ini", UserPath, PlayerName(playerid));
  if(!dini_Exists(FilePath)) {
    dini_Create(FilePath);
    dini_Set(FilePath, "Name", PlayerName(playerid));
    dini_Set(FilePath, "Ip", Ip);
    dini_IntSet(FilePath, "VIP", 0);
  }
  return 1;
}
You will also need this stock for that.
Using stock when you need to get players name is much easier than using GetPlayerName.
pawn Код:
stock PlayerName(playerid) {
  new name[MAX_PLAYER_NAME];
  GetPlayerName(playerid, name, sizeof(name));
  return name;
}



Re: need help - aircombat - 12.03.2010

appreciate ur help but still doesnt work

Код:
public OnPlayerConnect(playerid)
{
  new FilePath[32];
  new Ip[16];
  GetPlayerIp(playerid,Ip,sizeof(Ip));

  format(FilePath, sizeof(FilePath), "%s/%s.ini", UserPath, PlayerName(playerid));
  if(!dini_Exists(FilePath)) {
    dini_Create(FilePath);
    dini_Set(FilePath, "Name", PlayerName(playerid));
    dini_Set(FilePath, "Ip", Ip);
    dini_IntSet(FilePath, "VIP", 0);
  }
  return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
  new FilePath[32];
  new Ip[16];
  format(FilePath, sizeof(FilePath), "%s/%s.ini", UserPath, PlayerName(playerid));
	dini_Set(FilePath, "Name", PlayerName(playerid));
  dini_Set(FilePath, "Ip", Ip);
  dini_IntSet(FilePath, "VIP", 0);

	return 1;
}



Re: need help - lameguy - 12.03.2010

what are you actually looking for?
That creates file named by connecter's name, and adds the other stuff to file. I tested


Re: need help - aircombat - 12.03.2010

then why it doesnt work in my server?


Re: need help - SlashPT - 12.03.2010

i believe because you dont have the folder with the same name on scriptfiles i think its Case Sensitive and sould have the folder OFC!!

btw you can test via just

Код:
%s