Converting strcmp command to ZCMD
#1

How to convert this strcmp command to a ZCMD command ??
Код:
	if(strcmp(cmd, "/animhelp", true) == 0 || strcmp(cmd, "/animlist", true) == 0)
	{
		SendClientMessage(playerid, COLOR_GREEN,"____________________________________________");
		SendClientMessage(playerid, COLOR_GRAD1," /handsup, /drunk, /cry, /bomb, /wank, /skate, /lookout,   /hitch,  /crabs, /rap.");
		SendClientMessage(playerid, COLOR_GRAD1," /showoff, /dance, /dj,  /what, /lean, /vomit, /getjiggy,  /robman, /greet, /fucku.");
		SendClientMessage(playerid, COLOR_GRAD2," /fuckme,  /cheer, /cpr, /kiss, /gift, /stand, /fallover,  /taichi, /pedmove.");
		SendClientMessage(playerid, COLOR_GRAD2," /slapass, /laugh, /bj,  /piss, /stop, /crack, /nobreath,  /signal, /followme.");
		SendClientMessage(playerid, COLOR_GRAD3," /gesture 	/hide,  /rob, /wave, /hurt, /smoke, /washhands, /salute, /crossarms.");
		SendClientMessage(playerid, COLOR_GRAD3," /sitdown, /relax, /sit, /dive, /deal, /sleep, /bitchslap, /reload, /checktime.");
        return 1;
	}
    if(strcmp(cmd,"/sit", true) == 0)
	{
	    if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || PlayerFrozen[playerid] != 0 || IsPlayerInAnyVehicle(playerid))
		{
  			SendClientMessage(playerid, COLOR_GREY, "   You can't do that at this time !");
			return 1;
		}
	    tmp = strtok(cmdtext, idx);
	    if(!strlen(tmp))
		{
			SendClientMessage(playerid,0xFF0000FF,"USAGE: /sit [1-5]");
			return 1;
		}
		anumber = strval(tmp);
		if(anumber < 1 || anumber > 5) { SendClientMessage(playerid,0xFF0000FF,"USAGE: /sit [1-5]"); return 1; }
		if(anumber == 1) { LoopingAnim(playerid,"BEACH","bather",4.0,1,0,0,0,0); }
		if(anumber == 2) { LoopingAnim(playerid,"BEACH","Lay_Bac_Loop",4.0,1,0,0,0,0); }
		if(anumber == 3) { LoopingAnim(playerid,"BEACH","ParkSit_W_loop",4.0,1,0,0,0,0); }
		if(anumber == 4) { LoopingAnim(playerid,"BEACH","SitnWait_loop_W",4.0,1,0,0,0,0); }
		if(anumber == 4) { LoopingAnim(playerid,"BEACH","SitnWait_loop_W",4.0,1,0,0,0,0); }
		if(anumber == 5) { LoopingAnim(playerid,"BEACH", "ParkSit_M_loop", 4.0,1,0,0,0,0); }
		return 1;
	}
	if(strcmp(cmd,"/nobreath", true) == 0)
	{
	    tmp = strtok(cmdtext, idx);
	    if(!strlen(tmp))
		{
			SendClientMessage(playerid,0xFF0000FF,"USAGE: /nobreath [1-2]");
			return 1;
		}
		anumber = strval(tmp);
		if(anumber < 1 || anumber > 2) { SendClientMessage(playerid,0xFF0000FF,"USAGE: /nobreath [1-2]"); return 1; }
		if(anumber == 1) { LoopingAnim(playerid,"PED","IDLE_tired",4.0,1,0,0,0,0); }
		if(anumber == 2) { LoopingAnim(playerid,"FAT","IDLE_tired",4.0,1,0,0,0,0); }
		return 1;
	}
    if(strcmp(cmd, "/sitonchair", true) == 0 || strcmp(cmd, "/sitdown", true) == 0)
	{
		tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid,0xFF0000FF,"USAGE: /sitonchair [1-7] or /sitdown [1-7]");
			return 1;
		}
		anumber = strval(tmp);
		if(anumber < 1 || anumber > 7) { SendClientMessage(playerid,0xFF0000FF,"USAGE: /sitonchair [1-7]"); return 1; }
		if(anumber == 1) { LoopingAnim(playerid,"Attractors","Stepsit_in",4.0,0,0,0,1,0); } // Not looping
		else if(anumber == 2) { LoopingAnim(playerid,"CRIB","PED_Console_Loop",4.0,1,0,0,0,0); }
		else if(anumber == 3) { LoopingAnim(playerid,"INT_HOUSE","LOU_In",4.0,0,0,0,1,0); } // Not looping
		else if(anumber == 4) { LoopingAnim(playerid,"MISC","SEAT_LR",4.0,1,0,0,0,0); }
		else if(anumber == 5) { LoopingAnim(playerid,"MISC","Seat_talk_01",4.0,1,0,0,0,0); }
		else if(anumber == 6) { LoopingAnim(playerid,"MISC","Seat_talk_02",4.0,1,0,0,0,0); }
		else if(anumber == 7) { LoopingAnim(playerid,"ped","SEAT_down",4.0,0,0,0,1,0); } // Not looping
		return 1;
	}
	if(strcmp(cmd, "/handsup", true) == 0)
	{
	    if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || PlayerFrozen[playerid] != 0 || IsPlayerInAnyVehicle(playerid))
		{
  			SendClientMessage(playerid, COLOR_GREY, "   You can't do that at this time !");
			return 1;
		}
	    SetPlayerSpecialAction(playerid,SPECIAL_ACTION_HANDSUP);
        return 1;
    }
    if(strcmp(cmd, "/dance", true) == 0)
	{
	    new Float:x, Float:y, Float:z, Float:v;
		GetPlayerVelocity(playerid, x, y, z);
		v = floatsqroot( floatpower(x,2) + floatpower(y,2) + floatpower(z,2) );

		if(v > 0.05)
		{
  			SendClientMessage(playerid, COLOR_GREY, "   You can't do that at this time !");
  			return 1;
  		}

      	tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid,0xFF0000FF,"USAGE: /dance [style 1-4]");
			return 1;
		}
		if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || PlayerFrozen[playerid] != 0 || IsPlayerInAnyVehicle(playerid))
		{
  			SendClientMessage(playerid, COLOR_GREY, "   You can't do that at this time !");
			return 1;
		}
		new dancestyle = strval(tmp);
		if(dancestyle < 1 || dancestyle > 4)
		{
		    SendClientMessage(playerid,0xFF0000FF,"USAGE: /dance [style 1-4]");
			return 1;
		}
		if(dancestyle == 1) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DANCE1);
		else if(dancestyle == 2) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DANCE2);
		else if(dancestyle == 3) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DANCE3);
		else if(dancestyle == 4) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DANCE4);
 	  	return 1;
	}
    if(strcmp(cmd, "/crossarms", true) == 0)
	{
      	tmp = strtok(cmdtext, idx);
		if(!strlen(tmp))
		{
			SendClientMessage(playerid,0xFF0000FF,"USAGE: /crossarms [1-5]");
			return 1;
		}
		if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || PlayerFrozen[playerid] != 0 || IsPlayerInAnyVehicle(playerid))
		{
  			SendClientMessage(playerid, COLOR_GREY, "   You can't do that at this time !");
			return 1;
		}
		anumber = strval(tmp);
		if(anumber < 1 || anumber > 6)
		{
            SendClientMessage(playerid,0xFF0000FF,"USAGE: /crossarms [1-5]");
            return 1;
		}
Reply
#2

Just change every if(strcmp(cmd, "/cmdnameishere", true) == 0)
to
pawn Код:
CMD:cmdnamehere(playerid, params)
{
     //Your code here
     return 1;
}
Have a nice day !
Reply
#3

https://sampforum.blast.hk/showthread.php?tid=271043
Reply
#4

pawn Код:
COMMAND:animhelp(playerid, cmdtext)
{
        SendClientMessage(playerid, COLOR_GREEN,"____________________________________________");
        SendClientMessage(playerid, COLOR_GRAD1," /handsup, /drunk, /cry, /bomb, /wank, /skate, /lookout,   /hitch,  /crabs, /rap.");
        SendClientMessage(playerid, COLOR_GRAD1," /showoff, /dance, /dj,  /what, /lean, /vomit, /getjiggy,  /robman, /greet, /fucku.");
        SendClientMessage(playerid, COLOR_GRAD2," /fuckme,  /cheer, /cpr, /kiss, /gift, /stand, /fallover,  /taichi, /pedmove.");
        SendClientMessage(playerid, COLOR_GRAD2," /slapass, /laugh, /bj,  /piss, /stop, /crack, /nobreath,  /signal, /followme.");
        SendClientMessage(playerid, COLOR_GRAD3," /gesture  /hide,  /rob, /wave, /hurt, /smoke, /washhands, /salute, /crossarms.");
        SendClientMessage(playerid, COLOR_GRAD3," /sitdown, /relax, /sit, /dive, /deal, /sleep, /bitchslap, /reload, /checktime.");
        return 1;
}

COMMAND:sit(playerid, cmdtext)
{
    if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || PlayerFrozen[playerid] != 0 || IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, COLOR_GREY, "   You can't do that at this time !");
            return 1;
        }
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,0xFF0000FF,"USAGE: /sit [1-5]");
            return 1;
        }
        anumber = strval(tmp);
        if(anumber < 1 || anumber > 5) { SendClientMessage(playerid,0xFF0000FF,"USAGE: /sit [1-5]"); return 1; }
        if(anumber == 1) { LoopingAnim(playerid,"BEACH","bather",4.0,1,0,0,0,0); }
        if(anumber == 2) { LoopingAnim(playerid,"BEACH","Lay_Bac_Loop",4.0,1,0,0,0,0); }
        if(anumber == 3) { LoopingAnim(playerid,"BEACH","ParkSit_W_loop",4.0,1,0,0,0,0); }
        if(anumber == 4) { LoopingAnim(playerid,"BEACH","SitnWait_loop_W",4.0,1,0,0,0,0); }
        if(anumber == 4) { LoopingAnim(playerid,"BEACH","SitnWait_loop_W",4.0,1,0,0,0,0); }
        if(anumber == 5) { LoopingAnim(playerid,"BEACH", "ParkSit_M_loop", 4.0,1,0,0,0,0); }
        return 1;
        }
       
COMMAND:nobreath(playerid, cmdtext)
}
    tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,0xFF0000FF,"USAGE: /nobreath [1-2]");
            return 1;
        }
        anumber = strval(tmp);
        if(anumber < 1 || anumber > 2) { SendClientMessage(playerid,0xFF0000FF,"USAGE: /nobreath [1-2]"); return 1; }
        if(anumber == 1) { LoopingAnim(playerid,"PED","IDLE_tired",4.0,1,0,0,0,0); }
        if(anumber == 2) { LoopingAnim(playerid,"FAT","IDLE_tired",4.0,1,0,0,0,0); }
        return 1;
}

COMMAND:sitonchair(playerid, cmdtext)
{
    tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,0xFF0000FF,"USAGE: /sitonchair [1-7] or /sitdown [1-7]");
            return 1;
        }
        anumber = strval(tmp);
        if(anumber < 1 || anumber > 7) { SendClientMessage(playerid,0xFF0000FF,"USAGE: /sitonchair [1-7]"); return 1; }
        if(anumber == 1) { LoopingAnim(playerid,"Attractors","Stepsit_in",4.0,0,0,0,1,0); } // Not looping
        else if(anumber == 2) { LoopingAnim(playerid,"CRIB","PED_Console_Loop",4.0,1,0,0,0,0); }
        else if(anumber == 3) { LoopingAnim(playerid,"INT_HOUSE","LOU_In",4.0,0,0,0,1,0); } // Not looping
        else if(anumber == 4) { LoopingAnim(playerid,"MISC","SEAT_LR",4.0,1,0,0,0,0); }
        else if(anumber == 5) { LoopingAnim(playerid,"MISC","Seat_talk_01",4.0,1,0,0,0,0); }
        else if(anumber == 6) { LoopingAnim(playerid,"MISC","Seat_talk_02",4.0,1,0,0,0,0); }
        else if(anumber == 7) { LoopingAnim(playerid,"ped","SEAT_down",4.0,0,0,0,1,0); } // Not looping
        return 1;
}

COMMAND:handsup(playerid, cmdtext)
{
    if(strcmp(cmd, "/handsup", true) == 0)
    {
        if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || PlayerFrozen[playerid] != 0 || IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, COLOR_GREY, "   You can't do that at this time !");
            return 1;
        }
        SetPlayerSpecialAction(playerid,SPECIAL_ACTION_HANDSUP);
        return 1;
}
 
 
COMMAND:dance(playerid, cmdtext)
{
    new Float:x, Float:y, Float:z, Float:v;
        GetPlayerVelocity(playerid, x, y, z);
        v = floatsqroot( floatpower(x,2) + floatpower(y,2) + floatpower(z,2) );

        if(v > 0.05)
        {
            SendClientMessage(playerid, COLOR_GREY, "   You can't do that at this time !");
            return 1;
        }

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,0xFF0000FF,"USAGE: /dance [style 1-4]");
            return 1;
        }
        if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || PlayerFrozen[playerid] != 0 || IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, COLOR_GREY, "   You can't do that at this time !");
            return 1;
        }
        new dancestyle = strval(tmp);
        if(dancestyle < 1 || dancestyle > 4)
        {
            SendClientMessage(playerid,0xFF0000FF,"USAGE: /dance [style 1-4]");
            return 1;
        }
        if(dancestyle == 1) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DANCE1);
        else if(dancestyle == 2) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DANCE2);
        else if(dancestyle == 3) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DANCE3);
        else if(dancestyle == 4) SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DANCE4);
        return 1;
    }
   
    COMMAND:crossarms(playerid, cmdtext)
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid,0xFF0000FF,"USAGE: /crossarms [1-5]");
            return 1;
        }
        if(PlayerTied[playerid] != 0 || PlayerCuffed[playerid] != 0 || PlayerFrozen[playerid] != 0 || IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, COLOR_GREY, "   You can't do that at this time !");
            return 1;
        }
        anumber = strval(tmp);
        if(anumber < 1 || anumber > 6)
        {
            SendClientMessage(playerid,0xFF0000FF,"USAGE: /crossarms [1-5]");
            return 1;
        }
Reply
#5

Yeah that's right, that's a zcmd command
Reply
#6

Quote:
Originally Posted by rangerxxll
Посмотреть сообщение
pawn Код:
COMMAND:animhelp(playerid, cmdtext)
This won't compile. ZCMD uses params[], not cmdtext and should be outside any callback.

Quote:
Originally Posted by BigAl
Посмотреть сообщение
Yeah that's right, that's a zcmd command
And this is spam.
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
This won't compile. ZCMD uses params[], not cmdtext and should be outside any callback.
You can change variable names to what ever you want it does not matter just dont mismatch string,integer and float
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)