What;s worng here?(I hope I can get an answer as soon as possible)
#1

This is my new heal command wich is working thanks to Sven who told me just how to solve an error line(Thanks),now in game evrything works evrything,but there's one problem about it when I type /heal 0(me) server shuts down and I think I know the problem(I can't heal my self probably) and I didn't make the IsPlayerConnected shit:

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]");
       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)
         {
           SetPlayerHealth(p2,100);
           GivePlayerMoney(p2,-500);
           GivePlayerMoney(p1,500);
           SendClientMessageToAll(COLOR_PURPLE,"Player %s has been healed by medic %s");
         }
       }
       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)
     {
       SendClientMessage(playerid,COLOR_RED,"This command is only for medics.");
       return 1;
     }
     return true;
}
Reply
#2

Make another command, just to heal yourself? Like /healme
Cant see an error in here
Reply
#3

pawn Код:
SendClientMessageToAll(COLOR_PURPLE,"Player %s has been healed by medic %s");


Also, instead of using IsPlayerConnected, you could do:
pawn Код:
if(GetPlayerHealth(p2,health))
{
    // He is connected, do stuff
}
Reply
#4

yeah probably GetDIstanceBetweenPlayers is supossed to get distance between 2 players and as I tried to heal my self(I'm only 1 player) when I called that function it didn't work as it should work now thanks for opening up my minds wesley and thanks for the point vince
Reply
#5

Use like
pawn Код:
if(sscanf(params....))
{
SetPlayerHealth(playerid,100);
}
If no params, you heal yourself..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)