need help tho
#1

pawn Код:
stock SavePlayerOrgInfo(playerid)
{

if (!dini_Exists(PlayerPath(playerid)))
{
dini_Create(PlayerPath(playerid));
}
//dini_Set(savef,"ContactName1",ContactNames[0][playerid]);
dini_Set(PlayerPath(playerid),"Org",Organization[PlayerOrg[playerid]][Name]);
if(Organization[PlayerOrg[playerid]][ismember] == 1)
{
dini_IntSet(PlayerPath(playerid),"Member",1);
}
if(Organization[PlayerOrg[playerid]][trial] == 1)
{
dini_IntSet(PlayerPath(playerid),"trial",1);
}
if(Organization[PlayerOrg[playerid]][adv] == 1)
{
dini_IntSet(PlayerPath(playerid),"adv",1);
}
if(Organization[PlayerOrg[playerid]][co] == 1)
{
dini_IntSet(PlayerPath(playerid),"co",1);
}
if(Organization[PlayerOrg[playerid]][Leader] == 1)
{
dini_IntSet(PlayerPath(playerid),"Leader",1);
}
dini_IntSet(PlayerPath(playerid),"CollectedWage",CollectedWage[playerid]);
}

stock LoadPlayerOrgInfo(playerid)
{
new string[45];
format(string,sizeof(string),"%s",dini_Get(PlayerPath(playerid),"Org"));
PlayerOrg[playerid] = GetOrgID(string);
new string2[28];
Organization[PlayerOrg[playerid]][ismember] = dini_Int(PlayerPath(playerid),"Member");
Organization[PlayerOrg[playerid]][adv] = dini_Int(PlayerPath(playerid),"adv");
Organization[PlayerOrg[playerid]][co] = dini_Int(PlayerPath(playerid),"co");
Organization[PlayerOrg[playerid]][Leader] = dini_Int(PlayerPath(playerid),"Leader");
Organization[PlayerOrg[playerid]][trial] = dini_Int(PlayerPath(playerid),"Trial");
CollectedWage[playerid] = dini_Int(PlayerPath(playerid), "CollectedWage");

if (strcmp(Organization[PlayerOrg[playerid]][Leader], PlayerName(playerid),true) == 0 && PlayerOrg[playerid] != 0)
{
PlayerLeader[playerid] = 1;
}
}
Doesnt saves correct, fix this code.
pawn Код:
CMD:setrank(playerid, params[])
{
if (!IsLeader(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not the leader of an organization");
new ID, rank,mode[128];
if (sscanf(params, "us[28]", ID, rank)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /setrank [playerid] [rank]");
if (!IsPlayerConnected(ID)) return 1;
if(done[playerid] == 1) return 0;
new org = PlayerOrg[playerid];
if (PlayerOrg[ID] != org) return SendClientMessage(playerid, COLOR_RED,"That player does not belong to your organization");
new string[120];
if(rank=0)
{
Organization[PlayerOrg[playerid]][trial] = 1;
mode = "Trial";
done[playerid] = 1;
format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), mode);
SendClientMessage(ID, COLOR_YELLOW, string);
format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), mode);
SendClientMessage(playerid, COLOR_YELLOW, string);
SavePlayerOrgInfo(ID);

}
if(rank=1)
{
Organization[PlayerOrg[playerid]][ismember] = 1;
mode = "Member";
done[playerid] = 1;
format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), mode);
SendClientMessage(ID, COLOR_YELLOW, string);
format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), mode);
SendClientMessage(playerid, COLOR_YELLOW, string);
SavePlayerOrgInfo(ID);

}
if(rank=2)
{
Organization[PlayerOrg[playerid]][advs] = 1;
mode = "Adv.Member";
done[playerid] = 1;
format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), mode);
SendClientMessage(ID, COLOR_YELLOW, string);
format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), mode);
SendClientMessage(playerid, COLOR_YELLOW, string);
SavePlayerOrgInfo(ID);

}
if(rank=3)
{
Organization[PlayerOrg[playerid]][co] = 1;
mode = "Co-Leader";
done[playerid] = 1;
format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), mode);
SendClientMessage(ID, COLOR_YELLOW, string);
format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), mode);
SendClientMessage(playerid, COLOR_YELLOW, string);
SavePlayerOrgInfo(ID);

}
if(rank=4)
{
Organization[PlayerOrg[playerid]][Leader] = 1;
mode = "Leader";
done[playerid] = 1;
format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), mode);
SendClientMessage(ID, COLOR_YELLOW, string);
format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), mode);
SendClientMessage(playerid, COLOR_YELLOW, string);
SavePlayerOrgInfo(ID);
}
return 1;
}
When i setmyself as a member, it sets me everything exists in this cmd, leader,coleader,adv,member,trial.lols
pls i;m trying to fix it but you guys help me as well
Reply
#2

First of all, why are you parsing the rank parameter as a string instead of an integer when you clearly don't need to? It's useless.

And maaaaan, please, your identation!

pawn Код:
CMD:setrank(playerid, params[])
{
    if (!IsLeader(playerid))
        return SendClientMessage(playerid,COLOR_RED,"You are not the leader of an organization");

    new ID, rank, mode[128];
           
    if (sscanf(params, "ui", ID, rank))
        return SendClientMessage(playerid,COLOR_WHITE,"Usage: /setrank [playerid] [rank]");
       
    if (!IsPlayerConnected(ID))
        return 1;
       
    if(done[playerid] == 1)
        return 0;
       
    new org = PlayerOrg[playerid];
   
    if (PlayerOrg[ID] != org)
        return SendClientMessage(playerid, COLOR_RED,"That player does not belong to your organization");
       
    new string[120];
   
    switch(rank)
    {
        case 0:
        {
            Organization[PlayerOrg[playerid]][trial] = 1;
            mode = "Trial";
            done[playerid] = 1;
            format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), mode);
            SendClientMessage(ID, COLOR_YELLOW, string);
            format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), mode);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            SavePlayerOrgInfo(ID);
        }      
        case 1:
        {
            Organization[PlayerOrg[playerid]][ismember] = 1;
            mode = "Member";
            done[playerid] = 1;
            format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), mode);
            SendClientMessage(ID, COLOR_YELLOW, string);
            format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), mode);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            SavePlayerOrgInfo(ID);
        }  
        case 2:
        {
            Organization[PlayerOrg[playerid]][advs] = 1;
            mode = "Adv.Member";
            done[playerid] = 1;
            format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), mode);
            SendClientMessage(ID, COLOR_YELLOW, string);
            format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), mode);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            SavePlayerOrgInfo(ID);
        }
        case 3:
        {
            Organization[PlayerOrg[playerid]][co] = 1;
            mode = "Co-Leader";
            done[playerid] = 1;
            format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), mode);
            SendClientMessage(ID, COLOR_YELLOW, string);
            format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), mode);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            SavePlayerOrgInfo(ID);
        }
        case 4:
        {
            Organization[PlayerOrg[playerid]][Leader] = 1;
            mode = "Leader";
            done[playerid] = 1;
            format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), mode);
            SendClientMessage(ID, COLOR_YELLOW, string);
            format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), mode);
            SendClientMessage(playerid, COLOR_YELLOW, string);
            SavePlayerOrgInfo(ID);
        }
       
        default: SendClientMessage(playerid, COLOR_RED, "The given rank is invalid.");
    }
   
    return 1;
}

stock SavePlayerOrgInfo(playerid)
{
    if(!dini_Exists(PlayerPath(playerid)))
        dini_Create(PlayerPath(playerid));

    //dini_Set(savef,"ContactName1",ContactNames[0][playerid]);
    dini_Set(PlayerPath(playerid),"Org",Organization[PlayerOrg[playerid]][Name]);
   
    if(Organization[PlayerOrg[playerid]][ismember] == 1)
        dini_IntSet(PlayerPath(playerid),"Member",1);

    if(Organization[PlayerOrg[playerid]][trial] == 1)
        dini_IntSet(PlayerPath(playerid),"trial",1);
   
    if(Organization[PlayerOrg[playerid]][adv] == 1)
        dini_IntSet(PlayerPath(playerid),"adv",1);
       
    if(Organization[PlayerOrg[playerid]][co] == 1)
        dini_IntSet(PlayerPath(playerid),"co",1);

    if(Organization[PlayerOrg[playerid]][Leader] == 1)
        dini_IntSet(PlayerPath(playerid),"Leader",1);

    dini_IntSet(PlayerPath(playerid),"CollectedWage",CollectedWage[playerid]);
    return 1;
}

stock LoadPlayerOrgInfo(playerid)
{
    new string[45];
    format(string,sizeof(string),"%s",dini_Get(PlayerPath(playerid),"Org"));
    PlayerOrg[playerid] = GetOrgID(string);
    new string2[28];
    Organization[PlayerOrg[playerid]][ismember] = dini_Int(PlayerPath(playerid),"Member");
    Organization[PlayerOrg[playerid]][adv] = dini_Int(PlayerPath(playerid),"adv");
    Organization[PlayerOrg[playerid]][co] = dini_Int(PlayerPath(playerid),"co");
    Organization[PlayerOrg[playerid]][Leader] = dini_Int(PlayerPath(playerid),"Leader");
    Organization[PlayerOrg[playerid]][trial] = dini_Int(PlayerPath(playerid),"Trial");
    CollectedWage[playerid] = dini_Int(PlayerPath(playerid), "CollectedWage");

    if (strcmp(Organization[PlayerOrg[playerid]][Leader], PlayerName(playerid),true) == 0 && PlayerOrg[playerid] != 0)
        PlayerLeader[playerid] = 1;
       
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)