Help with "/heal" CMD
#1

I want doctors to be able to do the command outside the ambulance. Can someone change the code for me?

PHP код:
    if(strcmp(cmd"/heal"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_WHITE"{7DAEFF}USAGE: /heal [playerid/PartOfName] [price]{7DAEFF}");
                return 
1;
            }
            
giveplayerid ReturnUser(tmp);
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_WHITE"{7DAEFF}USAGE: /heal [playerid/PartOfName] [price{7DAEFF}]");
                return 
1;
            }
            
moneys strvalEx(tmp);
            if(
moneys 200 || moneys 1000) { SendClientMessage(playeridCOLOR_GREY"   Price can't be below $200 or above $1000 !"); return 1; }
            if(
giveplayerid == playerid)
            {
                
SendClientMessage(playeridCOLOR_GRAD1"You cannot heal yourself.");
                return 
1;
            }
            if(
IsPlayerConnected(giveplayerid))
            {
                if(
giveplayerid != INVALID_PLAYER_ID)
                {
                    
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                    
GetPlayerName(playeridsendernamesizeof(sendername));
                    new 
giveambu GetPlayerVehicleID(giveplayerid);
                    new 
playambu GetPlayerVehicleID(playerid);
                    if(
PlayerInfo[playerid][pMember] == || PlayerInfo[playerid][pLeader] == 4)
                    {
                        if(
IsAnAmbulance(playambu) && playambu == giveambu)
                        {
                            new 
Float:tempheal;
                            
GetPlayerHealth(giveplayerid,tempheal);
                            if(
tempheal >= 100.0)
                            {
                                
SendClientMessage(playeridCOLOR_GRAD1,"   That person is fully healed !");
                                return 
1;
                            }
                            
PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+moneys;
                            
GivePlayerMoney(playerid,moneys);
                            
PlayerInfo[giveplayerid][pCash] = PlayerInfo[giveplayerid][pCash]-moneys;
                            
GivePlayerMoney(giveplayerid,-moneys);
                            
SetPlayerHealth(giveplayerid100);
                            
PlayerPlaySound(giveplayerid10520.00.00.0);
                            
SendClientMessage(giveplayeridCOLOR_GRAD1"   You have been fully healed.");
                            
format(stringsizeof(string), "* Paramedic %s has healed %s for $%d."sendername,giveplayer,moneys);
                            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                            if(
STDPlayer[giveplayerid] > 0)
                            {
                                
STDPlayer[giveplayerid] = 0;
                                
SendClientMessage(giveplayeridCOLOR_LIGHTBLUE"* You are no longer infected with a STD !");
                            }
                        }
                        else
                        {
                            
SendClientMessage(playeridCOLOR_GRAD1"   You and the patient must be inside the Ambulance !");
                            return 
1;
                        }
                    }
                    else
                    {
                        
SendClientMessage(playeridCOLOR_GRAD1"   You are not authorized to use that command !");
                        return 
1;
                    }
                }
            }
            else
            {
                
format(stringsizeof(string), "   %d is not an active player !"giveplayerid);
                
SendClientMessage(playeridCOLOR_GRAD1string);
            }
        }
        return 
1;
    } 
Reply
#2

i guess you have to remove this to make it available everywhere, not just inside ambulances

pawn Код:
new giveambu = GetPlayerVehicleID(giveplayerid);//just remove this
new playambu = GetPlayerVehicleID(playerid);//and this
if(IsAnAmbulance(playambu) && playambu == giveambu) //remove that check, we don't need it anymore
basically, just remove all the vehicle related stuff


Код:
    if(strcmp(cmd, "/heal", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "{7DAEFF}USAGE: /heal [playerid/PartOfName] [price]{7DAEFF}");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "{7DAEFF}USAGE: /heal [playerid/PartOfName] [price{7DAEFF}]");
                return 1;
            }
            moneys = strvalEx(tmp);
            if(moneys < 200 || moneys > 1000) { SendClientMessage(playerid, COLOR_GREY, "   Price can't be below $200 or above $1000 !"); return 1; }
            if(giveplayerid == playerid)
            {
                SendClientMessage(playerid, COLOR_GRAD1, "You cannot heal yourself.");
                return 1;
            }
            if(IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    if(PlayerInfo[playerid][pMember] == 4 || PlayerInfo[playerid][pLeader] == 4)
                    {
						new Float:tempheal;
						GetPlayerHealth(giveplayerid,tempheal);
						if(tempheal >= 100.0)
						{
							SendClientMessage(playerid, COLOR_GRAD1,"   That person is fully healed !");
							return 1;
						}
						PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+moneys;
						GivePlayerMoney(playerid,moneys);
						PlayerInfo[giveplayerid][pCash] = PlayerInfo[giveplayerid][pCash]-moneys;
						GivePlayerMoney(giveplayerid,-moneys);
						SetPlayerHealth(giveplayerid, 100);
						PlayerPlaySound(giveplayerid, 1052, 0.0, 0.0, 0.0);
						SendClientMessage(giveplayerid, COLOR_GRAD1, "   You have been fully healed.");
						format(string, sizeof(string), "* Paramedic %s has healed %s for $%d.", sendername,giveplayer,moneys);
						ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
						if(STDPlayer[giveplayerid] > 0)
						{
							STDPlayer[giveplayerid] = 0;
							SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "* You are no longer infected with a STD !");
						}
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "   You are not authorized to use that command !");
                        return 1;
                    }
                }
            }
            else
            {
                format(string, sizeof(string), "   %d is not an active player !", giveplayerid);
                SendClientMessage(playerid, COLOR_GRAD1, string);
            }
        }
        return 1;
    }
Reply
#3

I test it, thanks for your reply +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)