Make a cmd that simulates a player is typed another cmd? - 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: Make a cmd that simulates a player is typed another cmd? (
/showthread.php?tid=363956)
Make a cmd that simulates a player is typed another cmd? -
TheDeath - 29.07.2012
hello is there any way to simulate sending cmd.I have commands /drift1 /drift2 /drift3 /drift4..... They are all strcmp.But i want to make it with dcmdto read /drift[space][NUMBER]
So i want to ask how i can make when player enter any number to make him send cmd "/drift[NUMBER]"
I just want someone to tell me the command not to write me the script!
Re: Make a cmd that simulates a player is typed another cmd? -
TheDeath - 29.07.2012
Bump
Re: Make a cmd that simulates a player is typed another cmd? -
pasha97 - 29.07.2012
Try:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/drift", true) == 0)
{
new tmp[128],string(256);
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /drift[number]");
format(string,sizeof(string),"/drift%d",strval(tmp));
CallRemoteFunction("OnPlayerCommandText", "ds", playerid,string);
return 1;
}
return 0;
}
}
Re: Make a cmd that simulates a player is typed another cmd? -
[MM]RoXoR[FS] - 29.07.2012
I prefer using sscanf.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(drift,5,cmdtext);
return 0;
}
dcmd_drift(playerid,params[])
{
new id;
if(sscanf(params,"i",id)) return SendClientMessage(playerid,-1,"Usage : /drift [id]");
switch (id)
{
case 1 : //Equivalent to /drift1
case 2 : ///drift2 and so on
}
return 1;
}
Re: Make a cmd that simulates a player is typed another cmd? -
pasha97 - 29.07.2012
Quote:
Originally Posted by [MM]RoXoR[FS]
I prefer using sscanf.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(drift,5,cmdtext); return 0; }
dcmd_drift(playerid,params[]) { new id; if(sscanf(params,"i",id)) return SendClientMessage(playerid,-1,"Usage : /drift [id]"); switch (id) { case 1 : //Equivalent to /drift1 case 2 : ///drift2 and so on } return 1; }
|
yeah, sscanf is much easier
Re: Make a cmd that simulates a player is typed another cmd? -
TheDeath - 29.07.2012
Thanks my problem was not to make the cmd my question was how to make it to send:
Thanks, pasha97:
pawn Код:
CallRemoteFunction("OnPlayerCommandText", "ds", playerid,string);
Thanks [MM]RoXoR[FS],
I will definely use sscanf + dcmd
REP+ to the two of you.
Sorry for my bad english