Author Topic: Skins  (Read 2233 times)

0 Members and 1 Guest are viewing this topic.

Offline kitt85711

  • Wiseguy
  • **
  • Posts: 72
    • View Profile
Skins
« on: March 10, 2012, 07:07:51 am »
Can I get help on how I would fix my skin cmd? When your at a certain place and you are aloud that function for instance, I'm a cop I want to be like a UC cop, I have to go to the station to become that but I get a warning in my command. Can someone tell me how to fix this? I already have "cop," at the enum pInfo so I got that defined.

}
   else if (strcmp(cmd, "!cop", true) == 0) {
      if (PlayerInfo[playerid][Logged] != 1) SendClientMessage(playerid, COLOR_GREEN, "Please login first");
      else {
         new szMsg[256];
         SetPlayerSkin(playerid, 1);
         SetPlayerWeapon(playerid, 17, 500);
         SetPlayerWeapon(playerid, 19, 500);
         PlayerInfo[playerid][cop] = 1;
         format(szMsg, sizeof(szMsg), "Welcome to the force, officer %s", gPlayers[playerid]);
         SendClientMessage(playerid, COLOR_GREEN, szMsg);
         SendClientMessage(playerid, COLOR_GREEN, "!cophelp");
         SetSpikes(playerid,1);
      }
      return 1;

And the warning I get says: warning 219: local variable "szMsg" shadows a variable at a preceding level

How would I fix this so I can remove the 5 warnings I have?

Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: Skins
« Reply #1 on: March 10, 2012, 10:28:30 am »
If it "shadows a variable at a preceding level," you already have szMsg defined outside of that else if. Get rid of new szMsg[256]; in that command and it shouldn't throw a warning. If I recall, it should work correctly regardless.
Do not PM me for support.




Offline YoMan

  • Street Thug
  • *
  • Posts: 17
    • View Profile
Re: Skins
« Reply #2 on: March 10, 2012, 01:33:11 pm »
Warning Compile the Script But the Error Cant Compile