Author Topic: Whats wrong?  (Read 2528 times)

0 Members and 1 Guest are viewing this topic.

Offline Fuzzy168

  • VC:MP Veteran
  • *****
  • Posts: 729
  • Programming since 2011
    • View Profile
Whats wrong?
« on: June 16, 2011, 06:40:10 am »
Is there anything wrong with this command? I try it and it says
Quote
VC-MP Mode has cloak activated

[pawn]   else if (strcmp(cmd, "cloak", true) == 0)
      SendClientMessage(playerid, COLOR_GREEN, "You have been cloaked!");
      SendClientMessage(playerid, COLOR_GREEN, "Your cloak will only be available until your death.");
      SendClientMessageToAll(COLOR_GREEN, "%s has cloak activated!");
      RemovePlayerMarker(playerid);
      return 1;
   }[/pawn]
I'm beginning to feel like a Lag God, Lag God

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: Whats wrong?
« Reply #1 on: June 16, 2011, 06:47:33 am »
[pawn]
SendClientMessageToAll(COLOR_GREEN, "%s has cloak activated!");
[/pawn]

%s won't automatically substitute the player's name in. SendClientMessageToAll also won't format the message by itself. You need to do this:

[pawn]
new string[48];
format(string, sizeof(string), "%s has cloak activated!", gPlayers[playerid]);
SendClientMessageToAll(COLOR_GREEN, string);
[/pawn]
Do not PM me for support.




Offline Madara

  • Street Thug
  • *
  • Posts: 48
    • View Profile
Re: Whats wrong?
« Reply #2 on: June 16, 2011, 08:43:37 am »
[pawn]   else if (strcmp(cmd, "cloak", true) == 0) // <- here "{" not implemented
      SendClientMessage(playerid, COLOR_GREEN, "You have been cloaked!");
      SendClientMessage(playerid, COLOR_GREEN, "Your cloak will only be available until your death.");
      SendClientMessageToAll(COLOR_GREEN, "%s has cloak activated!");// <- "SendClientMessage" or "SendClientMessageToAll" are not functions for consult a argument or arguments. Only text or strings text wrapped, in thid case a format.
      RemovePlayerMarker(playerid);
      return 1;
   }[/pawn]

Line 1 of that code: have not implemented a key start, so, if you implement:
Code: [Select]
return 1;
}
Would need a "{" go above where the code starts.

Line 4 of that code: "SendClientMessage" or "SendClientMessageToAll" are not functions for consult a argument or arguments. Only text or strings text wrapped.

Fixed code:
[pawn]   else if (strcmp(cmd, "cloak", true) == 0) {
      new stmp[256];
      SendClientMessage(playerid, COLOR_GREEN, "You have been cloaked!");
      SendClientMessage(playerid, COLOR_GREEN, "Your cloak will only be available until your death.");
      format(stmp,256,"%s has cloak activated!",gPlayers[playerid]);//<- or other consult player name
      SendClientMessageToAll(COLOR_GREEN, stmp);
      RemovePlayerMarker(playerid);
      return 1;
   }[/pawn]

Hope this helps and regards ;)
« Last Edit: June 16, 2011, 08:56:27 am by Madara »