SA-MP Forums Archive
Offline set admin [YSI] - 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)
+--- Thread: Offline set admin [YSI] (/showthread.php?tid=659542)



Offline set admin [YSI] - MIDO007 - 06.10.2018

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?


Re: Offline set admin [YSI] - MIDO007 - 06.10.2018

Hello any one help me?


Re: Offline set admin [YSI] - bigtigerbeee - 06.10.2018

then read his data before set


Re: Offline set admin [YSI] - MIDO007 - 06.10.2018

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


Re: Offline set admin [YSI] - Leaky - 06.10.2018

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.


Re: Offline set admin [YSI] - Jefff - 07.10.2018

You need use INI_ParseFile


Re: Offline set admin [YSI] - GameOvr - 07.10.2018

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


Re: Offline set admin [YSI] - MIDO007 - 07.10.2018

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



Re: Offline set admin [YSI] - Beckett - 07.10.2018

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.


Re: Offline set admin [YSI] - Calisthenics - 08.10.2018

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.