how to make other player to do a command
#1

yo guys, i need something like

When i do /command [id of player] [the command i want the player to do] , the player do the command( only rcon admin can do it)

an example : /command 11 /dm , //now the player on dm.

i saw this on a server, so i want it to make it,

can anyone give me a script or any idea or any link.
Reply
#2

Erm I highly doubt you can do that. Not sure which server even has that, Never seen it before.
Reply
#3

ZCMD:
pawn Code:
CMD:command(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0;
    new id, sendcommand[50], cmdparams;
    if(sscanf(params, "us[50]S[100]", id, sendcommand, cmdparams)) return SendClientMessage(playerid, -1, "USAGE: /command [name/id] [command] [Optional: parameters]");
    if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid Player.");
    if(sendcommand[0] == '/') strdel(sendcommand, 0, 1);
    CallLocalFunction(sendcommand, "is", id, cmdparams);
    SendClientMessage(playerid, 0xFFFF00FF, "Command Sent.");
    return 1;
}
This should work.

Requires the following includes:
a_samp
sscanf2
zcmd
Reply
#4

thanks BenzoAMG man, awesome, at last i got this command
Reply
#5

Quote:
Originally Posted by SkilledMaster
View Post
Erm I highly doubt you can do that. Not sure which server even has that, Never seen it before.
yep, how many server u played before? the server is not in hosted tab. anyway i got the code
Reply
#6

OMG no. I forgot to edit it after I changed it from strcmp to zcmd.

pawn Code:
CMD:command(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0;
    new id, sendcommand[50], cmdparams;
    if(sscanf(params, "us[50]S[100]", id, sendcommand, cmdparams)) return SendClientMessage(playerid, -1, "USAGE: /command [name/id] [command] [Optional: parameters]");
    if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid Player.");
    if(sendcommand[0] == '/') strdel(sendcommand, 0, 1);
    new actualcmd[55];
    format(actualcmd, sizeof(actualcmd), "cmd_%s", sendcommand);
    CallLocalFunction(actualcmd, "is", id, cmdparams);
    SendClientMessage(playerid, 0xFFFF00FF, "Command Sent.");
    return 1;
}
Sorry.
Reply
#7

thanks one more time, ur really helpful

but not work

Code:
CMD:cmd(playerid, params[])
{
    LoginCheck(playerid);
    LevelCheck(playerid, 5);
    
    new id, sendcommand[50], cmdparams;
    if(sscanf(params, "us[50]S[100]", id, sendcommand, cmdparams)) return SendClientMessage(playerid, -1, "USAGE: /cmd [name/id] [command] [Optional: parameters]");
    if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid Player.");
    if(sendcommand[0] == '/') strdel(sendcommand, 0, 1);
    new actualcmd[55];
    format(actualcmd, sizeof(actualcmd), "cmd_%s", sendcommand);
    CallLocalFunction(actualcmd, "is", id, cmdparams);
    SendClientMessage(playerid, 0xFFFF00FF, "Command Sent.");
    return 1;
}
what i did wrong bro, please tell, i have 5 lavel of admin, so added the levelCheck...
Reply
#8

pawn Code:
CMD:command(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0;
    new id, sendcommand[50], cmdparams;
    if(sscanf(params, "us[50]S[100]", id, sendcommand, cmdparams)) return SendClientMessage(playerid, -1, "USAGE: /command [name/id] [command] [Optional: parameters]");
    if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid Player.");
    if(sendcommand[0] == '/') strdel(sendcommand, 0, 1);
    cmd_sendcommand(id, cmdparams);
    SendClientMessage(playerid, 0xFFFF00FF, "Command Sent.");
    return 1;
}
Would this actually work? 0_o
Give it a shot.
Reply
#9

Quote:
Originally Posted by BenzoAMG
View Post
pawn Code:
CMD:command(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0;
    new id, sendcommand[50], cmdparams;
    if(sscanf(params, "us[50]S[100]", id, sendcommand, cmdparams)) return SendClientMessage(playerid, -1, "USAGE: /command [name/id] [command] [Optional: parameters]");
    if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid Player.");
    if(sendcommand[0] == '/') strdel(sendcommand, 0, 1);
    cmd_sendcommand(id, cmdparams);
    SendClientMessage(playerid, 0xFFFF00FF, "Command Sent.");
    return 1;
}
Would this actually work? 0_o
Give it a shot.
No, it wouldnt because it will try to call command called cmd_sendcommand and i dont think it would even compile. Try this:

pawn Code:
CMD:cmd(playerid, params[])
{
    LoginCheck(playerid);
    LevelCheck(playerid, 5);
   
    new id, sendcommand[50], cmdparams;
    if(sscanf(params, "us[32]s[100]", id, sendcommand, cmdparams)) return SendClientMessage(playerid, -1, "USAGE: /cmd [name/id] [command] [Optional: parameters]");
    if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid Player.");
    if(sendcommand[0] != '/') strins(sendcommand "/", 0);
    new actualcmd[32];
    format(actualcmd, sizeof(actualcmd), "%s %s", sendcommand, cmdparams);
    CallLocalFunction("OnPlayerCommandText", "is", id, actualcmd);
    SendClientMessage(playerid, 0xFFFF00FF, "Command Sent.");
    return 1;
}
Reply
#10

Quote:
Originally Posted by QuaTTrO
View Post
No, it wouldnt because it will try to call command called cmd_sendcommand and i dont think it would even compile. Try this:

pawn Code:
CMD:cmd(playerid, params[])
{
    LoginCheck(playerid);
    LevelCheck(playerid, 5);
   
    new id, sendcommand[50], cmdparams;
    if(sscanf(params, "us[32]s[100]", id, sendcommand, cmdparams)) return SendClientMessage(playerid, -1, "USAGE: /cmd [name/id] [command] [Optional: parameters]");
    if(id == INVALID_PLAYER_ID || !IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Invalid Player.");
    if(sendcommand[0] != '/') strins(sendcommand "/", 0);
    new actualcmd[32];
    format(actualcmd, sizeof(actualcmd), "%s %s", sendcommand, cmdparams);
    CallLocalFunction("OnPlayerCommandText", "is", id, actualcmd);
    SendClientMessage(playerid, 0xFFFF00FF, "Command Sent.");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)