need help
#1

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;
	}
Reply
#2

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\
Reply
#3

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

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);
Reply
#5

still not working
Reply
#6

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;
}
Reply
#7

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;
}
Reply
#8

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

then why it doesnt work in my server?
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)