Refuel command.
#1

I've been checking for like one hour now, but still can't figure out what I did whrong here.
I scripted a refuel command, if you don't have a fuel can.. it'll check if you're near a pump.
If you're near a pump and don't have a vehicle it checks if u got a gas can to refuel. Also if ur not near a pump it'll check if u have a gas can and near an owned vehicle.
But when I get IG, It just keeps saying you don't have a fuel can. :O

Code:
CMD:refuel(playerid, params[])
{
	if (IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFC800FF,"SERVER: You can not refuel a vehicle from the inside.");
	new engine, lights, alarm, doors, bonnet, boot, objective;
	new veh = GetClosestVehicle(playerid, 5.0);
    if(IsPlayerInRangeOfPoint(playerid, 5.0, 572.5297+11400,-2759.7271-10000,13.9872) && IsPlayerInRangeOfPoint(playerid, 5.0, 12368.1885,-11937.6396,5.5338) && IsPlayerInRangeOfPoint(playerid, 5.0, 12368.8154,-11943.2422,5.5425) && IsPlayerInRangeOfPoint(playerid, 5.0, 12371.4863,-11948.7529,5.5312) && IsPlayerInRangeOfPoint(playerid, 5.0, 12365.1885,-11938.9287,5.5332))
	{
	    if(!IsPlayerNearAnyVehicle(playerid, 5.0) && PlayerInfo[playerid][pFuelCan] == 1 && PlayerInfo[playerid][pCanFuel] < 100)
	    {
	    	SetTimerEx("RefuelingCan2", 20000, 0, "i", playerid);
	    	GameTextForPlayer(playerid, "Refueling!", 17000, 1);
	    	TogglePlayerControllable(playerid, 0);
	    	SetCameraBehindPlayer(playerid);
	    	return 1;
		}
		if(IsPlayerNearAnyVehicle(playerid, 5.0))
		{
			if(owner[veh] == -1) return ERROR(playerid, "SERVER: You can't refill this vehicle!");
	    	if (fuel[veh] == 100) return SendClientMessage(playerid,0xFFC800FF,"SERVER: You're vehicle is full, you can't refuel it.");
			GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
			SetVehicleParamsEx(veh, 1, lights, alarm, doors, bonnet, boot, objective);
	    	SetTimerEx("Refueling", 20000, 0, "id", playerid, veh);
	    	TogglePlayerControllable(playerid, 0);
	    	GameTextForPlayer(playerid, "Refueling!", 17000, 1);
	    	SetCameraBehindPlayer(playerid);
    		return 1;
		}
	}
	else if(PlayerInfo[playerid][pFuelCan] == 1)
	{
	    if(PlayerInfo[playerid][pCanFuel] < 1) return SCM(playerid, COLOR_WHITE, "SERVER: Your fuel can is empty, refill it at the gas station.");
		if(owner[veh] == -1) return ERROR(playerid, "SERVER: You can't refill this vehicle!");
 		if (fuel[veh] == 100) return SendClientMessage(playerid,0xFFC800FF,"SERVER: You're vehicle is full, you can't refuel it.");
		GetVehicleParamsEx(veh, engine, lights, alarm, doors, bonnet, boot, objective);
		SetVehicleParamsEx(veh, 1, lights, alarm, doors, bonnet, boot, objective);
    	SetTimerEx("RefuelingCan", 20000, 0, "id", playerid, veh);
    	TogglePlayerControllable(playerid, 0);
    	GameTextForPlayer(playerid, "Refueling!", 17000, 1);
    	SetCameraBehindPlayer(playerid);
    	return 1;
    }
    else
    {
        SCM(playerid, COLOR_WHITE, "SERVER: You need to be near a gas station or have a fuel can in order to use this command.");
    }

    new str[128];
	format(str, sizeof(str), "%s has issued the /refuel command.", GetName(playerid));
 	Log("logs/playercmds/veh.log", str);
	return 1;
}
Reply
#2

I'd suggest you make a pickup for pumps instead of a command
Reply
#3

Quote:
Originally Posted by Kevinas100
View Post
I'd suggest you make a pickup for pumps instead of a command
That doesn't solve my problem, does it? I want to keep it this way. Somehow it does not what I ask.
Reply
#4

I believe
PHP Code:
    if(IsPlayerInRangeOfPoint(playerid5.0572.5297+11400,-2759.7271-10000,13.9872) && IsPlayerInRangeOfPoint(playerid5.012368.1885,-11937.6396,5.5338) && IsPlayerInRangeOfPoint(playerid5.012368.8154,-11943.2422,5.5425) && IsPlayerInRangeOfPoint(playerid5.012371.4863,-11948.7529,5.5312) && IsPlayerInRangeOfPoint(playerid5.012365.1885,-11938.9287,5.5332)) 
should be in OR cases ( || ) instead of logical AND (&&) as all those cases wont be true at same time.

You might meant to do this way if player is in either of these range
PHP Code:
if(IsPlayerInRangeOfPoint(playerid5.0572.5297+11400,-2759.7271-10000,13.9872) || IsPlayerInRangeOfPoint(playerid5.012368.1885,-11937.6396,5.5338) || IsPlayerInRangeOfPoint(playerid5.012368.8154,-11943.2422,5.5425) || IsPlayerInRangeOfPoint(playerid5.012371.4863,-11948.7529,5.5312) || IsPlayerInRangeOfPoint(playerid5.012365.1885,-11938.9287,5.5332)) 
Reply
#5

Quote:
Originally Posted by SyS
View Post
I believe
PHP Code:
    if(IsPlayerInRangeOfPoint(playerid5.0572.5297+11400,-2759.7271-10000,13.9872) && IsPlayerInRangeOfPoint(playerid5.012368.1885,-11937.6396,5.5338) && IsPlayerInRangeOfPoint(playerid5.012368.8154,-11943.2422,5.5425) && IsPlayerInRangeOfPoint(playerid5.012371.4863,-11948.7529,5.5312) && IsPlayerInRangeOfPoint(playerid5.012365.1885,-11938.9287,5.5332)) 
should be in OR cases ( || ) instead of logical AND (&&) as all those cases wont be true at same time.

You might meant to do this way if player is in either of these range
PHP Code:
if(IsPlayerInRangeOfPoint(playerid5.0572.5297+11400,-2759.7271-10000,13.9872) || IsPlayerInRangeOfPoint(playerid5.012368.1885,-11937.6396,5.5338) || IsPlayerInRangeOfPoint(playerid5.012368.8154,-11943.2422,5.5425) || IsPlayerInRangeOfPoint(playerid5.012371.4863,-11948.7529,5.5312) || IsPlayerInRangeOfPoint(playerid5.012365.1885,-11938.9287,5.5332)) 
Thanks, I'll test. Working fine. Thank you. Always getting confused with those two .
After re-reading it it indeed makes sense to put || instead of &&.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)