I have a question
#1

Well,I wanna know if someone can give a working rate to this command:

pawn Код:
COMMAND:heal(playerid,params[])
{
    if(gTeam[playerid] == TEAM_MEDICS)
    {
       new p1;
       new p2;
       new Float:health;
       if(sscanf(params,"u",p2)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /heal [id]");
       else if(!IsPlayerConnected(p2)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
       else if(p2 == playerid) return SendClientMessage(playerid,COLOR_RED,"You cannot heal yourself");
       GetPlayerHealth(p2,health);
       if(health < 80)
       {
         GetDistanceBetweenPlayers(p1,p2);
         if(GetDistanceBetweenPlayers(p1,p2) > 5) return SendClientMessage(p1,COLOR_RED,"Player is too far away");
         if(GetDistanceBetweenPlayers(p1,p2) < 5)
         {
             GetPlayerMoney(p2);
             if(GetPlayerMoney(p2) > 500)
             {
                SetPlayerHealth(p2,100);
                GivePlayerMoney(p2,-500);
                GivePlayerMoney(p1,500);
                new medicname[24];
                new injuriedname[24];
                GetPlayerName(p1,medicname,sizeof(medicname));
                GetPlayerName(p2,injuriedname,sizeof(injuriedname));
                new string[128];
                format(string,sizeof(string),"Player %s has been healed by medic %s",injuriedname,medicname);
                SendClientMessageToAll(COLOR_PURPLE,string);
             }
             if(GetPlayerMoney(p2) < 500) return SendClientMessage(p1,COLOR_YELLOW,"The player doesn't have enough money");
         }
         if(health > 80) return SendClientMessage(playerid,COLOR_GREEN,"The player doesn't need to be healed");
      }
      if(gTeam[playerid] == TEAM_COPS || gTeam[playerid] == TEAM_ROBBERS || gTeam[playerid] == TEAM_FIREFIGHTERS) return SendClientMessage(playerid,COLOR_RED,"This command is only for medics.");
     }
  return true;
}
Else tell me if you spot an error,because when I choose another team and I type heal nothing happens,though it should say this command is only for medics,and I can't test it right now so do you think the command would work?
Reply
#2

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
Well,I wanna know if someone can give a working rate to this command:

Else tell me if you spot an error,because when I choose another team and I type heal nothing happens,though it should say this command is only for medics,and I can't test it right now so do you think the command would work?
I moved 4th-from-the-bottom line. It should work now:


pawn Код:
COMMAND:heal(playerid,params[])
{
    if(gTeam[playerid] == TEAM_MEDICS)
    {
       new p1;
       new p2;
       new Float:health;
       if(sscanf(params,"u",p2)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /heal [id]");
       else if(!IsPlayerConnected(p2)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
       else if(p2 == playerid) return SendClientMessage(playerid,COLOR_RED,"You cannot heal yourself");
       GetPlayerHealth(p2,health);
       if(health < 80)
       {
         GetDistanceBetweenPlayers(p1,p2);
         if(GetDistanceBetweenPlayers(p1,p2) > 5) return SendClientMessage(p1,COLOR_RED,"Player is too far away");
         if(GetDistanceBetweenPlayers(p1,p2) < 5)
         {
             GetPlayerMoney(p2);
             if(GetPlayerMoney(p2) > 500)
             {
                SetPlayerHealth(p2,100);
                GivePlayerMoney(p2,-500);
                GivePlayerMoney(p1,500);
                new medicname[24];
                new injuriedname[24];
                GetPlayerName(p1,medicname,sizeof(medicname));
                GetPlayerName(p2,injuriedname,sizeof(injuriedname));
                new string[128];
                format(string,sizeof(string),"Player %s has been healed by medic %s",injuriedname,medicname);
                SendClientMessageToAll(COLOR_PURPLE,string);
             }
             if(GetPlayerMoney(p2) < 500) return SendClientMessage(p1,COLOR_YELLOW,"The player doesn't have enough money");
         }
         if(health > 80) return SendClientMessage(playerid,COLOR_GREEN,"The player doesn't need to be healed");
      }
     }
 if(gTeam[playerid] == TEAM_COPS || gTeam[playerid] == TEAM_ROBBERS || gTeam[playerid] == TEAM_FIREFIGHTERS) return SendClientMessage(playerid,COLOR_RED,"This command is only for medics.");
  return true;
}
Reply
#3

Try to use
pawn Код:
//Change it with this
             }
             else if(GetPlayerMoney(p2) < 500) return SendClientMessage(p1,COLOR_YELLOW,"The player doesn't have enough money");
         }
         else if(health > 80) return SendClientMessage(playerid,COLOR_GREEN,"The player doesn't need to be healed");
      }
      else if(gTeam[playerid] == TEAM_COPS || gTeam[playerid] == TEAM_ROBBERS || gTeam[playerid] == TEAM_FIREFIGHTERS) return SendClientMessage(playerid,COLOR_RED,"This command is only for medics.");
  }
  return true;
}
Reply
#4

Thanks IsBack but now working rate please? someone try it for me(i can test it right now)

pawn Код:
COMMAND:heal(playerid,params[])
{
    if(gTeam[playerid] == TEAM_MEDICS)
    {
       new p1;
       new p2;
       new Float:health;
       if(sscanf(params,"u",p2)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /heal [id]");
       else if(!IsPlayerConnected(p2)) return SendClientMessage(playerid, COLOR_RED, "This player is not connected");
       else if(p2 == playerid) return SendClientMessage(playerid,COLOR_RED,"You cannot heal yourself");
       GetPlayerHealth(p2,health);
       if(health < 80)
       {
         GetDistanceBetweenPlayers(p1,p2);
         if(GetDistanceBetweenPlayers(p1,p2) > 5) return SendClientMessage(p1,COLOR_RED,"Player is too far away");
         if(GetDistanceBetweenPlayers(p1,p2) < 5)
         {
             GetPlayerMoney(p2);
             if(GetPlayerMoney(p2) > 500)
             {
                SetPlayerHealth(p2,100);
                GivePlayerMoney(p2,-500);
                GivePlayerMoney(p1,500);
                new medicname[24];
                new injuriedname[24];
                GetPlayerName(p1,medicname,sizeof(medicname));
                GetPlayerName(p2,injuriedname,sizeof(injuriedname));
                new string[128];
                format(string,sizeof(string),"Player %s has been healed by medic %s",injuriedname,medicname);
                SendClientMessageToAll(COLOR_PURPLE,string);
             }
             if(GetPlayerMoney(p2) < 500) return SendClientMessage(p1,COLOR_YELLOW,"The player doesn't have enough money");
         }
        if(health > 80) return SendClientMessage(playerid,COLOR_GREEN,"The player doesn't need to be healed");
      }
    }
    if(gTeam[playerid] == TEAM_COPS || gTeam[playerid] == TEAM_ROBBERS || gTeam[playerid] == TEAM_FIREFIGHTERS) return SendClientMessage(playerid,COLOR_RED,"This command is only for medics.");
  return true;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)