how to make this command to zcmd and sscanf?
#1

hi everyone, i saw this command in a game mode how can I make it in zcmd and sscanf?

pawn Code:
if(strcmp(cmd,"/createclan",true) == 0)
    {
        if(PlayerInfo[playerid][pRank] > 0) return SendClientMessage(playerid,Red,"You are already in a clan !");
        tmp = strtok(cmdtext,idx);
        if(!strlen(tmp))
        {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createclan 1/2 (front or back) (tag)");
        SendClientMessage(playerid,COLOR_GREEN,"Do not include [ or ] in the tag");
        return 1;
        }
        moneys = strval(tmp);
        new length = strlen(cmdtext);
        while ((idx < length) && (cmdtext[idx] <= ' '))
        {
        idx++;
        }
        new offset = idx;
        new result[256];
        while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
        {
        result[idx - offset] = cmdtext[idx];
        idx++;
        }
        result[idx - offset] = EOS;
        if(!strlen(result))
        {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createclan 1/2 (front or back) (tag)");
        SendClientMessage(playerid,COLOR_GREEN,"Do not include [ or ] in the tag");
        return 1;
        }
        for(new i = 0; i < sizeof(Clans); i++)
        {
            if(clan != 255)
            {
                SendClientMessage(playerid,Red,"You are in a clan !");
                return 1;
            }
            if(strmatch(Clans[i][cName],result)) return SendClientMessage(playerid,Red,"Clan name already exists !");
            if(moneys == 1)
            {
                i = lastclan;
                PlayerInfo[playerid][pClanKey] = lastclan;
                PlayerInfo[playerid][pRank] = 3;
                GetPlayerName(playerid,sendername,sizeof(sendername));
                strmid(Clans[i][clOwner], sendername, 0, strlen(sendername), 255);
                strmid(Clans[i][cName], result, 0, strlen(result), 255);
                Clans[i][Front] = 1;
                format(string,sizeof(string),"You have created the clan [%s], at the front of your name.",result);
                SendClientMessage(playerid,COLOR_GREEN,string);
                lastclan++;
                SaveClans();
                OnPlayerDataSave(playerid);
                return 1;
            }
            if(moneys == 2)
            {
                i = lastclan;
                PlayerInfo[playerid][pClanKey] = lastclan;
                PlayerInfo[playerid][pRank] = 3;
                GetPlayerName(playerid,sendername,sizeof(sendername));
                strmid(Clans[i][clOwner], sendername, 0, strlen(sendername), 255);
                strmid(Clans[i][cName], result, 0, strlen(result), 255);
                Clans[i][Back] = 1;
                format(string,sizeof(string),"You have created the clan [%s], at the back of your name.",result);
                SendClientMessage(playerid,COLOR_GREEN,string);
                lastclan++;
                SaveClans();
                OnPlayerDataSave(playerid);
                return 1;
            }
        }
        return 1;
    }
Reply
#2

pawn Code:
new lastclan=0;
new seconds;
new Invited[MAX_PLAYERS];
new invite;
new inviter;
enum ClanSystem
{
    cName[MAX_PLAYER_NAME],
    clOwner[MAX_PLAYER_NAME],
    Front,
    Back,
    cID,
};
new Clans[100][ClanSystem];
pawn Code:
new clan = PlayerInfo[playerid][pClanKey];
Is this good enough for the rest of the code to be converted?
I deleted it before I put it here on samp forums
your right strcmp/strtok sucks

also can you please explain how you did it so i can learn it too
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)