05.08.2009, 20:24
Hi,
when i type /Chan it says
USAGE: /Chan [channel id] ( it suppose to do that )
but when i type /Chan 63 for example it says "Unknown Command", here is the code:
Fix me, thanks
when i type /Chan it says
USAGE: /Chan [channel id] ( it suppose to do that )
but when i type /Chan 63 for example it says "Unknown Command", here is the code:
pawn Код:
#include <a_samp>
new Chan[MAX_PLAYERS] = 0;
public OnPlayerText(playerid, text[])
{
if(Chan[playerid] >= 1)
{
new str[256];
new pName[17];
GetPlayerName(playerid, pName, 17);
format(str, 256, "%s: %s (Channel :%d)",pName, text, Chan[playerid]);
SendClientMessageToChan(Chan[playerid], 0xF6F6F6AA, str);
return 0;
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
new tmp[128];
if (strcmp("/Chan", cmdtext, true, 10) == 0)
{
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /Chan [channel id]");
Chan[playerid] = strval(tmp);
return 1;
}
return 0;
}
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;
}
SendClientMessageToChan(ChanID, color, const msg[])
{
for (new i = 0; i >= GetMaxPlayers(); i++)
{
if(Chan[i] == ChanID)
{
SendClientMessage(i, color, msg);
}
}
}