SA-MP Forums Archive
why doesn't || work? - 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: why doesn't || work? (/showthread.php?tid=154103)



why doesn't || work? - MWF2 - 12.06.2010

I have my command /buyheal

I'm trying to make it work for 2 locations, it won't work though



pawn Код:
if(strcmp(cmdtext, "/buyheal", true) == 0)
{
  if(IsSpawned[playerid] == 0) {
    SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
    return 1;
  }
  if (!IsPlayerInDynamicCP(playerid, gCheckpoint[18] || !IsPlayerInDynamicCP(playerid, gCheckpoint[19]))) {
    SendClientMessage(playerid,COLOR_ERROR,"You are not in the hospital checkpoint");
    return 1;
  }
  if(gTeam[playerid] == TEAM_MEDIC) {
    SendClientMessage(playerid,COLOR_ERROR,"You are a Medic. Use /healme or /cureme");
    return 1;
  }
  if(gTeam[playerid] == TEAM_PVTMED) {
    SendClientMessage(playerid,COLOR_ERROR,"You are a Private Medic. Use /healme or /cureme");
    return 1;
  }
  if (!IsPlayerInDynamicCP(playerid, gCheckpoint[18]) || !IsPlayerInDynamicCP(playerid, gCheckpoint[19])) {
    SendClientMessage(playerid,COLOR_ERROR,"You are not at the Los Santos hospital");
    return 1;
  }
  if(GetPlayerMoney(playerid) <= 999 && IsPlayerInCheckpoint(playerid)) {
    SendClientMessage(playerid,COLOR_ERROR,"You cannot afford this Medical Service {$1000)");
    return 1;
  }
  new Float:health;
  GetPlayerHealth(playerid, health);
  if(health == 100) {
    SendClientMessage(playerid,COLOR_ERROR,"You do not have any injuries");
    return 1;
  }
  TogglePlayerDynamicCP(playerid, 18, true) || TogglePlayerDynamicCP(playerid, 19, true);
  {
    SetPlayerHealth(playerid,100);
    GameTextForPlayer(playerid, "~g~HEALED", 6000, 3);
    GivePlayerMoney(playerid,-1000);
    SendClientMessage(playerid,COLOR_FORESTGREEN,"You have purchased Medical services. You have been charged $1000.");
  }
  return 1;
}

I receive no warnings/errors


Re: why doesn't || work? - DJDhan - 12.06.2010

Код:
if(strcmp(cmdtext, "/buyheal", true) == 0)
{
  if(IsSpawned[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
    
  if (!IsPlayerInDynamicCP(playerid, gCheckpoint[18]) && !IsPlayerInDynamicCP(playerid, gCheckpoint[19])) return SendClientMessage(playerid,COLOR_ERROR,"You are not in the hospital checkpoint");
    
  if(gTeam[playerid] == TEAM_MEDIC) return SendClientMessage(playerid,COLOR_ERROR,"You are a Medic. Use /healme or /cureme");
    
  if(gTeam[playerid] == TEAM_PVTMED) return SendClientMessage(playerid,COLOR_ERROR,"You are a Private Medic. Use /healme or /cureme");
    
  if (!IsPlayerInDynamicCP(playerid, gCheckpoint[18]) || !IsPlayerInDynamicCP(playerid, gCheckpoint[19])) return SendClientMessage(playerid,COLOR_ERROR,"You are not at the Los Santos hospital");
    
  if(GetPlayerMoney(playerid) <= 999 && IsPlayerInCheckpoint(playerid)) return SendClientMessage(playerid,COLOR_ERROR,"You cannot afford this Medical Service {$1000)");
    
  new Float:health;
  GetPlayerHealth(playerid, health);
  if(health == 100) return SendClientMessage(playerid,COLOR_ERROR,"You do not have any injuries");
    
  if(IsPlayerInDynamicCP(playerid, gCheckpoint[18])) 
  {
    TogglePlayerDynamicCP(playerid, 18, true); 
    SetPlayerHealth(playerid,100);
    GameTextForPlayer(playerid, "~g~HEALED", 6000, 3);
    GivePlayerMoney(playerid,-1000);
    SendClientMessage(playerid,COLOR_FORESTGREEN,"You have purchased Medical services. You have been charged $1000.");
  }
  if(IsPlayerInDynamicCP(playerid, gCheckpoint[19]))
  {
    TogglePlayerDynamicCP(playerid, 19, true);
    SetPlayerHealth(playerid,100);
    GameTextForPlayer(playerid, "~g~HEALED", 6000, 3);
    GivePlayerMoney(playerid,-1000);
    SendClientMessage(playerid,COLOR_FORESTGREEN,"You have purchased Medical services. You have been charged $1000.");
  }
  return 1;
}



Re: why doesn't || work? - MWF2 - 12.06.2010

I receive an error


expected token: ")", but found "-identifier-"

pawn Код:
if(strcmp(cmdtext, "/buyheal", true) == 0)
{
  if(IsSpawned[playerid] == 0)
  {
    SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
    return 1;
  }
  if (!IsPlayerInDynamicCP(playerid, gCheckpoint[18]) || !IsPlayerInDynamicCP(playerid, gCheckpoint[19]))
  {
    SendClientMessage(playerid,COLOR_ERROR,"You are not in the hospital checkpoint");
    return 1;
  }
  if(gTeam[playerid] == TEAM_MEDIC)
  {
    SendClientMessage(playerid,COLOR_ERROR,"You are a Medic. Use /healme or /cureme");
    return 1;
  }
  if(gTeam[playerid] == TEAM_PVTMED)
  {
    SendClientMessage(playerid,COLOR_ERROR,"You are a Private Medic. Use /healme or /cureme");
    return 1;
  }
  if (!IsPlayerInDynamicCP(playerid, gCheckpoint[18]) || !IsPlayerInDynamicCP(playerid, gCheckpoint[19]))
  {
    SendClientMessage(playerid,COLOR_ERROR,"You are not at the Los Santos hospital");
    return 1;
  }
  if(GetPlayerMoney(playerid) <= 999 && IsPlayerInCheckpoint(playerid))
  {
    SendClientMessage(playerid,COLOR_ERROR,"You cannot afford this Medical Service {$1000)");
    return 1;
  }
  new Float:health;
  GetPlayerHealth(playerid, health);
  if(health == 100)
  {
    SendClientMessage(playerid,COLOR_ERROR,"You do not have any injuries");
    return 1;
  }

  if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true);
  else TogglePlayerDynamicCP(playerid, 19, true);
  {
    SetPlayerHealth(playerid,100);
    GameTextForPlayer(playerid, "~g~HEALED", 6000, 3);
    GivePlayerMoney(playerid,-1000);
    SendClientMessage(playerid,COLOR_FORESTGREEN,"You have purchased Medical services. You have been charged $1000.");
  }
  return 1;
}



Re: why doesn't || work? - [XST]O_x - 12.06.2010

EDIT: Oh noes! wrong line,let me find the right one.

EDIT 2: Here,change:
pawn Код:
if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true);
To:
pawn Код:
if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true));



Re: why doesn't || work? - MWF2 - 12.06.2010

Quote:
Originally Posted by O_x
EDIT: Oh noes! wrong line,let me find the right one.

EDIT 2: Here,change:
pawn Код:
if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true);
To:
pawn Код:
if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true));
Doesn't work.


Re: why doesn't || work? - [XST]O_x - 12.06.2010

Quote:
Originally Posted by MWF2
Quote:
Originally Posted by O_x
EDIT: Oh noes! wrong line,let me find the right one.

EDIT 2: Here,change:
pawn Код:
if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true);
To:
pawn Код:
if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true));
Doesn't work.
Omg I'm such a failure.
Can you show lines please?


Re: why doesn't || work? - MWF2 - 12.06.2010

if i add if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true));


it just crashes.


Код:
if(strcmp(cmdtext, "/buyheal", true) == 0)
{
  if(IsSpawned[playerid] == 0) {
    SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
    return 1;
  }
  if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true));
    SendClientMessage(playerid,COLOR_ERROR,"You are not in the hospital checkpoint");
    return 1;
  }
  if(gTeam[playerid] == TEAM_MEDIC) {
    SendClientMessage(playerid,COLOR_ERROR,"You are a Medic. Use /healme or /cureme");
    return 1;
  }
  if(gTeam[playerid] == TEAM_PVTMED) {
    SendClientMessage(playerid,COLOR_ERROR,"You are a Private Medic. Use /healme or /cureme");
    return 1;
  }
  if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true));
    SendClientMessage(playerid,COLOR_ERROR,"You are not at the Los Santos hospital");
    return 1;
  }
  if(GetPlayerMoney(playerid) <= 999 && IsPlayerInCheckpoint(playerid)) {
    SendClientMessage(playerid,COLOR_ERROR,"You cannot afford this Medical Service {$1000)");
    return 1;
  }
  new Float:health;
  GetPlayerHealth(playerid, health);
  if(health == 100) {
    SendClientMessage(playerid,COLOR_ERROR,"You do not have any injuries");
    return 1;
  }
  TogglePlayerDynamicCP(playerid, 18, true) || TogglePlayerDynamicCP(playerid, 19, true);
  {
    SetPlayerHealth(playerid,100);
    GameTextForPlayer(playerid, "~g~HEALED", 6000, 3);
    GivePlayerMoney(playerid,-1000);
    SendClientMessage(playerid,COLOR_FORESTGREEN,"You have purchased Medical services. You have been charged $1000.");
  }
  return 1;
}



Re: why doesn't || work? - DJDhan - 12.06.2010

I have modified my post.

EDIT: Again.


Re: why doesn't || work? - [XST]O_x - 12.06.2010

Quote:
Originally Posted by MWF2
if i add if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true));


it just crashes.


Код:
if(strcmp(cmdtext, "/buyheal", true) == 0)
{
  if(IsSpawned[playerid] == 0) {
    SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
    return 1;
  }
  if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true));
    SendClientMessage(playerid,COLOR_ERROR,"You are not in the hospital checkpoint");
    return 1;
  }
  if(gTeam[playerid] == TEAM_MEDIC) {
    SendClientMessage(playerid,COLOR_ERROR,"You are a Medic. Use /healme or /cureme");
    return 1;
  }
  if(gTeam[playerid] == TEAM_PVTMED) {
    SendClientMessage(playerid,COLOR_ERROR,"You are a Private Medic. Use /healme or /cureme");
    return 1;
  }
  if(IsPlayerInDynamicCP(playerid, gCheckpoint[18]) TogglePlayerDynamicCP(playerid, 18, true));
    SendClientMessage(playerid,COLOR_ERROR,"You are not at the Los Santos hospital");
    return 1;
  }
  if(GetPlayerMoney(playerid) <= 999 && IsPlayerInCheckpoint(playerid)) {
    SendClientMessage(playerid,COLOR_ERROR,"You cannot afford this Medical Service {$1000)");
    return 1;
  }
  new Float:health;
  GetPlayerHealth(playerid, health);
  if(health == 100) {
    SendClientMessage(playerid,COLOR_ERROR,"You do not have any injuries");
    return 1;
  }
  TogglePlayerDynamicCP(playerid, 18, true) || TogglePlayerDynamicCP(playerid, 19, true);
  {
    SetPlayerHealth(playerid,100);
    GameTextForPlayer(playerid, "~g~HEALED", 6000, 3);
    GivePlayerMoney(playerid,-1000);
    SendClientMessage(playerid,COLOR_FORESTGREEN,"You have purchased Medical services. You have been charged $1000.");
  }
  return 1;
}
Dude I meant the lines that had the errors xD
But never mind DJDhan solved it for you xD


Re: why doesn't || work? - MWF2 - 12.06.2010

Still didn't work. It says i'm not in the checkpoint when i am.



It works fine for 1 checkpoint