Something is wrong with my afk cmd...
#1

Hey,
I want to make the cmd /afk [minutes].But with my code it says for exemple: "Player (ID:0) is now in AFK-Mode ! Minutes:z"

Here is my script:
Код:
  	if(strcmp(cmd, "/afk", true) == 0)
  {
  new tmp[128];
  tmp = strtok(cmdtext, idx);
  if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /afk [minutes]");
  new name[MAX_PLAYER_NAME+1];
  new string[128];
  GetPlayerName(playerid, name, sizeof(name));
  format(string, sizeof(string), "%s (ID:%i) is now in AFK-Mode ! Minutes:%z.", name,playerid,strlen(tmp));
  SendClientMessageToAll(0xDBD993FF,string);
  return 1;
  }
I hope someone will find whatґs wrong...
Reply
#2

Replace:
pawn Код:
format(string, sizeof(string), "%s (ID:%i) is now in AFK-Mode ! Minutes:%z.", name,playerid,strlen(tmp));
With:
pawn Код:
format(string, sizeof(string), "%s (ID:%i) is now in AFK-Mode ! Minutes:%d.", name,playerid,strlen(tmp));
That should work, if the rest of your code is correct =)

Good luck!
Reply
#3

Sry this doesnґt work . It will just count how many numbers are behind /afk (for example : by typing /afk 222222 you get 6 Minutes)
Reply
#4

Quote:
Originally Posted by SEC
Sry this doesnґt work . It will just count how many numbers are behind /afk (for example : by typing /afk 222222 you get 6 Minutes)
Then I don't really get what you want with that command :O
On sight, I assumed you wanted to get this:

When a player types /afk 3 you want to say (example):
Test (ID:0) is now in AFK-Mode ! Minutes:3

It wont do something else (like, put [AFK] in front of the player's name, or whatever), you haven't scripted it.
Reply
#5

Quote:
Originally Posted by SEC
Sry this doesnґt work . It will just count how many numbers are behind /afk (for example : by typing /afk 222222 you get 6 Minutes)
Use strval and not strlen
Reply
#6

thank you , that was what i was searching for .
Reply
#7

Quote:
Originally Posted by mabako
Quote:
Originally Posted by SEC
Sry this doesnґt work . It will just count how many numbers are behind /afk (for example : by typing /afk 222222 you get 6 Minutes)
Use strval and not strlen
Looooool! I don't pay enough attention
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)