Forcing a command by a command.
#5

Here you go my man calibrated just for you
(Stealing this idea for myself too hehe)

Код:
CMD:forcecmd(playerid, params[])
{

// Set your command prefix here
#define     cmdprefix       "cmd"

#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif

	new Target;
	new cmdParams[50];
    new cmdToForce[50];

    if(PlayerInfo[playerid][AdminLevel] < 5) SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are not authorized to perform this command.");
	else
 	{
	    sscanf(params, "us[50]s[50]", Target, cmdToForce, cmdParams);

		if(isnull(cmdToForce)) SendClientMessage(playerid, COLOR_USAGE, "USAGE: /forcecmd [playerid/PartOfName] [command-to-force] [command-parameters]");
		else
		{
			if(!IsPlayerConnected(Target)) SendClientMessage(playerid, COLOR_USAGE, "Player is not connected - USAGE: /forcecmd [playerid/PartOfName] [command-to-force] [command-parameters]");
			else
			{
				format(cmdToForce, sizeof(cmdToForce), "%s_%s", cmdprefix, cmdToForce);
				if(funcidx(cmdToForce) != -1)
				{
					if(isnull(cmdParams)) CallLocalFunction(cmdToForce, "i", Target);
					else CallLocalFunction(cmdToForce, "is", Target, cmdParams);
				}
				else SendClientMessage(playerid, COLOR_USAGE, "FUNCTION DOES NOT EXIST - USAGE: /forcecmd [playerid/PartOfName] [command-to-force] [command-parameters]");
			}
		}
	}
	return 1;
}
Reply


Messages In This Thread
Forcing a command by a command. - by Denying - 24.03.2013, 09:40
Re: Forcing a command by a command. - by DiGiTaL_AnGeL - 24.03.2013, 09:50
Re: Forcing a command by a command. - by Misiur - 24.03.2013, 09:50
Re: Forcing a command by a command. - by Denying - 24.03.2013, 10:39
Re: Forcing a command by a command. - by Pottus - 24.03.2013, 10:44
Re: Forcing a command by a command. - by Denying - 24.03.2013, 10:55

Forum Jump:


Users browsing this thread: 1 Guest(s)