Vice City Multiplayer

VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: [Akatsuki]Itachi on July 07, 2013, 04:03:35 am

Title: How To Set Enter Place ?
Post by: [Akatsuki]Itachi on July 07, 2013, 04:03:35 am
Just like when you type !heal, it say you need to be in hospital. How can i set where is the hospital and if player enter the hospital it will send client message, how to type the if player enter location. Who can give me the example ? And also how to use this function on automatic without using commands like it will do it by its own
[pawn]GetPlayerLocation[/pawn]
And then will what ever like send client message
Title: Re: How To Set Enter Place ?
Post by: dynavolt71 on July 07, 2013, 05:16:17 am
use GUPS in script showroom
And
DO NOT ask for giving cmd/func
P.s : change your name (many players using nick "itachi")
Title: Re: How To Set Enter Place ?
Post by: NeskWriter on July 07, 2013, 08:55:08 pm
Wrong topic, dude.
this must be posted in Scripting showroom, I guess
Title: Re: How To Set Enter Place ?
Post by: [Akatsuki]Itachi on July 08, 2013, 09:24:37 am
so how am i able to put this topic to pawn scripting board ? And then we will continue discuss. Anyway, this board have a description tell us that we can talk about anything about VCMP .
Title: Re: How To Set Enter Place ?
Post by: NeskWriter on July 08, 2013, 03:17:11 pm
I will try to make an example for you:

Put this line in the beginning of ur code, before OnGameModeInit:
[pawn]forward IsPlayerAtZone(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy);[/pawn]
All the public functions must be forwarded, this is the rule of Pawn.

Now let's put our public function anywhere, between another public functions:
[pawn]public IsPlayerAtZone(playerid, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
   new Float:plrx, Float:plry, Float:plrz; //we are declaring new floats - plrx, plr and plrz
   GetPlayerPos(playerid, plrx, plry, plrz); //we are setting their parameters through getting player's position (x, y, z)
   if(plrx >= minx && plrx <= maxx && plry >= miny && plry <= maxy) //if all the conditions (plrx >= minx && plrx <= maxx && plry >= miny && plry <= maxy) are true
   {
      return 1; // then we will be returned a "true" value of the "IsPlayerAtZone"function, like: -Is player at hospital? return 1 says: -Yes he is, because all the conditions are true!
   }
   return 0;
}[/pawn]

Now, let's use my stock function, that substracts player's cash according to the hp number he needs to be healthy :P. Put this after public OnPlayerText:
[pawn]stock SellPlayerHealth(playerid)
{
   new Float:phealth, Float:product1, Float:product2;
   new pmoney = GetPlayerMoney(playerid);
   new money2pay[256];
   GetPlayerHealth(playerid, phealth);
   if(phealth <= 99)
   {
      product1 = floatsub(100, phealth);
      product2 = floatmul(product1, 5);//My price for 1hp is $5, change "5" on your integer if you want
      format(money2pay, sizeof(money2pay), "%0.2f", product2);
      new money2payfinal = strval(money2pay);
      if(money2payfinal <= pmoney)
      {
          SetPlayerHealth(playerid, 100);
          SetPlayerMoney(playerid, pmoney - money2payfinal);
         new string2[256];
         format(string2, sizeof(string2), "You have been healed for $%d", money2payfinal);
         SendClientMessage(playerid, 0xFFFFFFAA, string2);
      }
      else
      {
          new string3[256];
          format(string3, sizeof(string3), "You don't have enough money (you need $%d)", money2payfinal);
          SendClientMessage(playerid, 0xFF0000AA, string3);
      }
   }
   else
   {
       SendClientMessage(playerid, 0xFF0000AA, "You don't need to heal yourself");
   }
}[/pawn]
P.S. If u want to increase ur knowledge about this function PM me

Now let's put this in OnPlayerText:
[pawn]if(strcmp(text, "!healme", true)==0)
   {
      if(IsPlayerAtZone(playerid, -118.94831, -98.60392, -993.66656, -959.46441)) //we check if the player is at hospital, we will be returned true (yes, he is) if he is
      {
         SellPlayerHealth(playerid); //if he is, he will be "healed"
      }
      else //otherwise (if one or more conditions aren't true)
      {
            SendClientMessage(playerid, 0xFF0000AA, "You are not at the hospital!"); //he will be sent a message noticed that he isn't at the hospital coordinates
        }
   }[/pawn]

(http://i.imgur.com/m9BRVjC.jpg)

Good luck, tell me if I admitted any mistake
Title: Re: How To Set Enter Place ?
Post by: aledark24 on July 08, 2013, 09:40:19 pm
wtf is this?
better is use playertopoint... of you want heal in all hospital......

and not use innecesary things in one simple command......


you need stay death... nesk...
Title: Re: How To Set Enter Place ?
Post by: NeskWriter on July 08, 2013, 10:51:29 pm
wtf is this?
better is use playertopoint... of you want heal in all hospital......

and not use innecesary things in one simple command......


you need stay death... nesk...

mKay, but I suggest u to make a better one
Title: Re: How To Set Enter Place ?
Post by: [Akatsuki]Itachi on July 09, 2013, 08:59:58 am
thank you NeskWritter, I will try it.  ;D