Player Detect [HELP]
#1

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?
Reply
#2

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
Reply
#3

Try this :
Quote:

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

Reply
#4

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
Reply
#5

Alright thanks a lot. +Rep you guys,
Reply
#6

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?
Reply
#7

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;
}
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)