Heal in red marker
#1

I've made a hospital for my server and i'm trying to figure out how to heal a player if ONLY if they type /heal in the red marker i've placed in the server...


I have no idea how? can someone please help me.
Reply
#2

Use
PlayerToPoint

Example:

pawn Код:
if(PlayerToPoint(2,playerid,x,y,z))
{
//Do Something
}
You can find PlayerToPoint somewhere on this forum.
Reply
#3

Put this on OnPlayerCommandText.

pawn Код:
if(strcmp(cmdtext, "/gethealth", true) == 0)
    {
    SetPlayerCheckpoint(playerid,x,y,z,4.0);
        GameTextForPlayer(playerid, "~g~Get Health", 5000, 1);
        if (TestDistance(playerid,giveplayerid,x,y.z,7))
        SetPlayerHealth(playerid, 100.0);
        return 1;
    }
It's untested.
Reply
#4

Quote:
Originally Posted by Joeri
Put this on OnPlayerCommandText.

pawn Код:
if(strcmp(cmdtext, "/gethealth", true) == 0)
    {
    SetPlayerCheckpoint(playerid,x,y,z,4.0);
        GameTextForPlayer(playerid, "~g~Get Health", 5000, 1);
        if (TestDistance(playerid,giveplayerid,x,y.z,7))
        SetPlayerHealth(playerid, 100.0);
        return 1;
    }
It's untested.

I'm not good at scripting, i have no idea what to fill in with my cords where.
Reply
#5

Код:
public OnPlayerSpawn(playerid)
{
  SetPlayerCheckpoint(playerid, x, y, z);
  return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
  SetPlayerHealth(playerid, 100.0);
  return 1;
}
To find the coordinates, go to SAN ANDREAS folder and open SAMP DEBUG exe, then go to the position where u want the red marker and type /save or /save comment. this will create a text file with coorinates in your SAN ANDREAS game folder, get the coordinates and replace to x y and z!
Reply
#6

https://sampwiki.blast.hk/wiki/IsPlayerInCheckpoint
Reply
#7

Quote:
Originally Posted by steven_italy
Код:
public OnPlayerSpawn(playerid)
{
  SetPlayerCheckpoint(playerid, x, y, z);
  return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
  SetPlayerHealth(playerid, 100.0);
  return 1;
}
To find the coordinates, go to SAN ANDREAS folder and open SAMP DEBUG exe, then go to the position where u want the red marker and type /save or /save comment. this will create a text file with coorinates in your SAN ANDREAS game folder, get the coordinates and replace to x y and z!
I know how to get the cords! I dont no where the hell to put them in that code that he gave me, I tryed to place them where i thought but they give me errors!
Reply
#8

Код:
public OnPlayerSpawn(playerid)
{
  SetPlayerCheckpoint(playerid, x, y, z);
  return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
  SetPlayerHealth(playerid, 100.0);
  return 1;
}
Just put that anywhere in the code...
Put the:

Код:
if(strcmp(cmdtext, "/gethealth", true) == 0)
	{
   	SetPlayerCheckpoint(playerid,x,y,z,4.0);
		GameTextForPlayer(playerid, "~g~Get Health", 5000, 1);
		if (TestDistance(playerid,giveplayerid,x,y.z,7))
		SetPlayerHealth(playerid, 100.0);
		return 1;
	}
Under OnPlayerCommandText
Reply
#9

Quote:
Originally Posted by [SAP
Sidhu ]
Код:
public OnPlayerSpawn(playerid)
{
  SetPlayerCheckpoint(playerid, x, y, z);
  return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
  SetPlayerHealth(playerid, 100.0);
  return 1;
}
Just put that anywhere in the code...
Put the:

Код:
if(strcmp(cmdtext, "/gethealth", true) == 0)
	{
   	SetPlayerCheckpoint(playerid,x,y,z,4.0);
		GameTextForPlayer(playerid, "~g~Get Health", 5000, 1);
		if (TestDistance(playerid,giveplayerid,x,y.z,7))
		SetPlayerHealth(playerid, 100.0);
		return 1;
	}
Under OnPlayerCommandText
Why is it that as soon as i enter the red marker it heals me? i want it to be you type /gethealth and then it heals me and charges 100 dollers.

Please someone help
Reply
#10

Here you are:

Put this at the bottom of your script:
pawn Код:
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
  new Float:oldposx, Float:oldposy, Float:oldposz;
  new Float:tempposx, Float:tempposy, Float:tempposz;
  GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  tempposx = (oldposx -x);
  tempposy = (oldposy -y);
  tempposz = (oldposz -z);
  //printf("DEBUG: X:%f Y:%f Z:%f",posx,posy,posz);
  if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  {
    return 1;
  }
  return 0;
}
and then, at public OnPlayerCommandText(playerid, cmdtext[]) type this:

pawn Код:
if(strcmp(cmdtext,"/heal",true ) == 0 )
    {
      if (PlayerToPoint(2, playerid, x, y, z)) // Replace X, Y, Z with the Co-Ords where you should be to do /heal
      {
      SetPlayerHealth(playerid, 100);
      SendClientMessage(playerid, COLOR, " MESSAGE"); // Replace color with a color code, and replace message with any message you want
      return 1;
      }
And about the checkpoint do as what steve_italy told you.. Good luck!

PS: If it didn't work, please tell me..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)