SA-MP Forums Archive
What;s worng here?(I hope I can get an answer as soon as possible) - 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: What;s worng here?(I hope I can get an answer as soon as possible) (/showthread.php?tid=255620)



What;s worng here?(I hope I can get an answer as soon as possible) - Cjgogo - 16.05.2011

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;
}



Re: What;s worng here?(I hope I can get an answer as soon as possible) - Wesley221 - 16.05.2011

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


Re: What;s worng here?(I hope I can get an answer as soon as possible) - Vince - 16.05.2011

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
}



Re: What;s worng here?(I hope I can get an answer as soon as possible) - Cjgogo - 16.05.2011

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


Re: What;s worng here?(I hope I can get an answer as soon as possible) - Seven_of_Nine - 16.05.2011

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