07.08.2016, 13:11
In my roleplay script i /createorg [Org Name] everything works fine when i create the org.. Here is the code
But when i wanna /request to see the orgs i created i get the error "There are currently no existing organizations" Here is the /request code
PHP Code:
CMD:createorg(playerid, params[])
{
new tmp[256], tmp2[256], string[256], giveplayer[256], moneys1, istr[2][50];
if (adlvl[playerid] < 6) return 0;
if (sscanf(params, "s[128]", tmp)) return SendClientMessage2(playerid, COLOR_WHITE, "Usage: /createorg [name]");
if (strlen(tmp) > 48) return SendClientMessage2(playerid, COLOR_RED, "Organization names must be a maximum of 48 characters.");
new amount = dini_Int(AddDirFile(dir_orgfiles, FILE_OSTATS), "orgs");
if (amount == MAX_ORGS)
{
format(tmp2, sizeof(tmp2), "The number of organizations has reached the limit of %d.", MAX_ORGS);
SendClientMessage2(playerid, COLOR_RED, tmp2);
return 1;
}
new giveplayerid = dini_Int(AddDirFile(dir_orgfiles, FILE_OSTATS), "max_org");
for (new tov = 1; tov <= giveplayerid; tov++)
{
format(string, 10, "org%d", tov);
if (!dini_Exists(AddDirFile(dir_orgfiles, string)))
{
moneys1 = tov;
break;
}
}
if (moneys1 == 0)
{
moneys1 = giveplayerid+1;
dini_IntSet(AddDirFile(dir_orgfiles, FILE_OSTATS), "max_org", moneys1);
}
dini_IntSet(AddDirFile(dir_orgfiles, FILE_OSTATS), "orgs", amount+1);
format(string, 10, "org%d", moneys1);
dini_Create(AddDirFile(dir_orgfiles, string));
dini_Set(AddDirFile(dir_orgfiles, string), "name", tmp);
dini_Set(AddDirFile(dir_orgfiles, string), "leader", "server");
for (new e = 1; e <= MAX_ORG_MEMBERS; e++)
{
format(giveplayer, 12, "members%d", e);
dini_Set(AddDirFile(dir_orgfiles, string), giveplayer, "server");
}
valstr(istr[0], moneys1);
SendPlayerFormattedText(playerid, COLOR_SILVER, "Organization '%s' created (ID = %s)", tmp, istr[0]);
if (DoesPlayerHaveMenuOpen(playerid) == 0 && GetPlayerDialog(playerid) == -1) ShowPlayerDialog2(playerid, DIALOG_ORG_CATS, DIALOG_STYLE_LIST, "Organization catagories", "Law Enforcement\nGang\nPublic Service\nPublic Transport\nPrivate Business\nHitman\nOther", "Select", "Cancel");
orgselectc[playerid] = moneys1;
return 1;
}
PHP Code:
CMD:request(playerid, params[])
{
new tmp[256], tmp2[256], moneys3, stringdata[256];
if (orgReq[playerid] > 0)
{
SendClientMessage2(playerid, COLOR_ORANGE, "You are already requesting to join an organization.");
SendClientMessage2(playerid, COLOR_YELLOW, "Your request will not be withdrawn until you are accepted, declined or reconnect.");
return 1;
}
new moneys1 = dini_Int(AddDirFile(dir_orgfiles, FILE_OSTATS), "max_org");
if (moneys1 == 0) return SendClientMessage2(playerid, COLOR_SILVER, "There are currently no existing organizations.");
if (DoesPlayerHaveMenuOpen(playerid) || GetPlayerDialog(playerid) != -1) return SendClientMessage2(playerid, COLOR_WHITE, "SERVER: Please exit your current menu first.");
new tmp3[1028], tmp4[400];
format(tmp3, sizeof(tmp3), "%sOrganization\tMembers\tLeader", tmp3);
for (new orgg = 1; orgg <= moneys1; orgg++)
{
moneys3=0;
format(tmp, 10, "org%d", orgg);
new temp1 = dini_Int(AddDirFile(dir_orgfiles, tmp), "maxmembers");
tmp4 = dini_Get(AddDirFile(dir_orgfiles, tmp), "leader");
for (new b = 1; b <= temp1; b++)
{
format(tmp2, 12, "member%d", b);
if (strcmp(dini_Get(AddDirFile(dir_orgfiles, tmp), tmp2), "server", false)) moneys3++;
}
if (strcmp(tmp4, "server", false) != 0)
{
format(stringdata,sizeof(stringdata), "%s", tmp4);
}
else
{
format(stringdata,sizeof(stringdata), "None");
}
if (!dini_Exists(AddDirFile(dir_orgfiles, tmp))) continue;
if (adlvl[playerid] >= 1)
{
if(moneys3 == temp1)
{
format(tmp3, sizeof(tmp3), "%s\n{%s}%s (%d)\tFull\t%s\n", tmp3, dini_Get(AddDirFile(dir_orgfiles, tmp), "color"), dini_Get(AddDirFile(dir_orgfiles, tmp), "name"), orgg, stringdata);
}
else if(moneys3 != temp1)
{
format(tmp3, sizeof(tmp3), "%s\n{%s}%s (%d)\tAvaliable\t%s\n", tmp3, dini_Get(AddDirFile(dir_orgfiles, tmp), "color"), dini_Get(AddDirFile(dir_orgfiles, tmp), "name"), orgg, stringdata);
}
}
else
{
if(moneys3 == temp1)
{
format(tmp3, sizeof(tmp3), "%s\n{%s}%s\tFull\t%s\n", tmp3, dini_Get(AddDirFile(dir_orgfiles, tmp), "color"), dini_Get(AddDirFile(dir_orgfiles, tmp), "name"), stringdata);
}
else if(moneys3 != temp1)
{
format(tmp3, sizeof(tmp3), "%s\n{%s}%s\tAvaliable\t%s\n", tmp3, dini_Get(AddDirFile(dir_orgfiles, tmp), "color"), dini_Get(AddDirFile(dir_orgfiles, tmp), "name"), stringdata);
}
}
}
ShowPlayerDialog2(playerid, DIALOG_ORG_REQUEST, DIALOG_STYLE_TABLIST_HEADERS, "Select an organization to join.", tmp3, "Select", "Cancel");
return 1;
}