I need a quick /ad command
#7

its very easy

Код:
public OnPlayerCommandText

new cmd[128], idx;
cmd = strtok(cmdtext, idx);

if (strcmp(cmd, "/ad", true)==0)
{
  new tmp[128];
  tmp = strtok(cmdtext, idx);

  if (strlen(tmp)==0) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /ad (text)"); // 0xFF0000AA is Red

  new adstring[128], pname[24];
  format(adstring, sizeof(adstring), "ADVERTISEMENT: %s, contact: %s [%i]", tmp, pname, (playerid));
  SendClientMessageToAll(0xFFFF00AA, adstring); // 0xFFFF00AA is yellow
  //GivePlayerMoney(playerid, -5) ;
  //GameTextForPlayer(playerid, "~r~-$5", 1500, 1);
  // remove the //'s from in front of the two lines above this if you want it to cost the player $5 to advertise
}
there ya go just copy and paste that at the top of your "OnPlayerCommandText"

yea yea i know it uses strtok, if you dont have <dutils.inc> with your game mode, past this at the bottom of the file:

Код:
stock strtok(const string[], &index)
{
	new length = strlen(string);
	while ((index < length) && (string[index] <= ' '))
	{
		index++;
	}
 
	new offset = index;
	new result[20];
	while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
	{
		result[index - offset] = string[index];
		index++;
	}
	result[index - offset] = EOS;
	return result;
}
EDIT: I realize mine isn't as good as others and doesn't check how much cash you got, but it should work fine.
Reply


Messages In This Thread
I need a quick /ad command - by killdahobo99 - 20.07.2009, 01:54
Re: I need a quick /ad command - by Correlli - 20.07.2009, 01:57
Re: I need a quick /ad command - by killdahobo99 - 20.07.2009, 02:04
Re: I need a quick /ad command - by Correlli - 20.07.2009, 02:05
Re: I need a quick /ad command - by killdahobo99 - 20.07.2009, 02:22
Re: I need a quick /ad command - by Grim_ - 20.07.2009, 02:29
Re: I need a quick /ad command - by Annihalation - 20.07.2009, 02:44
Re: I need a quick /ad command - by killdahobo99 - 20.07.2009, 02:57

Forum Jump:


Users browsing this thread: 1 Guest(s)