IsAtGasStation Function
#1

For people who might need it, i made this for DRPG

Top of your code:
Код:
forward IsAtGasStation(playerid);
End of your code:
Код:
public IsAtGasStation(playerid)
{
	if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == 2)
	{
		if(PlayerToPoint(5.0, playerid, -245.8878, 1207.6628, 19.7422) || PlayerToPoint(5.0, playerid, -245.8870, 1211.9666, 19.7422))
		{
			return 1;
		}
		else if(PlayerToPoint(5.0, playerid, 623.7903, 1678.2412, 6.9922) || PlayerToPoint(5.0, playerid, 617.9302, 1687.8840, 6.9922) || PlayerToPoint(5.0, playerid, 611.1439, 1697.2592, 6.9922) || PlayerToPoint(5.0, playerid, 603.8867, 1706.3608, 6.9922))
		{
	  	return 1;
		}
		else if(PlayerToPoint(7.0, playerid, 70.5051, 1219.3641, 18.8117))
		{
		  SendClientMessage(playerid, COLOR_RED, "Sorry, This Gas Station isn't in use!");
		  return 0;
		}
		SendClientMessage(playerid, COLOR_RED, "You must be at a Gas Station!");
		return 0;
	}
	SendClientMessage(playerid, COLOR_RED, "You must be in a vehicle and you must be the driver!");
	return 0;
}
To use this code (i.e. in an /refill command) use:
Код:
if(IsAtGasStation(playerid))
{
// Do here what should happen if the player is at a gas station
}
No else is required, because the messages come from the function!
Feel free to edit the coordinates, the ones used here are:
1. My custom gas station in Fort Carson
2. The unused gas station near the Clucking Bell in Fort Carson
3. The big gas station east of Las Venturas

Enjoy!

- Goz3rr
Reply
#2

You made this? I saw a script almost exactly the same a couple of days ago...

Edit: In fact, I saw it here: [FS] Fuel System with Display
Reply
#3

This aint a fuel system, its a function that checks if you are at the gas station.
I just made it this morning, all myself and never saw that FS before.

EDIT: I just looked at the code, and the IsAtGasStation he uses haves the same name, but is different. Infact, I think he copyed it from GF.
Reply
#4

I never said anything about it being a fuel system. I said that in the script which I gave a link to, there's a function almost exactly like this. It has the same function name (IsAtGasStation) and uses a very similar layout to yours...and it was made 5 months ago.
Reply
#5

It only uses PlayerToPoint, Like me, Because that's the easyiest way.
Then, that only checks the location, Mine does that + Send message + doesnt need an else in the command
Reply
#6

Yeah yeah,why didn`t you release this in filterscripts board,or post it in useful scripts?
Reply
#7

Because i just got back at SA:MP scripting and didnt know there is a useful snippet board :P
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)