SA-MP Forums Archive
[HELP] Commands Again... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Commands Again... (/showthread.php?tid=97265)



[HELP] Commands Again... - Smiths - 13.09.2009

I got Loose Identations into this :

pawn Код:
if(strcmp(cmdtext, "/medic", true) == 0) {
    SetJob(1,playerid);
    SetPlayerColor(playerid,0x33AA33AA);
    GameTextForPlayer(playerid,"~w~You Have Joined The ~n~~g~Medic~w~ Team",3000,4);
    new pName[MAX_PLAYER_NAME];
  new string[48];
  GetPlayerName(playerid, pName, sizeof(pName));
  format(string, sizeof(string), "[ %s ] has joined the Medic Team.", pName);
  SendClientMessageToAll(0xFFFFFFAA, string);
  SetPlayerSkin(playerid,275);
  GivePlayerWeapon(playerid, 3, 1);
    return 1;
 }
 if(strcmp(cmdtext, "/trucker", true) == 0) {
    SetJob(1,playerid);
    SetPlayerColor(playerid,0x33AA33AA);
    GameTextForPlayer(playerid,"~w~You Have Joined The ~n~~r~Trucker~w~ Team",3000,4);
    new pName[MAX_PLAYER_NAME];
  new string[48];
  GetPlayerName(playerid, pName, sizeof(pName));
  format(string, sizeof(string), "[ %s ] has joined the Trucker Team.", pName);
  SendClientMessageToAll(0xFFFFFFAA, string);
  SetPlayerSkin(playerid,275);
  GivePlayerWeapon(playerid, 3, 1);
    return 1;
 }
Why?

Full Code Here :

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128];
new idx;
cmd = strtok(cmdtext, idx);

if(strcmp(cmdtext, "/help", true) == 0) {
SendClientMessage(playerid, 0xFF9900AA, "•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••");
SendClientMessage(playerid, 0x33CCFFAA, "Eska Town RolePlayer - Help");
SendClientMessage(playerid, 0x33CCFFAA, "JOBS : /police /medic /trucker");
SendClientMessage(playerid, 0xFF9900AA, "•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••");
return 1;
}
if(strcmp(cmdtext, "/police", true) == 0) {
    SetJob(1,playerid);
    SetPlayerColor(playerid,0x0000BBAA);
    GameTextForPlayer(playerid,"~w~You Have Joined The ~n~~b~Police~w~ Team",3000,4);
    new pName[MAX_PLAYER_NAME];
  new string[48];
  GetPlayerName(playerid, pName, sizeof(pName));
  format(string, sizeof(string), "[ %s ] has joined the Police Team.", pName);
  SendClientMessageToAll(0xFFFFFFAA, string);
  SetPlayerSkin(playerid,266);
  GivePlayerWeapon(playerid, 3, 1);
    return 1;
 }
 if(strcmp(cmdtext, "/medic", true) == 0) {
    SetJob(1,playerid);
    SetPlayerColor(playerid,0x33AA33AA);
    GameTextForPlayer(playerid,"~w~You Have Joined The ~n~~g~Medic~w~ Team",3000,4);
    new pName[MAX_PLAYER_NAME];
  new string[48];
  GetPlayerName(playerid, pName, sizeof(pName));
  format(string, sizeof(string), "[ %s ] has joined the Medic Team.", pName);
  SendClientMessageToAll(0xFFFFFFAA, string);
  SetPlayerSkin(playerid,275);
  GivePlayerWeapon(playerid, 3, 1);
    return 1;
 }
 if(strcmp(cmdtext, "/trucker", true) == 0) {
    SetJob(1,playerid);
    SetPlayerColor(playerid,0x33AA33AA);
    GameTextForPlayer(playerid,"~w~You Have Joined The ~n~~r~Trucker~w~ Team",3000,4);
    new pName[MAX_PLAYER_NAME];
  new string[48];
  GetPlayerName(playerid, pName, sizeof(pName));
  format(string, sizeof(string), "[ %s ] has joined the Trucker Team.", pName);
  SendClientMessageToAll(0xFFFFFFAA, string);
  SetPlayerSkin(playerid,275);
  GivePlayerWeapon(playerid, 3, 1);
    return 1;
 }
return 0;
}
Thank you for helping me


Re: [HELP] Commands Again... - Smiths - 13.09.2009

Bump help please


Re: [HELP] Commands Again... - Clavius - 13.09.2009

That's because you have bad indentation:
pawn Код:
if(strcmp(cmdtext, "/medic", true) == 0)
    {
        SetJob(1,playerid);
        SetPlayerColor(playerid,0x33AA33AA);
        GameTextForPlayer(playerid,"~w~You Have Joined The ~n~~g~Medic~w~ Team",3000,4);
        new pName[MAX_PLAYER_NAME];
        new string[48];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(string, sizeof(string), "[ %s ] has joined the Medic Team.", pName);
        SendClientMessageToAll(0xFFFFFFAA, string);
        SetPlayerSkin(playerid,275);
        GivePlayerWeapon(playerid, 3, 1);
        return 1;
    }
    if(strcmp(cmdtext, "/trucker", true) == 0)
    {
        SetJob(1,playerid);
        SetPlayerColor(playerid,0x33AA33AA);
        GameTextForPlayer(playerid,"~w~You Have Joined The ~n~~r~Trucker~w~ Team",3000,4);
        new pName[MAX_PLAYER_NAME];
        new string[48];
        GetPlayerName(playerid, pName, sizeof(pName));
        format(string, sizeof(string), "[ %s ] has joined the Trucker Team.", pName);
        SendClientMessageToAll(0xFFFFFFAA, string);
        SetPlayerSkin(playerid,275);
        GivePlayerWeapon(playerid, 3, 1);
        return 1;
    }
is correct.


Re: [HELP] Commands Again... - Smiths - 13.09.2009

Thank you it work great! But can you just show me my errors please... i really want to learn!


Re: [HELP] Commands Again... - Clavius - 13.09.2009

Quote:
Originally Posted by Pawn Language Guide
217
Loose Indentation
Statements at the same logical level do not start in the same
column; that is, the indents of the statement are different.
Although PAWN is a free format language, loose indentation
frequently hides a logical error in the control flow.
[...]
The above is from the Pawn Language Guide, discussing error 217, which is loose indentation.

Here is an example of a badly indented code:
pawn Код:
public SomeCallBack(something, something2)
{
      if (SomeFunction(something) > 10)
 {
   SomeThing(something2);
  }
   else DoWhatever();
}
and here is the correct version of the above code:
pawn Код:
public SomeCallBack(something, something2)
{
    if (SomeFunction(something) > 10)
    {
        SomeThing(something2);
    }
    else DoWhatever();
}
pawn Код:
// logical level 0
    // logical level 1
        // logical level 2
    // logical level 1
        // etc