[HELP]Organization Command
#1

In my roleplay script i /createorg [Org Name] everything works fine when i create the org.. Here is the code

PHP Code:
CMD:createorg(playeridparams[])
{
    new 
tmp[256], tmp2[256], string[256], giveplayer[256], moneys1istr[2][50];
    if (
adlvl[playerid] < 6) return 0;
    if (
sscanf(params"s[128]"tmp)) return SendClientMessage2(playeridCOLOR_WHITE"Usage: /createorg [name]");
    if (
strlen(tmp) > 48) return SendClientMessage2(playeridCOLOR_RED"Organization names must be a maximum of 48 characters.");
    new 
amount dini_Int(AddDirFile(dir_orgfilesFILE_OSTATS), "orgs");
    if (
amount == MAX_ORGS)
    {
        
format(tmp2sizeof(tmp2), "The number of organizations has reached the limit of %d."MAX_ORGS);
        
SendClientMessage2(playeridCOLOR_REDtmp2);
        return 
1;
    }
    new 
giveplayerid dini_Int(AddDirFile(dir_orgfilesFILE_OSTATS), "max_org");
    for (new 
tov 1tov <= giveplayeridtov++)
    {
        
format(string10"org%d"tov);
        if (!
dini_Exists(AddDirFile(dir_orgfilesstring)))
        {
            
moneys1 tov;
            break;
        }
    }
    if (
moneys1 == 0)
    {
        
moneys1 giveplayerid+1;
        
dini_IntSet(AddDirFile(dir_orgfilesFILE_OSTATS), "max_org"moneys1);
    }
    
dini_IntSet(AddDirFile(dir_orgfilesFILE_OSTATS), "orgs"amount+1);
    
format(string10"org%d"moneys1);
    
dini_Create(AddDirFile(dir_orgfilesstring));
    
dini_Set(AddDirFile(dir_orgfilesstring), "name"tmp);
    
dini_Set(AddDirFile(dir_orgfilesstring), "leader""server");
    for (new 
1<= MAX_ORG_MEMBERSe++)
    {
        
format(giveplayer12"members%d"e);
        
dini_Set(AddDirFile(dir_orgfilesstring), giveplayer"server");
    }
    
valstr(istr[0], moneys1);
    
SendPlayerFormattedText(playeridCOLOR_SILVER"Organization '%s' created (ID = %s)"tmpistr[0]);
    if (
DoesPlayerHaveMenuOpen(playerid) == && GetPlayerDialog(playerid) == -1ShowPlayerDialog2(playeridDIALOG_ORG_CATSDIALOG_STYLE_LIST"Organization catagories""Law Enforcement\nGang\nPublic Service\nPublic Transport\nPrivate Business\nHitman\nOther""Select""Cancel");
    
orgselectc[playerid] = moneys1;
    return 
1;

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:request(playeridparams[])
{
    new 
tmp[256], tmp2[256], moneys3stringdata[256];
    if (
orgReq[playerid] > 0)
    {
        
SendClientMessage2(playeridCOLOR_ORANGE"You are already requesting to join an organization.");
        
SendClientMessage2(playeridCOLOR_YELLOW"Your request will not be withdrawn until you are accepted, declined or reconnect.");
        return 
1;
    }
    new 
moneys1 dini_Int(AddDirFile(dir_orgfilesFILE_OSTATS), "max_org");
    if (
moneys1 == 0) return SendClientMessage2(playeridCOLOR_SILVER"There are currently no existing organizations.");
    if (
DoesPlayerHaveMenuOpen(playerid) || GetPlayerDialog(playerid) != -1) return SendClientMessage2(playeridCOLOR_WHITE"SERVER: Please exit your current menu first.");
    new 
tmp3[1028], tmp4[400];
    
format(tmp3sizeof(tmp3), "%sOrganization\tMembers\tLeader"tmp3);
    for (new 
orgg 1orgg <= moneys1orgg++)
    {
        
moneys3=0;
        
format(tmp10"org%d"orgg);
        new 
temp1 dini_Int(AddDirFile(dir_orgfilestmp), "maxmembers");
        
tmp4 dini_Get(AddDirFile(dir_orgfilestmp), "leader");
        for (new 
1<= temp1b++)
        {
            
format(tmp212"member%d"b);
            if (
strcmp(dini_Get(AddDirFile(dir_orgfilestmp), 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_orgfilestmp))) continue;
          if (
adlvl[playerid] >= 1)
        {
                    if(
moneys3 == temp1)
                    {
                        
format(tmp3sizeof(tmp3), "%s\n{%s}%s (%d)\tFull\t%s\n"tmp3dini_Get(AddDirFile(dir_orgfilestmp), "color"), dini_Get(AddDirFile(dir_orgfilestmp), "name"), orggstringdata);
                    }
                    else if(
moneys3 != temp1)
                    {
                        
format(tmp3sizeof(tmp3), "%s\n{%s}%s (%d)\tAvaliable\t%s\n"tmp3dini_Get(AddDirFile(dir_orgfilestmp), "color"), dini_Get(AddDirFile(dir_orgfilestmp), "name"), orggstringdata);
                    }
        }
        else
        {
                    if(
moneys3 == temp1)
                    {
                        
format(tmp3sizeof(tmp3), "%s\n{%s}%s\tFull\t%s\n"tmp3dini_Get(AddDirFile(dir_orgfilestmp), "color"), dini_Get(AddDirFile(dir_orgfilestmp), "name"), stringdata);
                    }
                    else if(
moneys3 != temp1)
                    {
                        
format(tmp3sizeof(tmp3), "%s\n{%s}%s\tAvaliable\t%s\n"tmp3dini_Get(AddDirFile(dir_orgfilestmp), "color"), dini_Get(AddDirFile(dir_orgfilestmp), "name"), stringdata);
                    }
        }
    }
    
ShowPlayerDialog2(playeridDIALOG_ORG_REQUESTDIALOG_STYLE_TABLIST_HEADERS"Select an organization to join."tmp3"Select""Cancel");
    return 
1;

Reply
#2

First of all, use some meaningfull variable names. giveplayerid, moneys1, ... Why would you call a variable giveplayerid, when it has nothing to do with a player ID?
That just makes it more difficult to debug such things.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)