/Forzarcmd [ID] [Comando]
if(strcmp(cmd, "/Forzarcmd", true) == 0)
{
tmp = strtokex(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, Blanco, "USO: /Forzarcmd [IdJugador/ParteDelNombre] [Comando]");
new player1;
if(!IsNumeric(tmp))
player1 = ReturnUser(tmp,playerid);
else player1 = strval(tmp);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[128];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result)) { SendClientMessage(playerid, Blanco, "USO: /Forzarcmd [IdJugador/ParteDelNombre] [Command]"); return 1; }
OnPlayerCommandText(player1, result);
}
return 1;
}
CMD:forzarc(playerid, params[])
{
new string[128];
if(sscanf(params, "us[128]", params[0], params[1])) return SendClientMessage(playerid, -1, "Utilize: /forzarz [ID/Nombre] [CMD]");
if(params[0] == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Jugador no conectado.");
format(string, sizeof(string), "[Info:] Forzaste a %s a usar el cmd %s", NombreEx(params[0]), params[1]);
SendClientMessage(playerid,-1,string);
OnPlayerCommandReceived(params[0], params[1]);
return 1;
}
new a[128];
format(a, sizeof(a), "cmd_%s", a);
CallLocalFunction(a, "i", params[0]);
//si el comando esta en el mismo lugar, ejemplo: forzarcmd en GM y comando a llamar en GM
COMMAND:forzarcmd(playerid, params[]) {
new data[100];
if(sscanf(params, "rs[20]", params[0], params[1])) return SendClientMessage(playerid, -1, " Escribe: /forzarcmd [id] [comando] ");
format(data, sizeof(data), "/%s", params[1]);
CallLocalFunction("OnPlayerCommandText", "is", params[0], data);
return true;
}
//si el comando esta en distinto lugar ejemplo: forzarcmd en GM y comando a llamar en FS
COMMAND:forzarcmd(playerid, params[]) {
new data[100];
if(sscanf(params, "rs[20]", params[0], params[1])) return SendClientMessage(playerid, -1, " Escribe: /forzarcmd [id] [comando] ");
format(data, sizeof(data), "/%s", params[1]);
CallRemoteFunction("OnPlayerCommandText", "is", params[0], data);
return true;
}
CallLocalFunction("OnPlayerCommandText", "is", params[0], data);
Sigue sin funcionar ....
pawn Код:
|
pawn Код:
https://sampwiki.blast.hk/wiki/CallRemoteFunction |