How to check if vehicle is repaired in a X-Y-Z zone ?
#1

vehicle is going to be repaired/fixed in a zone (defined x-y-z and range) for example in Pay'n Spray , if veh=fixed return me a text message

How this can be done ?
Reply
#2

Well the easiest way would be using the streamer plugin. It has functions like CreteDynamicRectangle for a 2D zone and CreateDyanmicCuboid for a 3D one.


So in your case you would need a cuboid:
pawn Код:
new gPayNSpray;

public OnGameModeInit()
{
     // This will create a cube. The length of each side is 4.0
     // The  first 6 parameters are: minx, miny, minz, maxx, maxy, maxz
     gPayNSpray = CreateDynamicCuboid(-2.0, -2.0, -2.0, 2.0, 2.0, 2.0);
}
And then whenever you want to check if player is in that zone you just use IsPlayerInDynamicArea(playerid, gPayNSpray);
Reply
#3

Код:
Functie IsPlayerInArea(playerid, Float:minx, Float:miny, Float:maxx, Float:maxy)
{
   new Float:x, Float:y, Float:z;
   GetPlayerPos(playerid, x, y, z);
   if (x > minx && x < maxx && y > miny && y < maxy) return 1;
   return 0;
}
I can use this too but I wanna know how to make that "if(VehIsRepaired)" function ...
Reply
#4

By setting the vehicle health to 999 when creating the vehicle and then if the player is in range the the vehicle's health is 1000, set it back to 999 and do your code.
Reply
#5

Ok i got it


Код:
public IsPlayerInArea(playerid, Float:minx, Float:miny, Float:maxx, Float:maxy)
{
   new Float:x, Float:y, Float:z;
   GetPlayerPos(playerid, x, y, z);
   if (x > minx && x < maxx && y > miny && y < maxy) return 1;
   return 0;
}
+

Код:
if(IsPlayerInArea(id, 1, 2, 3, 4))
{
    new Float:health;
    new veh = GetPlayerVehicleID(playerid);
    GetVehicleHealth(veh, health);
    if(health == 1000) return SendClientMessage(playerid, COLOR_RED, "FULL VEH HEALTH.");
    SetVehicleHealth(veh, 999.99);
}
But where should i add that "if..." ? in which "public.." function?
Reply
#6

This one is mentioned in wiki: http://pastebin.com/zX96D4dA

You can modify it and use dynamic areas as dusk said, it'll probably be more efficient.
Reply
#7

I've got it
Step 1: SetTimerEx called IsVehAtPNS with 1milisec loading and loading and etc
Step 2: IsVehAtPNS function (forward & public) with IsPlayerInArea and range 3.0
Step 3: If playerstate==driver -> do something; else return message

Works Perfectly
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)