Jump to content
  • 0

Diferenta intre zcmd si strcmp


AsSsASIN

Question

Cand eram si eu newbye, nu intelegeam de ce folosesc astia dcmd (in prezent zcmd e mai bun ca dcmd), acum stiu de ce, si vreau sa va spun si voua.

E mai rapid, mai usor de folosit, si este lagul mai putin.

Scurteaza anumite comenzi de exemplu :

	if(!strcmp(cmdtext, "/water", true))
	{
		if(PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 3 || PlayerInfo[playerid][pMember] == 3)
    	{
        	if (PlayerToPoint(2.0, playerid,251.6549,111.6241,1003.2187))
			{
	      		SetPlayerHealth(playerid, 100);
                SetPlayerArmour(playerid, 100.0);
			}
        	else if (PlayerToPoint(2.0, playerid,229.4513,155.2181,1003.0234))
			{
	      		SetPlayerHealth(playerid, 100);
                SetPlayerArmour(playerid, 100.0);
			}
        	else if (PlayerToPoint(2.0, playerid,215.1405,1816.4128,6.4216))
			{
	      		SetPlayerHealth(playerid, 100);
                SetPlayerArmour(playerid, 100.0);
			}
            else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location.");
			}
	 	}
	    else if(PlayerInfo[playerid][pLeader] == 5 || PlayerInfo[playerid][pMember] == 5)
    	{
        	if (PlayerToPoint(2.0, playerid,1701.4309,-1652.3481,20.2194))
			{
	      		SetPlayerHealth(playerid, 100);
			}
            else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location.");
			}
	 	}
	    else if(PlayerInfo[playerid][pLeader] == 6 || PlayerInfo[playerid][pMember] == 6)
    	{
        	if (PlayerToPoint(2.0, playerid,777.4392,-42.4484,1000.5859))
			{
	      		SetPlayerHealth(playerid, 100);
			}
            else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location.");
			}
	 	}
	    else if(PlayerInfo[playerid][pLeader] == 8 || PlayerInfo[playerid][pMember] == 8)
    	{
        	if (PlayerToPoint(2.0, playerid,954.4086,2112.5673,1011.0302)) 
			{
	      		SetPlayerHealth(playerid, 100);
			}
            else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location.");
			}
	 	}
	    else if(PlayerInfo[playerid][pLeader] == 9 || PlayerInfo[playerid][pMember] == 9)
    	{
        	if (PlayerToPoint(2.0, playerid,1496.3660,1304.4941,1093.2890))
			{
	      		SetPlayerHealth(playerid, 100);
			}
            else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location.");
			}
	 	}
	    else if(PlayerInfo[playerid][pLeader] == 10 || PlayerInfo[playerid][pMember] == 10)
    	{
        	if (PlayerToPoint(2.0, playerid,1496.3660,1304.4941,1093.2890))
			{
	      		SetPlayerHealth(playerid, 100);
			}
            else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location.");
			}
	 	}
	    else if(PlayerInfo[playerid][pLeader] == 11 || PlayerInfo[playerid][pMember] == 11)
    	{
        	if (PlayerToPoint(2.0, playerid,-2028.1030,-119.1108,1035.1718))
			{
	      		SetPlayerHealth(playerid, 100);
			}
            else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location.");
			}
	 	}
	    else if(PlayerInfo[playerid][pLeader] == 12 || PlayerInfo[playerid][pMember] == 12)
    	{
        	if (PlayerToPoint(2.0, playerid,2447.9267,-1690.3886,1013.5078))
			{
	      		SetPlayerHealth(playerid, 100);
			}
        	else if (PlayerToPoint(2.0, playerid,1248.8333,6.5205,1008.2578))
			{
	      		SetPlayerHealth(playerid, 100);
			}
	        else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location.");
			}
	 	}
	    else if(PlayerInfo[playerid][pLeader] == 13 || PlayerInfo[playerid][pMember] == 13)
    	{
        	if (PlayerToPoint(2.0, playerid, 2500.0539,-1709.3824,1014.7421))
			{
	      		SetPlayerHealth(playerid, 100);
			}
        	else if (PlayerToPoint(2.0, playerid,1248.8333,6.5205,1008.2578))
			{
	      		SetPlayerHealth(playerid, 100);
			}
		    else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location.");
			}
	 	}
	    else if(PlayerInfo[playerid][pLeader] == 14 || PlayerInfo[playerid][pMember] == 14)
    	{
        	if (PlayerToPoint(2.0, playerid,1496.3660,1304.4941,1093.2890))
			{
	      		SetPlayerHealth(playerid, 100);
			}
        	else if (PlayerToPoint(2.0, playerid,1248.8333,6.5205,1008.2578))
			{
	      		SetPlayerHealth(playerid, 100);
			}
		    else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location.");
			}
	 	}
	    else if(PlayerInfo[playerid][pLeader] == 15 || PlayerInfo[playerid][pMember] == 15)
    	{
        	if (PlayerToPoint(2.0, playerid,1496.3660,1304.4941,1093.2890))
			{
	      		SetPlayerHealth(playerid, 100);
			}
        	else if (PlayerToPoint(2.0, playerid,1248.8333,6.5205,1008.2578))
			{
	      		SetPlayerHealth(playerid, 100);
			}
		    else
			{
			    SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location.");
			}
	 	}
		else
		{
			 SendClientMessage(playerid, COLOR_GREY, "  You are not a member of a faction!");
		}
		return 1;
	}
Nu credeti ca e cam mare comanda? Ah, acum prin zcmd :
CMD:water(playerid, params[])
{
	if(PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 3 || PlayerInfo[playerid][pMember] == 3) {
        if (PlayerToPoint(2.0, playerid,251.6549,111.6241,1003.2187)) { SetPlayerHealth(playerid, 100); SetPlayerArmour(playerid, 100.0); }
        else if (PlayerToPoint(2.0, playerid,229.4513,155.2181,1003.0234)) { SetPlayerHealth(playerid, 100); SetPlayerArmour(playerid, 100.0); }
        else if (PlayerToPoint(2.0, playerid,215.1405,1816.4128,6.4216)) { SetPlayerHealth(playerid, 100); SetPlayerArmour(playerid, 100.0); }
        else { SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location."); }
	}
	else if(PlayerInfo[playerid][pLeader] == 5 || PlayerInfo[playerid][pMember] == 5) {
        if (PlayerToPoint(2.0, playerid,1701.4309,-1652.3481,20.2194)) { SetPlayerHealth(playerid, 100); }
        else { SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location."); }
    }
	else if(PlayerInfo[playerid][pLeader] == 6 || PlayerInfo[playerid][pMember] == 6) {
        if (PlayerToPoint(2.0, playerid,777.4392,-42.4484,1000.5859)) { SetPlayerHealth(playerid, 100); }
        else { SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location."); }
    }
	else if(PlayerInfo[playerid][pLeader] == 8 || PlayerInfo[playerid][pMember] == 8) {
        if (PlayerToPoint(2.0, playerid,954.4086,2112.5673,1011.0302)) { SetPlayerHealth(playerid, 100); }
        else { SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location."); }
	}
	else if(PlayerInfo[playerid][pLeader] == 9 || PlayerInfo[playerid][pMember] == 9) {
        if (PlayerToPoint(2.0, playerid,1496.3660,1304.4941,1093.2890)) { SetPlayerHealth(playerid, 100); }
        else { SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location."); }
    }
	else if(PlayerInfo[playerid][pLeader] == 10 || PlayerInfo[playerid][pMember] == 10) {
        if (PlayerToPoint(2.0, playerid,1496.3660,1304.4941,1093.2890)) { SetPlayerHealth(playerid, 100); }
        else { SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location."); }
	}
	else if(PlayerInfo[playerid][pLeader] == 11 || PlayerInfo[playerid][pMember] == 11) {
        if (PlayerToPoint(2.0, playerid,-2028.1030,-119.1108,1035.1718)) { SetPlayerHealth(playerid, 100); }
        else { SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location."); }
    }
	else if(PlayerInfo[playerid][pLeader] == 12 || PlayerInfo[playerid][pMember] == 12) {
        if (PlayerToPoint(2.0, playerid,2447.9267,-1690.3886,1013.5078)) { SetPlayerHealth(playerid, 100); }
        else if (PlayerToPoint(2.0, playerid,1248.8333,6.5205,1008.2578)) { SetPlayerHealth(playerid, 100); }
	    else { SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location."); }
	}
	else if(PlayerInfo[playerid][pLeader] == 13 || PlayerInfo[playerid][pMember] == 13) {
        if (PlayerToPoint(2.0, playerid, 2500.0539,-1709.3824,1014.7421)) { SetPlayerHealth(playerid, 100); }
        else if (PlayerToPoint(2.0, playerid,1248.8333,6.5205,1008.2578)) { SetPlayerHealth(playerid, 100); }
		else { SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location."); }
	}
	else if(PlayerInfo[playerid][pLeader] == 14 || PlayerInfo[playerid][pMember] == 14) {
        if (PlayerToPoint(2.0, playerid,1496.3660,1304.4941,1093.2890)) { SetPlayerHealth(playerid, 100); }
        else if (PlayerToPoint(2.0, playerid,1248.8333,6.5205,1008.2578)) { SetPlayerHealth(playerid, 100); }
		else { SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location."); }
	}
	else if(PlayerInfo[playerid][pLeader] == 15 || PlayerInfo[playerid][pMember] == 15) {
        if (PlayerToPoint(2.0, playerid,1496.3660,1304.4941,1093.2890)) { SetPlayerHealth(playerid, 100); }
        else if (PlayerToPoint(2.0, playerid,1248.8333,6.5205,1008.2578)) { SetPlayerHealth(playerid, 100); }
		else { SendClientMessage(playerid, COLOR_GRAD2, "  You're not in the right location."); }
	}
	else { SendClientMessage(playerid, COLOR_GREY, "  You are not a member of a faction!"); }
	return 1;
}

Uitati ce micuta este, va recomand tutoror, folositi cu incredere zcmd.

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

Zcmd te ajuta cand lucrezi cu 'params'(ex:/ban 1 Bitch).In exemplu tau nu e mare diferenta...

E bun si asa  :)


@stuntman:

if(!blabla) = if(blabla==0)

if(blabla) = if(blabla==1)

Link to comment
Share on other sites

Guest PlayON

Chiar ca ia dat maxim =)).

ZCMD prin MAI RAPID nu se refera numai la viteza raspunsului, ci si la usurarea codului.

CMD:kick(playerid, params[])
{
	if (P_DATA[ playerid ][ P_Level ] < 4)
		return SendError( playerid, "You are not allowed to use this command"),SendClientMessage(playerid, COLOR_WHITE, "REASON: Low level!");

    if (P_DATA[ playerid ][ P_LoggedIN ] == 0)
		return SendError( playerid, "Please login to use this command!");

	if ( sscanf( params, "us", params[ 0 ] ,params[ 1 ]) )
		return SendUsage( playerid, "/kick <id> [reason]" );

	if (P_DATA[ params[ 0 ] ][ P_Level ] > P_DATA[ playerid ][ P_Level ])
		return SendError( playerid, "You have no rights to use admin commands on higher admins!");

    if( params[ 0 ] == playerid )
	    return SendError( playerid, "You can't kick yourself!");

	FormMessageForAllEx(playerid,COLOR_GREEN, "Administrator %s kicked %s from the server! [Reason: %s]",PlayerName2( playerid ), PlayerName2( params[ 0 ] ), params[ 1 ]);
	FormMessage( params[ 0 ], COLOR_GREEN, "4 %s kicked you! [Reason: %s ]",PlayerName2( playerid ), params[ 1 ]);
	FormMessage( playerid, COLOR_GREEN, "You have kicked %s [Reason: %s]",PlayerName2( params[ 0 ] ), params[ 1 ]);
	Kick( params[ 0 ] );
	return 1;
}
CMD:ban(playerid, params[])
{
	if (P_DATA[ playerid ][ P_Level ] < 4)
		return SendError( playerid, "You are not allowed to use this command"),SendClientMessage(playerid, COLOR_WHITE, "REASON: Low level!");

    if (P_DATA[ playerid ][ P_LoggedIN ] == 0)
		return SendError( playerid, "Please login to use this command!");

	if ( sscanf( params, "us", params[ 0 ] ,params[ 1 ]) )
		return SendUsage( playerid, "/ban <id> [reason]" );

	if (P_DATA[ params[ 0 ] ][ P_Level ] > P_DATA[ playerid ][ P_Level ])
		return SendError( playerid, "You have no rights to use admin commands on higher admins!");

	if( params[ 0 ] == playerid )
	    return SendError( playerid, "You can't ban yourself!");
	FormMessageForAllEx(playerid,COLOR_GREEN, "Administrator %s banned %s from the server! [Reason: %s]",PlayerName2( playerid ), PlayerName2( params[ 0 ] ), params[ 1 ]);
	FormMessage( params[ 0 ], COLOR_GREEN, "Administrator %s banned you! [Reason: %s ]",PlayerName2( playerid ), params[ 1 ]);
	FormMessage( playerid, COLOR_GREEN, "You have banned %s [Reason: %s]",PlayerName2( params[ 0 ] ), params[ 1 ]);
	dUserSetINT( PlayerName2( params[ 0 ] ) ).("Banned", 1 );
	Ban( params[ 0 ] );

	return 1;
}

Uite codul meu, ignore FormMessage si SendError alea, is niste prescurtari la functii. :)

Link to comment
Share on other sites

Astai kick de kick ma =)) :

CMD:kick(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new
            year,
            month,
            day,
            string[256],
            result[128],
            giveplayerid,
            sendername[MAX_PLAYER_NAME],
            giveplayer[MAX_PLAYER_NAME];
            
        if (sscanf(params, "us", giveplayerid, result)) { SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /kick [playerid/PartOfName] [reason]"); return 1; }
        if (PlayerInfo[playerid][pAdmin] >= 1) {
            if(IsPlayerConnected(giveplayerid)) {
                if(giveplayerid != INVALID_PLAYER_ID) {
                    if(FindIP((params))) /// Anti-Reclama
                    {
                             format(string, sizeof(string), "AdmCmd: %s was kicked by Guardian, reason: Server Advertise",sendername);
                        SendClientMessageToAll(0xFF6347FF,string);
                        PlayerInfo[playerid][pWarns] += 1;
                        KickLog(string);
                        Kick(playerid);
                        return 1;
                    }
                    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    getdate(year, month, day);
                    format(string, sizeof(string), "AdmCmd: %s was kicked by %s, reason: %s (%d-%d-%d)", giveplayer, sendername, result,month,day,year);
                    format(string, sizeof(string), "AdmCmd: %s was kicked by %s, reason: %s", giveplayer, sendername, result);
                    SendClientMessageToAll(COLOR_LIGHTRED, string);
                    KickLog(string);
                    Kick(giveplayerid);
                    return 1;
                }
            }
        }
        else {
            format(string, sizeof(string), "   %d is not an active player.", giveplayerid);
            SendClientMessage(playerid, COLOR_GRAD1, string);
        }
    }
    return 1;
}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.