How do i read something inside a file using Y_INi -
Immortal99 - 20.05.2017
How do I read something inside a .ini file example:
PHP код:
#define CLAN_TAG_MEMBERS "ClanMembers/%.ini"
PHP код:
public OnPlayerSpawn(playerid)
{
If(strfind(playername, "[Look]", true) != 0) // this will check if the player has [Look] infront of there name and inside the .ini file is 0 his not clan tag member it will kick the player
if(fexist(Folder(playerid)))
{
new INI:file = INI_Open(Folder(playerid));
// NOW HERE HOW DO I CHECK IF THE PLAYER Really has 0 in there ini file?
}
Custom Function:
PHP код:
Folder(playerid)
{
New string[128], playername[MAX_PLAYER_NAME];
format(string, sizeof(string), CLAN_TAG_MEMBERS, playername);
return string;
}
Re: How do i read something inside a file using Y_INi -
coool - 20.05.2017
Код:
INI_Int("IsMember",IsMember[playerid]);
By the way, just make an array and store the name of guys that are in a clan. And check from it when some one connects, It can also be managed in game but won't be saved.
Re: How do i read something inside a file using Y_INi -
Immortal99 - 20.05.2017
Im already doing that tha ks
Re: How do i read something inside a file using Y_INi -
Immortal99 - 20.05.2017
Heres some things i missed out
Enum PlayerData
{
ClanMember
}
New player[MAX_PLAYERS][PlayerData]
Re: How do i read something inside a file using Y_INi -
Immortal99 - 20.05.2017
Wait, let me start from the beginning, I just got on the PC, so heres my defines and enums:
PHP код:
#define CLAN_TAG_MEMBERS "ClanMembers/%s.ini"
PHP код:
enum PlayerData
{
ClanMember
}
new Player[MAX_PLAYERS][PlayerData];
PHP код:
public OnPlayerConnect(playerid)
{
if(fexist(Folder(playerid)))
{
INI_ParseFile(Folder(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
}
else
{
new INI:file = INI_Open(Folder(playerid));
INI_WriteInt(file, "ClanMember", Player[playerid][ClanMember]);
INI_ParseFile(Folder(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
INI_Close(file);
}
return 1;
}
PHP код:
public OnPlayerSpawn(playerid)
{
new playername[64];
GetPlayerName(playerid,playername, MAX_PLAYER_NAME);
if(strfind(playername,""SERVER_CLAN_TAG"",true) != 0)
{
if(fexist(Folder(playerid)))
{
new INI:file = INI_Open(Folder(playerid));
// IDK WHAT TO DO HERE!
return 1;
}
}
return 1;
}
PHP код:
Folder(playerid)
{
new string[128],playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,sizeof(playername));
format(string,sizeof(string),CLAN_TAG_MEMBERS,playername);
return string;
}
Re: How do i read something inside a file using Y_INi -
Logic_ - 20.05.2017
I'd suggest you to learn MySQL, It's way easier than everyone thinks.
Re: How do i read something inside a file using Y_INi -
Immortal99 - 20.05.2017
Sure, I will, help me instead
Re: How do i read something inside a file using Y_INi -
coool - 20.05.2017
You may not need it under 'OnPlayerSpawn'. Why are you loading user in both cases when player's file exist, and when it doesn't exist.
By the way locate your loading function or loading code and place there in this
[CODE]INI_Int("IsMember",Player[playerid][ClanMember]);
//Now you are all set just use your variable when you want to check if someone is in clan or not[CODE]
Re: How do i read something inside a file using Y_INi -
Immortal99 - 20.05.2017
Error:
PHP код:
filterscripts\ClanTagSystem.pwn(66) : error 017: undefined symbol "name"
filterscripts\ClanTagSystem.pwn(66) : error 017: undefined symbol "value"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Errors.
Line:
66:
PHP код:
INI_Int("ClanMember", Player[playerid][ClanMember]);