Two commands doing the same thing
#1

Is there a way for like two commands to do the same thing without having to copy and paste the whole code twice?

For example, I want /a and /b to do the samething, but not have to do

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext, "/a", true) == 0)
  {
   // CODE
   return 1;
  }
  if(strcmp(cmdtext, "/b", true) == 0)
  {
   // SAME CODE
   return 1;
  }
  return 0;
}
Reply
#2

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext, "/a", true) == 0||strcmp(cmdtext, "/b", true) == 0)
  {
   // TEH CODEZ FOR U XD
   return 1;
  }
  return 0;
}
Reply
#3

Thank you, . But is there a way to implement dmcd in this manner?
Reply
#4

hi
pawn Код:
if(strcmp(cmdtext, "/a", true) == 0)

// /a is 2 character so it should be
                       
if(strcmp(cmdtext, "/a", true) == 2)
Reply
#5

Why would you need to implement dcmd on a /b function..?
Reply
#6

Код:
dcmd_some-kind-of-command(playerid,params[])
{
	//code here
}
dcmd_other-command-with-other-name-but-the-same-result(playerid,params[])
{
	return dcmd_some-kind-of-command(playerid, params);
}



Quote:
Originally Posted by snoob
hi
pawn Код:
if(strcmp(cmdtext, "/a", true) == 0)

// /a is 2 character so it should be
                       
if(strcmp(cmdtext, "/a", true) == 2)
wut d fook? It should be 0 not 2 because i don't know what what .. what!? It definately needs to be 0...
Reply
#7

Quote:
Originally Posted by Memoryz
Why would you need to implement dcmd on a /b function..?
Eh, I was just using it as an example, I'm trying to develop a /su(spect) command for Cops, so that's why. And thanks Ronyx, I'll try it out.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)