04.09.2010, 23:56
(
Последний раз редактировалось zack3021; 05.09.2010 в 00:34.
)
When i type /jail1 [id], that works fine, but if i type /jail2 [id] if gives the return saying USAGE: jail2 [id]
Here is my code:
And the Strtok:
Can you tell me the problem, because everytime i type any command under /jail1 if gives me the return and not make me jail the player (it is not an admin fs, just a normal jail command for cops)
OK to make it simpler. When i type /jail1 [the players id here] it works, But if i type /jail 2 [the players id here] it says
USAGE: /jail3 [id]
Here is my code:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], tmp[256], idx;
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/jail1", true))
{
new id;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /jail1 [id]");
id = strval(tmp);
SetPlayerPos(id, 2756.1196,690.8884,10.8984);
return 1;
}
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/jail2", true))
{
new id;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /jail2 [id]");
id = strval(tmp);
SetPlayerPos(id, 2755.4023,683.8808,10.8984);
return 1;
}
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/jail3", true))
{
new id;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /jail3 [id]");
id = strval(tmp);
SetPlayerPos(id, 2756.1255,676.9288,10.8984);
return 1;
}
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/jail4", true))
{
new id;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /jail4 [id]");
id = strval(tmp);
SetPlayerPos(id, 2756.1243,668.4799,10.8984);
return 1;
}
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/jail5", true))
{
new id;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /jail5 [id]");
id = strval(tmp);
SetPlayerPos(id, 2755.9297,660.0413,10.8984);
return 1;
}
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/jail6", true))
{
new id;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /jail6 [id]");
id = strval(tmp);
SetPlayerPos(id, 2755.7139,652.2241,10.8984);
return 1;
}
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/jail7", true))
{
new id;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /jail7 [id]");
id = strval(tmp);
SetPlayerPos(id, 2755.5430,645.7413,10.8984);
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;
}
OK to make it simpler. When i type /jail1 [the players id here] it works, But if i type /jail 2 [the players id here] it says
USAGE: /jail3 [id]

