Make a cmd that simulates a player is typed another cmd?
#1

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!
Reply
#2

Bump
Reply
#3

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



}
Reply
#4

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;
}
Reply
#5

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
Reply
#6

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)