I need a function Read .ini files
#1

I need a function INI_Get

Something like this: Ex:
pawn Код:
public OnPlayerConnect(playerid)
{
    new string[128];
    format(string,sizeof(string),"/Users/%s.ini",GetName(playerid));
    PlayerInfo[playerid][Admin] = INI_Get(string,"Admin");
    return 1;
}
I use y_ini
Reply
#2

If you want this then use it :: it will allow to load user ini file, Create a stock loaduser_data , about it you can simply check on wiki , that how to use it , btw there you can get all types of y-ini usage ... I think there u will get your problems solution...
Reply
#3

Yeah I made this
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",pInfo[playerid][Pass]);
    INI_Int("WazzAdmin",pInfo[playerid][WazzAdmLevel]);
    INI_Int("WazzVip",pInfo[playerid][WazzVIPLevel]);
    INI_Int("Warn",pInfo[playerid][Warn]);
    INI_Int("Banned",pInfo[playerid][Banned]);
    INI_Int("Freeze",pInfo[playerid][Freeze]);
    INI_Int("Cash",pInfo[playerid][Cash]);
    INI_Int("Kills",pInfo[playerid][Kills]);
    INI_Int("Deaths",pInfo[playerid][Deaths]);
    return 1;
}
Reply
#4

Yes it can load your ini system , but you also need to use prase ini to use it.
Reply
#5

But i need some thing like OnPlayerConnect if INI_Get UserPath Banned == 1 then Kick(playerid);
Reply
#6

Can you make the exemple? I need this too
Reply
#7

Bump...
Reply
#8

Quote:
Originally Posted by xganyx
Посмотреть сообщение
Yeah I made this
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",pInfo[playerid][Pass]);
    INI_Int("WazzAdmin",pInfo[playerid][WazzAdmLevel]);
    INI_Int("WazzVip",pInfo[playerid][WazzVIPLevel]);
    INI_Int("Warn",pInfo[playerid][Warn]);
    INI_Int("Banned",pInfo[playerid][Banned]);
    INI_Int("Freeze",pInfo[playerid][Freeze]);
    INI_Int("Cash",pInfo[playerid][Cash]);
    INI_Int("Kills",pInfo[playerid][Kills]);
    INI_Int("Deaths",pInfo[playerid][Deaths]);
    return 1;
}
This initializes the items in the player's .ini file under the "data" tag ( "[data]" ) into the player's pInfo variable. That is the function of INI_Int, INI_String, etc.. It takes the item in the player account file and put it into the player's pInfo variable. So all you need to do now is make sure this code is put in OnPlayerConnect:

pawn Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
Next, you can use it after the line such as:

pawn Код:
if ( pInfo[playerid][Banned] == 1 ) return Kick(playerid);
So your full code should be something like this:

pawn Код:
public OnPlayerConnect(playerid)
{
    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid) // Load all the playerid's data into that playerid's pInfo. This line will jump into every "LoadUser_%s" function such as your "LoadUser_data" in my quote above. (%s is the TAG, so "LoadUser_data" means it will load the data under "[data]" tag in that player's file only.)
    if ( pInfo[playerid][Banned] == 1 ) return Kick(playerid); // If in his .ini file, the full line of "Banned =" under the "[data]" tag is "Banned = 1", so we kick him.

    return 1;
}
Reply
#9

Thank you so much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)