[HELP]: Yini !
#1

Hello SAMP !

I have a problem with loading yini.

I made like this:

pawn Код:
#define CommandsFile "TDM/Commands/EnableCmds.ini"
pawn Код:
enum CommandInfo
{
    MakeadminCmd,
    KickCmd,
    BanCmd,
    WarnCmd,
}
new cInfo[CommandInfo];
pawn Код:
public OnGameModeInit()
{
    if(fexist(CommandsFile))
    {
    INI_Load(CommandsFile);
    }
    else
    {
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "MakeadminCmd", 0);
    INI_WriteInt(file, "KickCmd", 0);
    INI_WriteInt(file, "BanCmd", 0);
    INI_WriteInt(file, "WarnCmd", 0);
    INI_Close(file);
    }
    return 1;
}
pawn Код:
public OnGameModeExit()
{  
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "MakeadminCmd", cInfo[MakeadminCmd]);
    INI_WriteInt(file, "KickCmd", cInfo[KickCmd]);
    INI_WriteInt(file, "BanCmd", cInfo[BanCmd]);
    INI_WriteInt(file, "WarnCmd", cInfo[WarnCmd]);
    INI_Close(file);
    return 1;
}
In every command this:
pawn Код:
if(cInfo[MakeadminCmd] == 0)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This command is {FF0000}disabled {FFFFFF}!"); //MakeadminCmd / BanCmd / WarnCmd / KickCmd
But the problem is, when i restart samp-server.exe are all commands still disabled.
Reply
#2

What is wroted in your ini file? Do you save OnPlayerDisconnect all stuff what is needed?
Reply
#3

Код:
MakeadminCmd = 1
KickCmd = 1
BanCmd = 1
WarnCmd = 1
That write in the file.

OnPlayerDisconnect ? Why do I need it ? This is not for user system, it's for enable/disable commands
Reply
#4

show full command..
Reply
#5

pawn Код:
#define CommandsFile "TDM/Commands/EnableCmds.ini"
pawn Код:
enum CommandInfo
{
    MakeadminCmd,
    KickCmd,
    BanCmd,
    WarnCmd,
}
new cInfo[CommandInfo];
pawn Код:
public OnGameModeInit()
{
    if(fexist(CommandsFile))
    {
    INI_Load(CommandsFile);
    }
    else
    {
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "MakeadminCmd", 0);
    INI_WriteInt(file, "KickCmd", 0);
    INI_WriteInt(file, "BanCmd", 0);
    INI_WriteInt(file, "WarnCmd", 0);
    INI_Close(file);
    }
    return 1;
}
pawn Код:
public OnGameModeExit()
{  
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "MakeadminCmd", cInfo[MakeadminCmd]);
    INI_WriteInt(file, "KickCmd", cInfo[KickCmd]);
    INI_WriteInt(file, "BanCmd", cInfo[BanCmd]);
    INI_WriteInt(file, "WarnCmd", cInfo[WarnCmd]);
    INI_Close(file);
    return 1;
}
pawn Код:
CMD:setcmd(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] < 9)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}You need to be {FF0000}Admin Level 9{FFFFFF}, to use this command !");
    ShowPlayerDialog(playerid, DIALOG_SETCMD, DIALOG_STYLE_LIST, "Enable/Disable Commands", "{0080FF}1. {FFFFFF}- /Makeadmin\n{0080FF}2. {FFFFFF}- /Kick\n{0080FF}3. {FFFFFF}- /Ban\n{0080FF}4. {FFFFFF}- /Warn", "Continue", "Close");
    return 1;
}
OnDialogResponse
pawn Код:
if(dialogid == DIALOG_SETCMD)
    {
    if(!response)return 0;
    if(response)
    {
    if(listitem == 0)return ShowPlayerDialog(playerid, CmdMakeadmin, DIALOG_STYLE_MSGBOX, "{FFFFFF}Command: {0080FF}/Makeadmin", "{FFFFFF}To {008000}enable {FFFFFF}this command, click '{008000}Enable'\n{FFFFFF}To {FF0000}disable {FFFFFF}it, click '{FF0000}Disable{FFFFFF}'", "Enable", "Disable");
    if(listitem == 1)return ShowPlayerDialog(playerid, CmdKick, DIALOG_STYLE_MSGBOX, "{FFFFFF}Command: {0080FF}/Kick", "{FFFFFF}To {008000}enable {FFFFFF}this command, click '{008000}Enable'\n{FFFFFF}To {FF0000}disable {FFFFFF}it, click '{FF0000}Disable{FFFFFF}'", "Enable", "Disable");
    if(listitem == 2)return ShowPlayerDialog(playerid, CmdBan, DIALOG_STYLE_MSGBOX, "{FFFFFF}Command: {0080FF}/Ban", "{FFFFFF}To {008000}enable {FFFFFF}this command, click '{008000}Enable'\n{FFFFFF}To {FF0000}disable {FFFFFF}it, click '{FF0000}Disable{FFFFFF}'", "Enable", "Disable");
    if(listitem == 3)return ShowPlayerDialog(playerid, CmdWarn, DIALOG_STYLE_MSGBOX, "{FFFFFF}Command: {0080FF}/Warn", "{FFFFFF}To {008000}enable {FFFFFF}this command, click '{008000}Enable'\n{FFFFFF}To {FF0000}disable {FFFFFF}it, click '{FF0000}Disable{FFFFFF}'", "Enable", "Disable");
    }
    }
    if(dialogid == CmdMakeadmin)
    {
    if(!response)
    {
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "MakeadminCmd", 0);
    INI_Close(file);
    cInfo[MakeadminCmd] = 0;
    SendAdminGameText("~y~/Makeadmin ~w~command has been ~r~disabled");
    }
    if(response)
    {
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "MakeadminCmd", 1);
    INI_Close(file);
    cInfo[MakeadminCmd] = 1;
    SendAdminGameText("~y~/Makeadmin ~w~command has been ~g~enabled");
    }
    }
    if(dialogid == CmdKick)
    {
    if(!response)
    {
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "KickCmd", 0);
    INI_Close(file);
    cInfo[KickCmd] = 0;
    SendAdminGameText("~y~/Kick ~w~command has been ~r~disabled");
    }
    if(response)
    {
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "KickCmd", 1);
    INI_Close(file);
    cInfo[KickCmd] = 1;
    SendAdminGameText("~y~/Kick ~w~command has been ~g~enabled");
    }
    }
    if(dialogid == CmdBan)
    {
    if(!response)
    {
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "BanCmd", 0);
    INI_Close(file);
    cInfo[BanCmd] = 0;
    SendAdminGameText("~y~/Ban ~w~command has been ~r~disabled");
    }
    if(response)
    {
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "BanCmd", 1);
    INI_Close(file);
    cInfo[BanCmd] = 1;
    SendAdminGameText("~y~/Ban ~w~command has been ~g~enabled");
    }
    }
    if(dialogid == CmdWarn)
    {
    if(!response)
    {
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "WarnCmd", 0);
    INI_Close(file);
    cInfo[WarnCmd] = 0;
    SendAdminGameText("~y~/Warn ~w~command has been ~r~disabled");
    }
    if(response)
    {
    new INI:file = INI_Open(CommandsFile);
    INI_WriteInt(file, "WarnCmd", 1);
    INI_Close(file);
    cInfo[WarnCmd] = 1;
    SendAdminGameText("~y~/Warn ~w~command has been ~g~enabled");
    }
    }
Reply
#6

There is some problem on loading the file. I think it ain't loading it correctly.. make stats cmd to see if it set to 0 when you are spawned... I think it could be set to 0 when you connect.
Reply
#7

Okay, so here is the command:

pawn Код:
CMD:cstats(playerid, params[])
{
    new string[100];
    format(string, sizeof(string), "Makeadmin = %d Kick = %d Ban = %d Warn = %d", cInfo[MakeadminCmd], cInfo[KickCmd], cInfo[BanCmd], cInfo[WarnCmd]);
    SendClientMessage(playerid, -1, string);
    return 1;
}
Results:

In .ini file
With /cstats command
Reply
#8

As I thought.. It sets your scores to 0 so you need to remake all to 1... So what you need to do is to check if file exists...
Reply
#9

What score ? This are commands. 0 = disabled, 1 = enabled lol
Reply
#10

You are saving them right? So if it is saved by 1 to enable.. and 0 to disable of course in game it will show the error. Because it's set as 0...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)