SA-MP Forums Archive
rcmd, like dcmd but for rcon commands! - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: rcmd, like dcmd but for rcon commands! (/showthread.php?tid=67526)



rcmd, like dcmd but for rcon commands! - Daren_Jacobson - 02.03.2009

the define:
pawn Код:
#define rcmd(%1,%2,%3) if (!strcmp((%3)[0], #%1, true, (%2)) && ((((%3)[(%2)] == '\0') && (rcmd_%1(""))) || (((%3)[(%2)] == ' ') && (rcmd_%1((%3)[(%2) + 1]))))) return 1
the usage:
pawn Код:
public OnRconCommand(cmd[])
{
   rcmd(cmdnamenoslash, 14, cmd); //14 is the length, cmd is the param passed by OnRconCommand
   return 1;
}
the usage:
pawn Код:
rcmd_cmdnamenoslash(params[])
{
   new Float:x, Float:y;
   if (sscanf(params, "ff", x, y)) print("USAGE: /cmdnamenoslash [x] [y]");
   else
   {      
          printf("%f", AngleToPoint(0.0, 0.0, x, y));
   }
   return 1;
}
if you call it by using /rcon cmdnamenoslash then any prints in the code will print to your in-game screen.


Re: rcmd, like dcmd but for rcon commands! - Daren_Jacobson - 02.03.2009

except i took out the stuff for the /, yours would return mdnamenoslash and than if you were passing paramters they wouldn't work, it would think that wasn't the command, cause cmdnamenoslash 534.0 348.0 would make it think that the command you were typing was mdnamenoslash 5, and that isn't cmdnamenoslash, now is it?

edit, i also got rid of playerid, you can make your own and do something like playerid = ReturnUser("Daren_Jacobson") than have it pass playerid


Re: rcmd, like dcmd but for rcon commands! - Daren_Jacobson - 02.03.2009

i almost just fainted, have i mentioned i idol you?