Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: Fuzzy168 on June 16, 2011, 06:40:10 am

Title: Whats wrong?
Post by: Fuzzy168 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]
Title: Re: Whats wrong?
Post by: stormeus 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]
Title: Re: Whats wrong?
Post by: Madara 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 ;)