02.01.2012, 16:01
Here is the code of afk replace it i fixed it
Here is strtok function add it any where in script but not in cmds
+REP if i helped so
pawn Код:
if(strcmp("/afk",cmd,true) == 0)
{
new tmp[256], cmd[128];
new string[256], index;
tmp = strtok(cmdtext,index);
if(afk[playerid] == 0)
{
if(!strlen(tmp))
{
SendClientMessage(playerid,COLOR_RED,"Usage:/afk[reason]");
return 1;
}
afk[playerid] = 1;
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "WARNING->%s Is AFK [Reason->%s]<-WARNING", playername,tmp);
SendClientMessageToAll(COLOR_YELLOW, string);
TogglePlayerControllable(playerid,0);
}
else
{
afk[playerid] = 0;
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), "->%s Is Back On Keyboard<-", playername);
SendClientMessageToAll(COLOR_YELLOW, string);
TogglePlayerControllable(playerid,1);
SetPlayerHealth(playerid,100);
}
return 1;
}
pawn Код:
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;
}