CMD:forcecmd(playerid, params[])
{
new cmdToForce[50];
if(PlayerInfo[playerid][AdminLevel] < 5) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You are not authorized to perform this command.");
if(sscanf(params, "rs[50]", Target, cmdToForce)) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /forcecmd [playerid/PartOfName] [command-to-force]");
return cmd_cmdToForce(Target, params[]);
}
error 017: undefined symbol "cmd_cmdToForce"
return cmd_cmdToForce(Target, params[]);
return cmd_params[2](Targer, params[]);
new cmdname[32] = "cmd_";
strcat(cmdname, cmdToForce);
CallLocalFunction(cmdname, "s", params);
|
https://sampwiki.blast.hk/wiki/CallLocalFunction
pawn Код:
@up: Could you explain to me how your code works? Even if there was a macro like that, params[2] would point to third character of params string |

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;
}
|
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;
}
|