SA-MP Forums Archive
Player Detect [HELP] - 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: Player Detect [HELP] (/showthread.php?tid=393123)



Player Detect [HELP] - Sting. - 17.11.2012

I wanted to create this heal command thing. But not like /heal and you are healed. I want to do this in strcmp. So, I will use the function OnPlayerEnterVehicle. When the player enters the vehicle, ambulance, a message will come out and say to type in /heal to heal himself. So at the command create part I do this:
Код:
if(!strcmp(cmdtext, "/heal", true))
{   (What do I put here?)
I have created the command, how do I make it detect whether the player is in the ambulance and then it will proceed with the healing? Something like IsPlayerInRangeOfPoint. I tried OnPlayerStateChange, and to make the health regenerate when the players enter's the ambulance. It worked but then I later noticed that in every other vehicle I entered, my health will also be regenerated. So it was an epic FAIL! so I thought of just creating a simple /heal cmd and it will execute if the player is in the ambulance. (No matter Driver or Passenger.) Can someone help me out?


Re: Player Detect [HELP] - [HK]Ryder[AN] - 17.11.2012

pawn Код:
if(!strcmp(cmdtext, "/heal", true))
{
new vehicle;
vehicle = GetPlayerVehicleID(playerid);
if(vehicle == 416)
{
    SetPlayerHealth(playerid, 100);
}
else
{
     SendClientMessage(playerid, -1, "You need to be in an ambulance to use this cmd");
}
return 1;
}
try this


Re: Player Detect [HELP] - Virus. - 17.11.2012

Try this :
Quote:

public OnPlayerEnterVehicle(playerid, vehicleid)
{
if((GetVehicleModel(vehicleid))==416)
{
//ur heal script
}
}




Re: Player Detect [HELP] - [HK]Ryder[AN] - 17.11.2012

Quote:
Originally Posted by Virus.
Посмотреть сообщение
Try this :
he wants it to work in a command....
when player enters veh he sends the message
but healing is done with the /heal cmd


Re: Player Detect [HELP] - Sting. - 17.11.2012

Alright thanks a lot. +Rep you guys,


Re: Player Detect [HELP] - Sting. - 18.11.2012

Ryder, I just tried on the code. Well the else works but not the command. I tried entering the ambulance and tried the command /heal but no difference, I still haven't healed yet. How?


Re: Player Detect [HELP] - [HK]Ryder[AN] - 18.11.2012

My Bad
change the code to this
pawn Код:
if(!strcmp(cmdtext, "/heal", true))
{
new vehicle, vehmod;
vehicle = GetPlayerVehicleID(playerid);
vehmod = GetVehicleModel(vehicle);
if(vehmod == 416)
{
    SetPlayerHealth(playerid, 100);
}
else
{
     SendClientMessage(playerid, -1, "You need to be in an ambulance to use this cmd");
}
return 1;
}



Re: Player Detect [HELP] - Sting. - 18.11.2012

Alright Ryder, Case Closed! thanks. It works for real now.