20.07.2009, 02:44
its very easy
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:
EDIT: I realize mine isn't as good as others and doesn't check how much cash you got, but it should work fine.
Код:
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 }
![Cheesy](images/smilies/biggrin.png)
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; }