SA-MP Forums Archive
how to make other player to do a command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: how to make other player to do a command (/showthread.php?tid=499402)



how to make other player to do a command - Dipto - 08.03.2014

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.


Re: how to make other player to do a command - SkilledMaster - 08.03.2014

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


Re: how to make other player to do a command - Threshold - 08.03.2014

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


Re: how to make other player to do a command - Dipto - 08.03.2014

thanks BenzoAMG man, awesome, at last i got this command


Re: how to make other player to do a command - Dipto - 08.03.2014

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


Re: how to make other player to do a command - Threshold - 08.03.2014

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.


Re: how to make other player to do a command - Dipto - 08.03.2014

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...


Re: how to make other player to do a command - Threshold - 09.03.2014

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.


Re: how to make other player to do a command - QuaTTrO - 09.03.2014

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



Re: how to make other player to do a command - Dipto - 09.03.2014

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