Strcmp ---> ZCMD
#1

I'm currently converting all my commands from strcmp to zcmd, but I got stuck at one command, I wanna know if I made it right guys.Here is the strcmp:
pawn Code:
if(strcmp(cmd,"/depune",true)==0)
    {
        if(IsPlayerConnected(playerid))
        {
            new leader = PlayerInfo[playerid][pLeader];
            new member = PlayerInfo[playerid][pMember];
            if(member==1 || member==2 || member==3 || member==4 || member==7 || member==8 || member==9 || member==10 || member==11)
            {
               SendClientMessage(playerid, COLOR_GREEN, "You are not a gang member !");
               return 1;
            }
            else if(leader==1 || leader==2 || leader==3 || leader==4 || leader==7 || leader==8 || leader==9 || leader==10 || leader==11)
            {
               SendClientMessage(playerid, COLOR_GREEN, "You are not a gang member !");
               return 1;
            }
            else if(PlayerInfo[playerid][pTeam] == 3 || PlayerInfo[playerid][pTeam] == 4)
            {
               SendClientMessage(playerid, COLOR_GREEN, "You are not a gang member !");
               return 1;
            }
            if(PlayerToPoint(25.0,playerid,2027.5966,1008.9321,10.8203) || PlayerToPoint(3.0,playerid,-2190.7061,641.7987,49.4375) || PlayerToPoint(3.0,playerid,2782.7209,-1957.9377,13.5469) || PlayerToPoint(3.0,playerid,679.4280,-1276.8392,13.5956) || PlayerToPoint(3.0,playerid,2156.3076,-1455.8517,25.5391) || PlayerToPoint(3.0,playerid,2494.8640,-1668.1879,13.3438))
            {
               new x_nr[128];//era 256
               x_nr = strtok(cmdtext, idx);
               if(!strlen(x_nr)) {
                  SendClientMessage(playerid, COLOR_WHITE, "|__________________ Depune  __________________|");
                  SendClientMessage(playerid, COLOR_WHITE, "MESAJ: /depune [nume]");
                  SendClientMessage(playerid, COLOR_GREY, "Nume Valabile: Materiale, Droguri");
                  SendClientMessage(playerid, COLOR_WHITE, "|____________________________________________|");
                  return 1;
               }
               if(strcmp(x_nr,"Materiale",true) == 0)
               {
                  tmp = strtok(cmdtext, idx);
                  if(!strlen(tmp))
                  {
                     SendClientMessage(playerid, COLOR_GRAD2, "MESAJ: Materiale [numar]");
                     format(string, sizeof(string), "ai %d materiale.", PlayerInfo[playerid][pMats]);
                     SendClientMessage(playerid, COLOR_GRAD3, string);
                     return 1;
                  }
                  new matss;
                  matss = strval(tmp);
                  if(!strlen(tmp))
                  {
                     SendClientMessage(playerid, COLOR_GRAD2, "MESAJ: Materiale [numar]");
                     format(string, sizeof(string), "ai %d materiale.", PlayerInfo[playerid][pMats]);
                     SendClientMessage(playerid, COLOR_GRAD3, string);
                     return 1;
                  }
                  if(matss > PlayerInfo[playerid][pMats])
                  {
                     SendClientMessage(playerid, COLOR_GRAD2, "Nu ai destul!");
                     return 1;
                  }
                  PlayerInfo[playerid][pMats] -= matss;
                  PlayerInfo[playerid][pBoxMats] += matss;
                  format(string, sizeof(string), "ai depus %d materiale!", matss);
                  SendClientMessage(playerid, COLOR_GRAD4, string);
                  return 1;
               }
               else if(strcmp(x_nr,"Droguri",true) == 0)
               {
                  tmp = strtok(cmdtext, idx);
                  if(!strlen(tmp))
                  {
                     SendClientMessage(playerid, COLOR_GRAD2, "MESAJ: Droguri [numar]");
                     format(string, sizeof(string), "ai %d Grame.", PlayerInfo[playerid][pDrugs]);
                     SendClientMessage(playerid, COLOR_GRAD3, string);
                     return 1;
                  }
                  new drugss;
                  drugss = strval(tmp);
                  if(!strlen(tmp))
                  {
                     SendClientMessage(playerid, COLOR_GRAD2, "MESAJ: Droguri [numar]");
                     format(string, sizeof(string), "ai %d Grame.", PlayerInfo[playerid][pDrugs]);
                     SendClientMessage(playerid, COLOR_GRAD3, string);
                     return 1;
                  }
                  if(drugss > PlayerInfo[playerid][pDrugs])
                  {
                     SendClientMessage(playerid, COLOR_GRAD2, "Nu ai atat!");
                     return 1;
                  }
                  PlayerInfo[playerid][pDrugs] -= drugss;
                  PlayerInfo[playerid][pBoxDrugs] += drugss;
                  format(string, sizeof(string), "ai depus %d grame droguri!", drugss);
                  SendClientMessage(playerid, COLOR_GRAD4, string);
                  return 1;
               }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "Nu esti in locul potrivit !");
                return 1;
            }
        }//not connected
        return 1;
    }
And here is the ZCMD:
pawn Code:
CMD:depune(playerid, params[])
{
    new le = PlayerInfo[playerid][pLeader], me = PlayerInfo[playerid][pMember], string[128], matss, drugss, value;
    if(le==1||le==2||le==3||le==4||le==7||le==9||le==10||le==11||me==1||me==2||me==3||me==4||me==7||me==9||me==10||me==11) return SCM(playerid, COLOR_GREY,"You are not a gang member");
    else if(!PlayerToPoint(25.0,playerid,2027.5966,1008.9321,10.8203) || !PlayerToPoint(3.0,playerid,-2190.7061,641.7987,49.4375) || !PlayerToPoint(3.0,playerid,2782.7209,-1957.9377,13.5469) || !PlayerToPoint(3.0,playerid,679.4280,-1276.8392,13.5956) || !PlayerToPoint(3.0,playerid,2156.3076,-1455.8517,25.5391) || !PlayerToPoint(3.0,playerid,2494.8640,-1668.1879,13.3438)) return SCM(playerid, COLOR_GREY,"You are not at the right place");
    else if (sscanf(params, "s[24]i", matss, value)) return SCM(playerid, COLOR_GREY,"USAGE: /depune [materiale/droguri] [numar]");
    else
    {
        if(matss > PlayerInfo[playerid][pMats]) return SCM(playerid, COLOR_GRAD2, "Nu ai destul!");
        else
        {
            PlayerInfo[playerid][pMats] -= matss;
            PlayerInfo[playerid][pBoxMats] += matss;
            format(string, sizeof(string), "ai depus %d materiale!", matss);
            SendClientMessage(playerid, COLOR_GRAD4, string);
        }
        if(drugss > PlayerInfo[playerid][pDrugs]) return SCM(playerid, COLOR_GRAD2, "Nu ai atat!");
        else
        {
            PlayerInfo[playerid][pDrugs] -= drugss;
            PlayerInfo[playerid][pBoxDrugs] += drugss;
            format(string, sizeof(string), "ai depus %d grame droguri!", drugss);
            SendClientMessage(playerid, COLOR_GRAD4, string);
        }
    }
    return 1;
}
Did I converted it to ZCMD good?Will this work?If anyone can help, thanks
Reply
#2

Did you test it? If you didn't, you don't know if it works??
Reply
#3

I didn't test it yet because I still have to convert many commands from strcmp to zcmd, I just wanna know if I converted it right, if this will work.
Reply
#4

i think its ok,but you shoud test it
Reply
#5

Does it give you any errors/warnings ?
Reply
#6

Nope
Reply
#7

The it should be just fine ?

BTW: <3 the Spongebob in your avatar :3
Reply
#8

https://sampforum.blast.hk/showthread.php?tid=231496
Reply
#9

Quote:
Originally Posted by Jafet_Macario
View Post
I didn't test it yet because I still have to convert many commands from strcmp to zcmd, I just wanna know if I converted it right, if this will work.
why you dont test before post ?
Reply
#10

Use the search function. There is a filterscript that's converting your strcmp commands to ZCMD. Very easy.
And you can do that within 5minutes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)