Strcmp to Zcmd
#1

i wanna transform all commands from my gamemode in zcmd format but i don`t know on this command
Код:
if(strcmp(cmd,"/nrgmk",true)==0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pAdmin] > 3 || PlayerInfo[playerid][pClubLeader] == 2)
	        {
		        new x_mk[128];//era 256
				x_mk = strtok(cmdtext, idx);
				if(!strlen(x_mk)) {
					SendClientMessage(playerid, COLOR_WHITE, "{D580FE}Foloseste:{FFFFFF} /nrgmk [name]");
					SendClientMessage(playerid, COLOR_GREY, "Poti folosi: title, maker, reward, cp, save)");
					return 1;
				}
                else if(strcmp(x_mk,"title",true) == 0)
				{
				    new length = strlen(cmdtext);
					while ((idx < length) && (cmdtext[idx] <= ' '))
					{
						idx++;
					}
					new offset = idx;
					new result[64];
					while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
					{
						result[idx - offset] = cmdtext[idx];
						idx++;
					}
					result[idx - offset] = EOS;
					if(!strlen(result))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "{D580FE}Foloseste:{FFFFFF} (/nrgmk title [text]");
						return 1;
					}
					strmid(NrgMission[NrgTitle], result, 0, strlen(result), 255);
			        SendClientMessage(playerid, COLOR_WHITE, "You've made the Title of the NRG Mission.");
				}
				else if(strcmp(x_mk,"maker",true) == 0)
				{
				    new length = strlen(cmdtext);
					while ((idx < length) && (cmdtext[idx] <= ' '))
					{
						idx++;
					}
					new offset = idx;
					new result[64];
					while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
					{
						result[idx - offset] = cmdtext[idx];
						idx++;
					}
					result[idx - offset] = EOS;
					if(!strlen(result))
					{
						SendClientMessage(playerid, COLOR_GRAD2, "{D580FE}Foloseste:{FFFFFF} (/nrgmk maker [player name]");
						return 1;
					}
					strmid(NrgMission[NrgMaker], result, 0, strlen(result), 255);
			        SendClientMessage(playerid, COLOR_WHITE, "You've made the Maker of the NRG Mission.");
				}
				else if(strcmp(x_mk,"reward",true) == 0)
				{
				    tmp = strtok(cmdtext, idx);
				    if(!strlen(x_mk))
					{
						SendClientMessage(playerid, COLOR_WHITE, "{D580FE}Foloseste:{FFFFFF} /nrgmk reward [price]");
						return 1;
					}
				    new price = strval(tmp);
					if(price < 1 || price > 500) { SendClientMessage(playerid, COLOR_GREY, "   Reward Price can't be below 1 or above 500 !"); return 1; }
					NrgMission[NrgReward] = price;
					SendClientMessage(playerid, COLOR_WHITE, "You've made the Reward Price for the NRG Mission.");
				}
				else if(strcmp(x_mk,"cp",true) == 0)
				{
				    tmp = strtok(cmdtext, idx);
				    if(!strlen(x_mk))
					{
						SendClientMessage(playerid, COLOR_WHITE, "{D580FE}Foloseste:{FFFFFF} /nrgmk cp [number]");
						return 1;
					}
				    new number = strval(tmp);
					if(number < 1 || number > 6) { SendClientMessage(playerid, COLOR_GREY, "   Number can't be below 1 or above 6 !"); return 1; }
					new Float:X,Float:Y,Float:Z;
					GetPlayerPos(playerid, X,Y,Z);
	                switch(number)
					{
					    case 1:
					    {
					        NrgMission[NrgCP1][0] = X; NrgMission[NrgCP1][1] = Y; NrgMission[NrgCP1][2] = Z;
					        SendClientMessage(playerid, COLOR_WHITE, "You've made the 1st Checkpoint of the NRG Mission.");
					    }
					    case 2:
					    {
					        NrgMission[NrgCP2][0] = X; NrgMission[NrgCP2][1] = Y; NrgMission[NrgCP2][2] = Z;
					        SendClientMessage(playerid, COLOR_WHITE, "You've made the 2nd Checkpoint Line of the NRG Mission.");
					    }
					    case 3:
					    {
					        NrgMission[NrgCP3][0] = X; NrgMission[NrgCP3][1] = Y; NrgMission[NrgCP3][2] = Z;
					        SendClientMessage(playerid, COLOR_WHITE, "You've made the 3rd Checkpoint Line of the NRG Mission.");
					    }
					    case 4:
					    {
					        NrgMission[NrgCP4][0] = X; NrgMission[NrgCP4][1] = Y; NrgMission[NrgCP4][2] = Z;
					        SendClientMessage(playerid, COLOR_WHITE, "You've made the 4th Checkpoint Line of the NRG Mission.");
					    }
					    case 5:
					    {
					        NrgMission[NrgCP5][0] = X; NrgMission[NrgCP5][1] = Y; NrgMission[NrgCP5][2] = Z;
					        SendClientMessage(playerid, COLOR_WHITE, "You've made the 5th Checkpoint Line of the NRG Mission.");
					    }
					    case 6:
					    {
					        NrgMission[NrgCP6][0] = X; NrgMission[NrgCP6][1] = Y; NrgMission[NrgCP6][2] = Z;
					        SendClientMessage(playerid, COLOR_WHITE, "You've made the 6th Checkpoint Line of the NRG Mission.");
					    }
					}
				}
				else if(strcmp(x_mk,"save",true) == 0)
				{
				    tmp = strtok(cmdtext, idx);
					if(!strlen(tmp))
					{
						SendClientMessage(playerid, COLOR_GRAD1, "{D580FE}Foloseste:{FFFFFF} /nrgmk save [mission number]");
						return 1;
					}
					SaveNrgMission(playerid,tmp);
				}
				else
				{
					SendClientMessage(playerid, COLOR_GREY, "   Invalid Mission Making name !");
					return 1;
				}
			}
			else
			{
			    SendClientMessage(playerid,COLOR_GREY, "You`re not Admin level 4+ or NRG Club Leader !");
				return 1;
			}
	    }
	    return 1;
	}
Somebody explain me, is it`s possible to transform order to realize. Sorry for my bad english
Reply
#2

pawn Код:
CMD:nrgmk(playerid, params[])
{
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pAdmin] > 3 || PlayerInfo[playerid][pClubLeader] == 2)
            {
                new x_mk[128];//era 256
                x_mk = strtok(cmdtext, idx);
                if(!strlen(x_mk)) {
                    SendClientMessage(playerid, COLOR_WHITE, "{D580FE}Foloseste:{FFFFFF} /nrgmk [name]");
                    SendClientMessage(playerid, COLOR_GREY, "Poti folosi: title, maker, reward, cp, save)");
                    return 1;
                }
                else if(strcmp(x_mk,"title",true) == 0)
                {
                    new length = strlen(cmdtext);
                    while ((idx < length) && (cmdtext[idx] <= ' '))
                    {
                        idx++;
                    }
                    new offset = idx;
                    new result[64];
                    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                    {
                        result[idx - offset] = cmdtext[idx];
                        idx++;
                    }
                    result[idx - offset] = EOS;
                    if(!strlen(result))
                    {
                        SendClientMessage(playerid, COLOR_GRAD2, "{D580FE}Foloseste:{FFFFFF} (/nrgmk title [text]");
                        return 1;
                    }
                    strmid(NrgMission[NrgTitle], result, 0, strlen(result), 255);
                    SendClientMessage(playerid, COLOR_WHITE, "You've made the Title of the NRG Mission.");
                }
                else if(strcmp(x_mk,"maker",true) == 0)
                {
                    new length = strlen(cmdtext);
                    while ((idx < length) && (cmdtext[idx] <= ' '))
                    {
                        idx++;
                    }
                    new offset = idx;
                    new result[64];
                    while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
                    {
                        result[idx - offset] = cmdtext[idx];
                        idx++;
                    }
                    result[idx - offset] = EOS;
                    if(!strlen(result))
                    {
                        SendClientMessage(playerid, COLOR_GRAD2, "{D580FE}Foloseste:{FFFFFF} (/nrgmk maker [player name]");
                        return 1;
                    }
                    strmid(NrgMission[NrgMaker], result, 0, strlen(result), 255);
                    SendClientMessage(playerid, COLOR_WHITE, "You've made the Maker of the NRG Mission.");
                }
                else if(strcmp(x_mk,"reward",true) == 0)
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(x_mk))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "{D580FE}Foloseste:{FFFFFF} /nrgmk reward [price]");
                        return 1;
                    }
                    new price = strval(tmp);
                    if(price < 1 || price > 500) { SendClientMessage(playerid, COLOR_GREY, "   Reward Price can't be below 1 or above 500 !"); return 1; }
                    NrgMission[NrgReward] = price;
                    SendClientMessage(playerid, COLOR_WHITE, "You've made the Reward Price for the NRG Mission.");
                }
                else if(strcmp(x_mk,"cp",true) == 0)
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(x_mk))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "{D580FE}Foloseste:{FFFFFF} /nrgmk cp [number]");
                        return 1;
                    }
                    new number = strval(tmp);
                    if(number < 1 || number > 6) { SendClientMessage(playerid, COLOR_GREY, "   Number can't be below 1 or above 6 !"); return 1; }
                    new Float:X,Float:Y,Float:Z;
                    GetPlayerPos(playerid, X,Y,Z);
                    switch(number)
                    {
                        case 1:
                        {
                            NrgMission[NrgCP1][0] = X; NrgMission[NrgCP1][1] = Y; NrgMission[NrgCP1][2] = Z;
                            SendClientMessage(playerid, COLOR_WHITE, "You've made the 1st Checkpoint of the NRG Mission.");
                        }
                        case 2:
                        {
                            NrgMission[NrgCP2][0] = X; NrgMission[NrgCP2][1] = Y; NrgMission[NrgCP2][2] = Z;
                            SendClientMessage(playerid, COLOR_WHITE, "You've made the 2nd Checkpoint Line of the NRG Mission.");
                        }
                        case 3:
                        {
                            NrgMission[NrgCP3][0] = X; NrgMission[NrgCP3][1] = Y; NrgMission[NrgCP3][2] = Z;
                            SendClientMessage(playerid, COLOR_WHITE, "You've made the 3rd Checkpoint Line of the NRG Mission.");
                        }
                        case 4:
                        {
                            NrgMission[NrgCP4][0] = X; NrgMission[NrgCP4][1] = Y; NrgMission[NrgCP4][2] = Z;
                            SendClientMessage(playerid, COLOR_WHITE, "You've made the 4th Checkpoint Line of the NRG Mission.");
                        }
                        case 5:
                        {
                            NrgMission[NrgCP5][0] = X; NrgMission[NrgCP5][1] = Y; NrgMission[NrgCP5][2] = Z;
                            SendClientMessage(playerid, COLOR_WHITE, "You've made the 5th Checkpoint Line of the NRG Mission.");
                        }
                        case 6:
                        {
                            NrgMission[NrgCP6][0] = X; NrgMission[NrgCP6][1] = Y; NrgMission[NrgCP6][2] = Z;
                            SendClientMessage(playerid, COLOR_WHITE, "You've made the 6th Checkpoint Line of the NRG Mission.");
                        }
                    }
                }
                else if(strcmp(x_mk,"save",true) == 0)
                {
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "{D580FE}Foloseste:{FFFFFF} /nrgmk save [mission number]");
                        return 1;
                    }
                    SaveNrgMission(playerid,tmp);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "   Invalid Mission Making name !");
                    return 1;
                }
            }
            else
            {
                SendClientMessage(playerid,COLOR_GREY, "You`re not Admin level 4+ or NRG Club Leader !");
                return 1;
            }
        }
        return 1;
    }
}
This?
Reply
#3

yes man, i don`t know who to make ...... you wanna help me ? give me a example similary
Reply
#4

It's so easy,
an ex.:
pawn Код:
if(strcmp(cmd,"/nrgmk",true)==0)
Must change to :
pawn Код:
CMD:nrgmk(playerid, params[])
Reply
#5

are you kidding? ))))) That i know, but i don`t know with
Код:
new x_mk[128];//era 256
                x_mk = strtok(cmdtext, idx);
                if(!strlen(x_mk)) {
                    SendClientMessage(playerid, COLOR_WHITE, "{D580FE}Foloseste:{FFFFFF} /nrgmk [name]");
                    SendClientMessage(playerid, COLOR_GREY, "Poti folosi: title, maker, reward, cp, save)");
                    return 1;
                }
                else if(strcmp(x_mk,"title",true) == 0)
                {
Reply
#6

use sscanf
Reply
#7

how man ? i don`t know i`m new in sscanf and ZCMD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)