Offline set admin [YSI]
#1

Before we start thanks for ****** for creating YSI and thanks for creators of ZCMD and SSCANF.

First i have problem with my offline set admin command

Код:
CMD:oadmin(playerid, params[])
{
    new targetname[24], filestring[79], level;
    if (PlayerInfo[playerid][pAdmin] < 7) return 0;
    if(level < 0 || level > 7) return SendClientMessage(playerid, red, "Error: Invailed Admin Level!");
	if(sscanf(params, "s[24]d", targetname, level)) return SendClientMessage(playerid, COLOR_WHITE, "Correct Usage: /oadmin [name] [level]");
    format(filestring, sizeof(filestring), "/PG/Accounts/%s.ini", targetname);
    if(!fexist(filestring)) return SendClientMessage(playerid, red, "Error: Incorrect Account!");
    else
    {
        new INI:File = INI_Open(filestring);
        INI_SetTag(File, "data");
        INI_WriteInt(File, "Admin", level);
        INI_Close(File);
        new done[128];
        format(done, sizeof(done), "You have set %s admin level to %d", targetname, level);
        SendClientMessage(playerid, COLOR_YELLOW, done);
    }
    return 1;
}
When i set some one his level i can set him again with the same level


Can Someone help me?
Reply
#2

Hello any one help me?
Reply
#3

then read his data before set
Reply
#4

What the... What do u mean i need a code like
Код:
if(PlayerInfo[playerid][pAdmin] == level) return SendClientMessage(playerid,-1,"This player already in this level
But i want it on offline system
Reply
#5

Quote:
Originally Posted by MIDO007
Посмотреть сообщение
What the... What do u mean i need a code like
Код:
if(PlayerInfo[playerid][pAdmin] == level) return SendClientMessage(playerid,-1,"This player already in this level
But i want it on offline system
No that is only for checking a player who is ONLINE, u need to make something like Dini_Get but for ini, which will read a offline players data. For Dini is Dini_Get but INI doesn't have it so u would have to make it for yourself, that's the only way i know.
Reply
#6

You need use INI_ParseFile
Reply
#7

Make a global var called
Код:
new lvl;
Then go to ur command and put this under if(!fexist)
Код:
INI_ParseFile(filestring, “lvlcheck”);
Then put this somewhere else

Forward lvlcheck();
Public lvlcheck()
{
     INI_Int("Admin",lvl);
}
Now goto the command again and do what you want like

if(lvl >=.......bla bla bla)

There might be small type errors becuz im in phone i hate
Reply
#8

Thanks alot guys i will REP u all and thanks for Jeff and GaneOvr and i made the system it was

Код:
forward Admin_data(name[], value[]);

public Admin_data(name[], value[])
{
     INI_Int("Admin",lvl);
     return 1;
}

CMD:oadmin(playerid, params[])
{
    new targetname[24], filestring[79], level;
    if (PlayerInfo[playerid][pAdmin] < 7) return 0;
    if(level < 0 || level > 7) return SendClientMessage(playerid, red, "Error: Invailed Admin Level!");
	if(sscanf(params, "s[24]d", targetname, level)) return SendClientMessage(playerid, COLOR_WHITE, "Correct Usage: /oadmin [name] [level]");
    format(filestring, sizeof(filestring), "/PG/Accounts/%s.ini", targetname);
    if(!fexist(filestring)) return SendClientMessage(playerid, red, "Error: Incorrect Account!");
    else
    {
        INI_ParseFile(filestring, "Admin_%s");
        if(lvl == level) return SendClientMessage(playerid,red,"Error: The player already in this level");
		new INI:File = INI_Open(filestring);
        INI_SetTag(File, "data");
        INI_WriteInt(File, "Admin", level);
        INI_Close(File);
        new done[128];
        format(done, sizeof(done), "You have set %s admin level to %d", targetname, level);
        SendClientMessage(playerid, COLOR_YELLOW, done);
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by GameOvr
Посмотреть сообщение
Make a global var called
Код:
new lvl;
Then go to ur command and put this under if(!fexist)
Код:
INI_ParseFile(filestring, “lvlcheck”);
Then put this somewhere else

Forward lvlcheck();
Public lvlcheck()
{
     INI_Int("Admin",lvl);
}
Now goto the command again and do what you want like

if(lvl >=.......bla bla bla)

There might be small type errors becuz im in phone i hate
No, please don't do this.

Simply get the player's admin level from the file and see whether it's equal to the level you're putting or not.
Reply
#10

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
No, please don't do this.

Simply get the player's admin level from the file and see whether it's equal to the level you're putting or not.
It cannot read directly, you need a global variable to store the value from the public function INI_ParseFile is using. His logic is correct.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)