Detecting when player enter Pay'n'Spray
#1

Is there a way to detect when player enter/exit Pay'N'Spray ?

Through my search I haven't find any but an include and some tips..

The problem with the include that it makes every vehicle's health 999 and detect when it gets 1000, But I don't like it as if someone cheated it will call the function.. So I decided to make one myself..

Tips
Quote:
Originally Posted by cessil
Посмотреть сообщение
Not really hard to do.

First thing I do when scripting something like this is to break it down into things we know.

1. The pay n spray locations do not move.

2. When a car is sprayed the car health goes back up to 1000.

3. The Player loses $100.

4. The car stays still while being sprayed

You could do a check at every pay n spray to check if a play is within a certain distance, then if they are get the health of the car.
Then if the cars health goes back up to 1000 while they are within that area then they probably used the pay n spray, you could also check if they lose money.
So if they are within that area, their car has healed and they have lost $100 give the business $100.
I tried making a timer and check every player near Pay'N'Spray and if he stood still for more then 3 seconds I call the function.. But what If he sprayed..then stood still.. It'll still call the function every 3 seconds.. So I tried to check if the player losses 100 and it worked.. But there is a problem.. You could spray your vehicle for free if its health is 1000.. And If I checked for the health I'll get back that he might stand still at the Pay'N'Spray with 1000 vehicle health and the function will keep calling.. Also I got an idea to make invisible Checkpoint/Pickup at every Pay'N'Spray and check OnPlayerEnterCheckPoint/OnPlayerPickUpPickUp instead of a timer... Can you tell me your suggestions/ideas to make this ? Or a link if it already exist..
Reply
#2

I would try to make it using a timer. Maybe you can save health of vehicle when it enters the position of the pay n spray for the first time. Timer can compare health of the vehicle when it detects the vehicle in the pay n spray for the second time.
Reply
#3

Quote:
Originally Posted by Ivan25
Посмотреть сообщение
I would try to make it using a timer. Maybe you can save health of vehicle when it enters the position of the pay n spray for the first time. Timer can compare health of the vehicle when it detects the vehicle in the pay n spray for the second time.
What if vehicle health already 1000 ? The vehicle will be sprayed and health/player cash will be the same...
Reply
#4

pawn Код:
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    //code here
    return 1;
}
Reply
#5

Quote:
Originally Posted by Voxel
Посмотреть сообщение
pawn Код:
public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    //code here
    return 1;
}
Quote from Wiki:
Quote:

The callback name is deceptive, this callback is called when a player exits a mod shop, regardless of whether the vehicle's colors were changed, and is NEVER called for pay 'n' spray garages.

Reply
#6

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
Quote from Wiki:
Lol ok, oops ! thank you for notifying!
Reply
#7

No problems.. I wonder is there a way to make invisible Pickup/Checkpoint ?
Reply
#8

try this http://pastebin.com/zX96D4dA
Reply
#9

Quote:
Originally Posted by tuitalker
Посмотреть сообщение
That's the include I'm talking about.. It depend on the vehicle health, I want to make another function..
Reply
#10

Well,you could get coordinates of all the Pay 'n' Spray's,then check if player enters one using
OnPlayerUpdate() callback and IsPlayerInRangeOfPoint() .
Or use a streamer and create an area,there's a callback for it,something like
pawn Код:
OnPlayerEnterDynamicArea()
or similar...
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)