SA-MP Forums Archive
Strcmp ---> ZCMD - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Strcmp ---> ZCMD (/showthread.php?tid=278665)



Strcmp ---> ZCMD - Jafet_Macario - 23.08.2011

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


Re: Strcmp ---> ZCMD - Pinguinn - 23.08.2011

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


Re: Strcmp ---> ZCMD - Jafet_Macario - 23.08.2011

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.


Re: Strcmp ---> ZCMD - dud - 23.08.2011

i think its ok,but you shoud test it


Re: Strcmp ---> ZCMD - sleepysnowflake - 23.08.2011

Does it give you any errors/warnings ?


Re: Strcmp ---> ZCMD - Jafet_Macario - 23.08.2011

Nope


Re: Strcmp ---> ZCMD - sleepysnowflake - 23.08.2011

The it should be just fine ?

BTW: <3 the Spongebob in your avatar :3


Re: Strcmp ---> ZCMD - =WoR=G4M3Ov3r - 23.08.2011

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


Re: Strcmp ---> ZCMD - doreto - 23.08.2011

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 ?


Re: Strcmp ---> ZCMD - Kingunit - 23.08.2011

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.