I didn't get you well but did you try saving in a file? and when the server runs again it reads from the file and generates.
|
#define CmdsPath "TDM/Commands/%s.ini"
enum CommandInfo
{
MakeadminCmd,
KickCmd,
BanCmd,
}
new cInfo[CommandInfo];
stock CmdPath()
{
new str[150];
format(str, sizeof(str), CmdsPath, "Commands");
return str;
}
public OnGameModeExit()
{
new INI:file = INI_Open(CmdPath());
INI_SetTag(file, "Enable/Disable Command:");
INI_WriteInt(file, "Makeadmin", cInfo[MakeadminCmd]);
INI_WriteInt(file, "Ban", cInfo[BanCmd]);
INI_WriteInt(file, "Kick", cInfo[KickCmd]);
INI_Close(file);
return 1;
}
Okay, let me know if i am doing right.
Top: pawn Код:
pawn Код:
pawn Код:
|
new File:ffile; new filepath[128]; new string[128]; format(filepath,sizeof(filepath),"%s.txt",filename); ffile = fopen(filepath,io_append); format(string,sizeof(string)," %s\r\n",text); fwrite(ffile,string); fclose(ffile); return 1;
#define CmdsPath "TDM/Commands/%s.ini"
#define DIALOG_SETCMD 2
enum CommandInfo
{
MakeadminCmd,
KickCmd,
BanCmd,
}
new cInfo[CommandInfo];
new CmdMakeadmin = 3;
new CmdKick = 4;
new CmdBan = 5;
stock CmdPath()
{
new str[150];
format(str, sizeof(str), CmdsPath, "Commands");
return str;
}
forward loadcommands(name[], value[]);
public loadcommands(name[], value[])
{
INI_Int("Makeadmin", cInfo[MakeadminCmd]);
INI_Int("Ban", cInfo[BanCmd]);
INI_Int("Kick", cInfo[KickCmd]);
return 1;
}
if(fexist(CmdsPath))
{
INI_ParseFile(CmdsPath, "loadcommands", .bExtra = true);
}
else
new INI:file = INI_Open(CmdPath());
INI_SetTag(file, "Enable/Disable Command:");
INI_WriteInt(file, "Makeadmin", cInfo[MakeadminCmd], 0);
INI_WriteInt(file, "Ban", cInfo[BanCmd], 0);
INI_WriteInt(file, "Kick", cInfo[KickCmd], 0);
INI_Close(file);
new INI:file = INI_Open(CmdPath());
INI_SetTag(file, "Enable/Disable Command:");
INI_WriteInt(file, "Makeadmin", cInfo[MakeadminCmd]);
INI_WriteInt(file, "Ban", cInfo[BanCmd]);
INI_WriteInt(file, "Kick", cInfo[KickCmd]);
INI_Close(file);
if(dialogid == DIALOG_SETCMD)
{
if(!response)return 0;
if(response)
{
if(listitem == 0)return ShowPlayerDialog(playerid, CmdMakeadmin, DIALOG_STYLE_MSGBOX, "Command: /Makeadmin", "To enable this command, click 'Enable'\nTo disable it, click 'Disable'", "Enable", "Disable");
if(listitem == 1)return ShowPlayerDialog(playerid, CmdKick, DIALOG_STYLE_MSGBOX, "Command: /Kick", "To enable this command, click 'Enable'\nTo disable it, click 'Disable'", "Enable", "Disable");
if(listitem == 2)return ShowPlayerDialog(playerid, CmdBan, DIALOG_STYLE_MSGBOX, "Command: /Ban", "To enable this command, click 'Enable'\nTo disable it, click 'Disable'", "Enable", "Disable");
}
}
if(dialogid == CmdMakeadmin)
{
if(!response)
{
cInfo[MakeadminCmd] = 0;
GameTextForPlayer(playerid, "~y~/Makeadmin ~w~command has been ~r~disabled", 3000, 5);
}
if(response)
{
cInfo[MakeadminCmd] = 1;
GameTextForPlayer(playerid, "~y~/Makeadmin ~w~command has been ~g~enabled", 3000, 5);
}
}
if(dialogid == CmdKick)
{
if(!response)
{
cInfo[KickCmd] = 0;
GameTextForPlayer(playerid, "~y~/Kick ~w~command has been ~r~disabled", 3000, 5);
}
if(response)
{
cInfo[KickCmd] = 1;
GameTextForPlayer(playerid, "~y~/Kick ~w~command has been ~g~enabled", 3000, 5);
}
}
if(dialogid == CmdBan)
{
if(!response)
{
cInfo[BanCmd] = 0;
GameTextForPlayer(playerid, "~y~/Ban ~w~command has been ~r~disabled", 3000, 5);
}
if(response)
{
cInfo[BanCmd] = 1;
GameTextForPlayer(playerid, "~y~/Ban ~w~command has been ~g~enabled", 3000, 5);
}
}
if(cInfo[MakeadminCmd] == 0)return SendClientMessage(playerid, RED, "[SERVER]: This command is disabled !");
if(cInfo[KickCmd] == 0)return SendClientMessage(playerid, RED, "[SERVER]: This command is disabled !");
if(cInfo[BanCmd] == 0)return SendClientMessage(playerid, RED, "[SERVER]: This command is disabled !");
/disablekickcommand
{
Commandkick = 0; //You sir, this is what you call a variable.
//Now add your INI_Write function here with the current variable.
return 1;
}