command problems rly help
#1

ok so i have these commands heres code


its /akill [id] [reason] and kills them and ive discovered if you put the cmd 4letters example (/slap) then the reason is

Reason : %s

Like Normal But If You Have More Than 4 Letters

The Reason Becomes

Reason:0 %s

Heres Code

Please Help Thanks


Код:
if ( strcmp ( cmd , "/akill" , true ) == 0 && IsPlayerAdmin ( playerid ) )
	{
	    new tmp [ 256 ];

		new message [ 256 ];

		tmp = strtok ( cmdtext , idx );

        if( ! strlen ( tmp ) )
		{
		    SendClientMessage ( playerid , 0xFF0000FF , "Usage: /akill [playerid] [reason]" );
		    return 1;
	    }

	    new giveplayerid = strval(tmp);

	    tmp = strtok(cmdtext, idx);

        if(!strlen(tmp))
	    {
	        if (IsPlayerConnected(giveplayerid))
	        {
   	            format(string, sizeof(string), "{FF66FF}**Kill: (%s) (ID) %d (Admin Kill) -> (%s) (ID) %d Reason: No Reason Given",GetName(playerid), playerid, GetName(giveplayerid), giveplayerid);
	            SendClientMessageToAll(COLOR_WHITE, string);
                printf(string);
                new Float:killhealth;
				GetPlayerHealth(giveplayerid, killhealth);
				SetPlayerHealth(giveplayerid, killhealth-100);
   	            return 1;
		    }
			else
			{
                format(string, sizeof(string), "{F81414}ERROR: ID %d Is Not Online/Found Please Recheck The ID", giveplayerid);
                SendClientMessage(playerid, COLOR_WHITE, string);
                return 1;
            }
        }

        if(giveplayerid < 10)
        {
		    strmid(message, cmdtext, 7, strlen(cmdtext));
        }
		else
		{
            strmid(message, cmdtext, 8, strlen(cmdtext));
        }

   	    if (IsPlayerConnected(giveplayerid))
	    {
            format(string, sizeof(string), "{FF66FF}**KILL: (%s) (ID) %d (Admin Kill) -> (%s) (ID) %d Reason:%s",GetName(playerid), playerid, GetName(giveplayerid), giveplayerid, message );
		    SendClientMessageToAll(COLOR_WHITE, string);
			printf(string);
            new Float:killhealth;
			GetPlayerHealth(giveplayerid, killhealth);
			SetPlayerHealth(giveplayerid, killhealth-100);
			return 1;
	    }
		else
		{
            format(string, sizeof(string), "ERROR: ID %d Is Not Online/Found Please Recheck The ID", giveplayerid);
            SendClientMessage(playerid, COLOR_WHITE, string);
            return 1;
        }
	}
thanks
Reply
#2

I cant understand it.. It has a weird identation
Reply
#3

Quote:
Originally Posted by Marricio
Посмотреть сообщение
I cant understand it.. It has a weird identation
what do you mean? and ty for replying
Reply
#4

You know the warning ''Loose identation''? Well, it's that.
Reply
#5

Quote:
Originally Posted by Marricio
Посмотреть сообщение
You know the warning ''Loose identation''? Well, it's that.
no it isnt because samp forums pawno [code thingy messes up the spaces its fine it has no warning or errors
Reply
#6

pawn Код:
if(strcmp("/akill", cmd, true) == 0)
    {
        if(IsPlayerAdmin(playerid)) {
            tmp = strtok(cmdtext,idx);
            if(!strlen(tmp) || strlen(tmp) > 5) {
                return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /akill (id) [reason]");
            }

            new id = strval(tmp);

            if(!IsPlayerConnected(id)) {
                SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/akill : Bad player ID");
                return 1;
            }

            gMessage = strrest(cmdtext,idx);

            GetPlayerName(id,iName,sizeof(iName));
            SendClientMessage(id,ADMINFS_MESSAGE_COLOR,"-- You have been kiled by an administrator.");

            if(strlen(gMessage) > 0) {
                format(Message,sizeof(Message),"Reason: %s",gMessage);
                SendClientMessage(id,ADMINFS_MESSAGE_COLOR,Message);
            }

            format(Message,sizeof(Message),">> %s(%d) has been akilled.",iName,id);
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,Message);

            SetPlayerHealth(id,0);
            return 1;
        } else {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/akill : You are not an admin");
            return 1;
        }
    }
Credits to baseAF
Reply
#7

Quote:
Originally Posted by Marricio
Посмотреть сообщение
pawn Код:
if(strcmp("/akill", cmd, true) == 0)
    {
        if(IsPlayerAdmin(playerid)) {
            tmp = strtok(cmdtext,idx);
            if(!strlen(tmp) || strlen(tmp) > 5) {
                return SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"Usage: /akill (id) [reason]");
            }

            new id = strval(tmp);

            if(!IsPlayerConnected(id)) {
                SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/akill : Bad player ID");
                return 1;
            }

            gMessage = strrest(cmdtext,idx);

            GetPlayerName(id,iName,sizeof(iName));
            SendClientMessage(id,ADMINFS_MESSAGE_COLOR,"-- You have been kiled by an administrator.");

            if(strlen(gMessage) > 0) {
                format(Message,sizeof(Message),"Reason: %s",gMessage);
                SendClientMessage(id,ADMINFS_MESSAGE_COLOR,Message);
            }

            format(Message,sizeof(Message),">> %s(%d) has been akilled.",iName,id);
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,Message);

            SetPlayerHealth(id,0);
            return 1;
        } else {
            SendClientMessage(playerid,ADMINFS_MESSAGE_COLOR,"/akill : You are not an admin");
            return 1;
        }
    }
Credits to baseAF
thanks but do you know why i can only have four worded commands any higher i get 0 infront of reason? thanks
Reply
#8

Quote:
Originally Posted by hadzx
Посмотреть сообщение
thanks but do you know why i can only have four worded commands any higher i get 0 infront of reason? thanks
I dont know, i couldn't check the code cause the identation.
Reply
#9

Quote:
Originally Posted by Marricio
Посмотреть сообщение
I dont know, i couldn't check the code cause the identation.
damn ok thx anyway
Reply
#10

Use SSCANF + ZCMD.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)