31.12.2010, 10:02
can someone code me for announce ?
if(strcmp(cmd, "/announce", true) == 0)
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
new tmp[256],tmp2[256];
#pragma unused tmp
#pragma unused tmp2
#pragma unused idx
new name[MAX_PLAYER_NAME],string[128];
GetPlayerName(playerid,name,sizeof(name));
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0x00FF40FF, "USAGE: /announce <text>");
format(string,sizeof(string),"%s: %s",name,cmdtext[10]);
GameTextForAll(string,2000,5);
return 1;
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;
}
}
Here's one basic:
pawn Code:
|
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(announce, 8, cmdtext);
return 0;
}
dcmd_announce(playerid,params[])
{
if(!strlen(params)) return SendClientMessage(playerid, 0x21DD00FF,"USAGE: /announce [Text]");
return GameTextForAll(params,4000,3);
}
if(strcmp(cmd, "/announce", true) == 0)
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
new tmp[256],tmp2[256];
#pragma unused tmp
#pragma unused tmp2
#pragma unused idx
new name[MAX_PLAYER_NAME],string[128];
GetPlayerName(playerid,name,sizeof(name));
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0x00FF40FF, "USAGE: /announce <text>");
format(string,sizeof(string),"%s: %s",name,cmdtext[10]);
GameTextForAll(string,2000,5);
return 1;
}
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;
}
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(announce, 8, cmdtext);
return 0;
}
dcmd_announce(playerid,params[])
{
if(!strlen(params)) return SendClientMessage(playerid, 0x21DD00FF,"USAGE: /announce [Text]");
return GameTextForAll(params,4000,3);
}