rcmd, like dcmd but for rcon commands!
#1

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)