SA-MP Forums Archive
/heal problem - 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)
+--- Thread: /heal problem (/showthread.php?tid=548525)



/heal problem - Akcent_Voltaj - 30.11.2014

hi how can I make so only in ambulance works command and at a distance? and a smaller command??please?

I made but its not good. its a bad command..

PHP код:
if (strcmp(cmd"/vindeca"true) == 0)
                    {
                        if(
IsPlayerConnected(playerid))
                        {
                            
tmp strtok(cmdtextidx);
                            if(!
strlen(tmp))
                            {
                                
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /vindeca [playerid/PartOfName] [price]");
                                return 
1;
                            }
                            
giveplayerid ReturnUser(tmp);
                            
moneys strval(tmp);
                            
                            if(
moneys || moneys 1000)
                            {
                                
SendClientMessage(playeridCOLOR_GREY"   Healing price not below 1 or above 1000!");
                                return 
1;
                            }
                            
tmp strtok(cmdtextidx);
                            if(!
strlen(tmp))
                            {
                                
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /vindeca [playerid/PartOfName] [price]");
                                return 
1;
                            }
                            
/*if (giveplayerid == playerid)
                            {
                                SendClientMessage(playerid, COLOR_GRAD1, "   You can not heal yourself!");
                                return 1;
                            }*/
                            
if (IsPlayerConnected(giveplayerid))
                            {
                                if(
giveplayerid != INVALID_PLAYER_ID)
                                {
                                    
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                                    new 
giveambu GetPlayerVehicleID(giveplayerid);
                                    new 
playambu GetPlayerVehicleID(playerid);
                                    if(
PlayerInfo[playerid][pJob] == 19)//model
                                    
{
                                        if (
IsAAmbulanceCar(playambu) && playambu == giveambu)
                                        {
                                            new 
Float:tempheal;
                                            
GetPlayerHealth(giveplayerid,tempheal);
                                            if(
tempheal >= 99)
                                            {
                                                
SendClientMessage(playeridTEAM_GREEN_COLOR,"   That person is fully healed.");
                                                return 
1;
                                            }
                                            
format(stringsizeof(string), "~y~You healed ~n~~w~%s~n~~g~$%d"giveplayer,moneys);
                                            
GameTextForPlayer(playeridstring50001);
                                            
GivePlayerCash(playerid,moneys);
                                            
GivePlayerCash(giveplayerid,-moneys);
                                            
format(stringsizeof(string), "* %s l-a vindecat pe %s %dLei"sendername,giveplayer,moneys);
                                            
ProxDetector(30.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                                            new 
hp 0;
                                            if(
PlayerInfo[playerid][pPainPerk] > 0)
                                            {
                                                
hp 20 PlayerInfo[playerid][pPainPerk]; hp += 100;
                                                
SetPlayerHealth(giveplayeridhp);
                                            }
                                            else
                                            {
                                                
hp 100;
                                                
SetPlayerHealth(giveplayerid100);
                                            }
                                            
PlayerPlaySound(playerid11500.00.00.0);
                                            
PlayerPlaySound(giveplayerid11500.00.00.0);
                                            
format(stringsizeof(string), "You have been healed to %d health -$%d",hp,moneys);
                                            
SendClientMessage(giveplayeridTEAM_GREEN_COLOR,string);
                                            if(
STDPlayer[giveplayerid] > 0)
                                            {
                                                
STDPlayer[giveplayerid] = 0;
                                                
SendClientMessage(giveplayeridCOLOR_WHITE"* You are no longer infected with a STD anymore because of the Medics help!");
                                            }
                                        }
                                        else
                                        {
                                            
SendClientMessage(playeridCOLOR_GRAD1"** One of you is not in the Ambulance / Chopper!");
                                            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;
                    } 



Re: /heal problem - Akcent_Voltaj - 30.11.2014

help?


Re: /heal problem - AnthonyTimmers - 30.11.2014

To make it only work in an ambulance get the player vehicle id (GetPlayerVehicle) and check if it is an ambulance.

I'd suggest using ZCMD or DCMD as they're both faster and shorter than using strtok.

To help you on the way:
https://sampwiki.blast.hk/wiki/Fast_Commands


Re: /heal problem - AzaMx - 30.11.2014

Agree with Anthony


Re: /heal problem - Akcent_Voltaj - 30.11.2014

fixed ..