01.10.2011, 17:42
It doesnt work!
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new tmp[256];
new idx;
new cmd[256];
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/evento", true) == 0)
{
new eventcmd;
tmp = strtok(cmdtext, idx);
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_YELLOW, "You are not admin");
return 1;
}
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_YELLOW, "Usage: /evento motos");
SendClientMessage(playerid, COLOR_YELLOW, "Usage: /evento amatar");
SendClientMessage(playerid, COLOR_YELLOW, "Usage: /evento polis");
return 1;
}
if(strcmp(tmp, "name", true)==0)
eventcmd = 1;
else if(strcmp(tmp, "say", true)==0)
eventcmd = 2;
else if(strcmp(tmp, "raw", true)==0)
eventcmd = 3;
tmp = strtok(cmdtext, idx);
if(eventcmd < 4 && !strlen(tmp))
{
if(eventcmd==0)
SendClientMessage(playerid, COLOR_YELLOW, "Usage: /evento [Motos, Amatar, Polis]");
else if(eventcmd==1)
SendClientMessage(playerid, COLOR_YELLOW, "Usage: /evento motos");
else if(eventcmd==2)
SendClientMessage(playerid, COLOR_YELLOW, "Usage: /evento amatar");
else if(eventcmd==3)
SendClientMessage(playerid, COLOR_YELLOW, "Usage: /evento polis");
return 1;
}
if(eventcmd==1)//Bot Name
{
SendClientMessage(playerid, COLOR_YELLOW, "1");
}
else if (eventcmd==2)//Bot say
{
SendClientMessage(playerid, COLOR_YELLOW, "2");
}
else if (eventcmd==3)//Bot raw
{
SendClientMessage(playerid, COLOR_YELLOW, "3");
}
return 1;
}
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;
}