24.10.2014, 11:25
what's wrong with that code ? ? i see this correctly but it doesn't work
after creating a dutymenu it doesnt save after restart server
after creating a dutymenu it doesnt save after restart server
PHP код:
SaveDutyMenus()
{
for(new i = 1; i < MAX_DUTYMENUS; i++)
{
if(DutyMenuIDTaken[i] == 0) continue;
new file[100];
new var[32];
format(file, sizeof(file), "DutyMenus/%d.ini", i);
if(INI_Open(file))
{
INI_WriteString("DutyMenuCommand", DutyMenuStatistics[i][DutyMenuCommand]);
INI_WriteFloat("DutyMenuX", DutyMenuStatistics[i][DutyMenuX]);
INI_WriteFloat("DutyMenuY", DutyMenuStatistics[i][DutyMenuY]);
INI_WriteFloat("DutyMenuZ", DutyMenuStatistics[i][DutyMenuZ]);
INI_WriteInt("DutyMenuFaction", DutyMenuStatistics[i][DutyMenuFaction]);
for(new g = 0; g < 47; g++)
{
format(var, sizeof(var), "DutyMenuGun%d", g);
INI_WriteInt(var, DutyMenuStatistics[i][DutyMenuGuns][g]);
format(var, sizeof(var), "DutyMenuGunRank%d", g);
INI_WriteInt(var, DutyMenuStatistics[i][DutyMenuGunRank][g]);
}
INI_WriteInt("DutyMenuMask", DutyMenuStatistics[i][DutyMenuMask]);
INI_WriteInt("DutyMenuMaskRank", DutyMenuStatistics[i][DutyMenuMaskRank]);
INI_WriteInt("DutyMenuVirtual", DutyMenuStatistics[i][DutyMenuVirtual]);
INI_Save();
INI_Close();
}
}
return 1;
}
PHP код:
//-----------------------------------------[Duty-Menu system]---------------------//
if(strcmp(cmd, "/dutymenu", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SyntaxMessage(playerid, "/dutymenu [faction] [command name (example: /dutymenu 1 lspd)]");
new factionid = strval(tmp);
if(factionid < 1 || factionid > MAX_FACTIONS + 1) return SendClientMessage(playerid, GREY, "Faction ID must be above 1, and below 10.");
if(DutyMenuIDTaken[factionid]) return SendClientMessage(playerid, GREY, "This faction already has a duty menu.");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SyntaxMessage(playerid, "/dutymenu [faction] [command name (example: /dutymenu 1 lspd)]");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
DutyMenuStatistics[factionid][DutyMenuPickup] = CreateDynamicPickup(1239, 23, x, y, z, GetPlayerVirtualWorld(playerid));
DutyMenuStatistics[factionid][DutyMenuX] = x;
DutyMenuStatistics[factionid][DutyMenuY] = y;
DutyMenuStatistics[factionid][DutyMenuZ] = z;
DutyMenuStatistics[factionid][DutyMenuFaction] = factionid;
DutyMenuStatistics[factionid][DutyMenuVirtual] = GetPlayerVirtualWorld(playerid);
strmid(DutyMenuStatistics[factionid][DutyMenuCommand], tmp, 0, strlen(tmp), 255);
for(new i = 0; i < 47; i++)
{
DutyMenuStatistics[factionid][DutyMenuGuns][i] = 0;
}
DutyMenuIDTaken[factionid] = 1;
format(string, sizeof(string), "Duty Menu created for faction ID %d, use /addgun %d or /deletedutymenu %d.", factionid, factionid, factionid);
SendClientMessage(playerid, LIGHTBLUE, string);
}
return 1;
}
if(strcmp(cmd, "/addmask", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SyntaxMessage(playerid, "/addmask [duty menu ID] [mask rank]");
new factionid = strval(tmp);
if(factionid < 1 || factionid > MAX_FACTIONS + 1) return SendClientMessage(playerid, GREY, "Faction ID must be above 1, and below 10.");
if(!DutyMenuIDTaken[factionid]) return SendClientMessage(playerid, GREY, "This faction doesn't have a duty menu.");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SyntaxMessage(playerid, "/addmask [duty menu ID] [mask rank]");
new rank = strval(tmp);
if(rank < 1 || rank > MAX_RANKS + 1) return SendClientMessage(playerid, GREY, "Invalid rank ID.");
if (DutyMenuStatistics[factionid][DutyMenuMask] == 0)
{
DutyMenuStatistics[factionid][DutyMenuMask] = 1;
DutyMenuStatistics[factionid][DutyMenuMaskRank] = rank;
format(string, sizeof(string), "Mask added to faction %d's duty menu, available for rank %d+.", factionid, rank);
SendClientMessage(playerid, LIGHTBLUE, string);
return 1;
}
else return SendClientMessage(playerid, GREY, "Use /removemask.");
}
return 1;
}
if(strcmp(cmd, "/removemask", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SyntaxMessage(playerid, "/removemask [duty menu ID]");
new factionid = strval(tmp);
if(factionid < 1 || factionid > MAX_FACTIONS + 1) return SendClientMessage(playerid, GREY, "Faction ID must be above 1, and below 10.");
if(!DutyMenuIDTaken[factionid]) return SendClientMessage(playerid, GREY, "This faction doesn't have a duty menu.");
if(DutyMenuStatistics[factionid][DutyMenuMask] == 1)
{
DutyMenuStatistics[factionid][DutyMenuMask] = 0;
DutyMenuStatistics[factionid][DutyMenuMaskRank] = 0;
format(string, sizeof(string), "Mask removed from faction %d's duty menu.", factionid);
SendClientMessage(playerid, LIGHTBLUE, string);
return 1;
}
else return SendClientMessage(playerid, GREY, "This faction doesn't have a mask.");
}
return 1;
}
if(strcmp(cmd, "/addgun", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SyntaxMessage(playerid, "/addgun [duty menu ID] [weapon ID] [rank]");
new factionid = strval(tmp);
if(factionid < 1 || factionid > MAX_FACTIONS + 1) return SendClientMessage(playerid, GREY, "Faction ID must be above 1, and below 10.");
if(!DutyMenuIDTaken[factionid]) return SendClientMessage(playerid, GREY, "This faction doesn't have a duty menu.");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SyntaxMessage(playerid, "/addgun [duty menu ID] [weapon ID] [rank]");
new weaponid = strval(tmp);
if(weaponid < 1 || weaponid == 19 || weaponid == 20 || weaponid == 21 || weaponid > 46) return SendClientMessage(playerid, GREY, "Invalid weapon ID.");
tmp = strtok(cmdtext, idx);
if (!strlen(tmp)) return SyntaxMessage(playerid, "/addgun [duty menu ID] [weapon ID] [rank]");
new rank = strval(tmp);
if (rank < 1 || rank > MAX_RANKS + 1) return SendClientMessage(playerid, GREY, "Invalid rank.");
for(new i = 0; i < 47; i++)
{
if(DutyMenuStatistics[factionid][DutyMenuGuns][i] == 0)
{
DutyMenuStatistics[factionid][DutyMenuGuns][i] = weaponid;
DutyMenuStatistics[factionid][DutyMenuGunRank][i] = rank;
break;
}
}
format(string, sizeof(string), "Weapon %d added to faction %d's duty menu successfully.", weaponid, factionid);
SendClientMessage(playerid, LIGHTBLUE, string);
}
return 1;
}
if(strcmp(cmd, "/deletedutymenu", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
new file[100];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SyntaxMessage(playerid, "/deletedutymenu [factionid]");
new factionid = strval(tmp);
if(factionid < 1 || factionid > MAX_FACTIONS + 1) return SendClientMessage(playerid, GREY, "Faction ID must be above 1, and below 10.");
if(!DutyMenuIDTaken[factionid]) return SendClientMessage(playerid, GREY, "This faction doesn't have a duty menu.");
DutyMenuIDTaken[factionid] = 0;
DestroyDynamicPickup(DutyMenuStatistics[factionid][DutyMenuPickup]);
DutyMenuStatistics[factionid][DutyMenuX] = 0;
DutyMenuStatistics[factionid][DutyMenuY] = 0;
DutyMenuStatistics[factionid][DutyMenuZ] = 0;
DutyMenuStatistics[factionid][DutyMenuFaction] = 0;
for(new i = 0; i < 47; i++)
{
DutyMenuStatistics[factionid][DutyMenuGuns][i] = 0;
DutyMenuStatistics[factionid][DutyMenuGunRank][i] = 0;
}
DutyMenuStatistics[factionid][DutyMenuMask] = 0;
DutyMenuStatistics[factionid][DutyMenuVirtual] = 0;
DutyMenuStatistics[factionid][DutyMenuMaskRank] = 0;
strmid(DutyMenuStatistics[factionid][DutyMenuCommand], "none", 0, strlen("none"), 255);
format(string, sizeof(string), "Faction %d's duty menu was deleted.", factionid);
SendClientMessage(playerid, LIGHTBLUE, string);
format(file, sizeof(file), "DutyMenus/%d.ini", factionid);
if(fexist(file)) fremove(file);
}
return 1;
}
if(strcmp(cmd, "/dutymenuloc", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SyntaxMessage(playerid, "/dutymenuloc [factionid]");
new factionid = strval(tmp);
if(factionid < 1 || factionid > MAX_FACTIONS + 1) return SendClientMessage(playerid, GREY, "Faction ID must be above 1, and below 10.");
if(!DutyMenuIDTaken[factionid]) return SendClientMessage(playerid, GREY, "This faction doesn't have a duty menu.");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
DutyMenuStatistics[factionid][DutyMenuX] = x;
DutyMenuStatistics[factionid][DutyMenuY] = y;
DutyMenuStatistics[factionid][DutyMenuZ] = z;
DutyMenuStatistics[factionid][DutyMenuVirtual] = GetPlayerVirtualWorld(playerid);
DestroyDynamicPickup(DutyMenuStatistics[factionid][DutyMenuPickup]);
DutyMenuStatistics[factionid][DutyMenuPickup] = CreateDynamicPickup(1239, 23, x, y, z, GetPlayerVirtualWorld(playerid));
return 1;
}
return 1;
}
if(strcmp(cmd, "/removegun", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 1337)
{
new guns;
new GunID[47];
new RankID[47];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SyntaxMessage(playerid, "/removegun [duty menu ID] [gun ID]");
new factionid = strval(tmp);
if(factionid < 1 || factionid > MAX_FACTIONS + 1) return SendClientMessage(playerid, GREY, "Faction ID must be above 1, and below 10.");
if(!DutyMenuIDTaken[factionid]) return SendClientMessage(playerid, GREY, "This faction doesn't have a duty menu.");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SyntaxMessage(playerid, "/removegun [duty menu ID] [gun ID]");
new weaponid = strval(tmp);
if(weaponid < 1 || weaponid > 46) return 1;
weaponid -= 1;
DutyMenuStatistics[factionid][DutyMenuGuns][weaponid] = 0;
DutyMenuStatistics[factionid][DutyMenuGunRank][weaponid] = 0;
format(string, sizeof(string), "Weapon %d removed from faction %d's duty menu successfully.", weaponid+1, factionid);
SendClientMessage(playerid, LIGHTBLUE, string);
for(new i = 0; i <= 46; i++)
{
if(DutyMenuStatistics[factionid][DutyMenuGuns][i])
{
GunID[guns] = DutyMenuStatistics[factionid][DutyMenuGuns][i];
RankID[guns] = DutyMenuStatistics[factionid][DutyMenuGunRank][i];
DutyMenuStatistics[factionid][DutyMenuGuns][i] = 0;
DutyMenuStatistics[factionid][DutyMenuGunRank][i] = 0;
guns++;
}
}
for(new i = 0; i <= 46; i++)
{
if(GunID[i])
{
DutyMenuStatistics[factionid][DutyMenuGuns][i] = GunID[i];
}
if(RankID[i])
{
DutyMenuStatistics[factionid][DutyMenuGunRank][i] = RankID[i];
}
}
}
return 1;
}