Refueling Timer Problem
#1

Hello Everybody,

I have got a problem with my Fuel System ..
I guess it is a Timer matter ..

The problem is that when I do /refuel , I keep geting this Message every second : "Your vehicle's tank has been refilled for $100.", then my money keeps getting reduced by 100$ at every message,
And I don't even get any fuel !!!
...
So, I thought That I have to Kill The Timer RefuelingVehicleTimer .. But I've already this in the StopRefueling stock :

Код:
KillTimer(RefuelingVehicleTimer[playerid] = 6000);
I'm not really familiar with the timers ...

So, Let me just show you some code :

The Command :

Код:
CMD:refuel(playerid, params[])
{
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
	    new vehicleid = GetPlayerVehicleID(playerid);
	    new engine,lights,alarm,doors,bonnet,boot,objective;
    	GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
	    if(engine == VEHICLE_PARAMS_ON) return SendClientMessageEx(playerid, COLOR_RED, "You need to shut off the engine before filling up (Press 'N').");
	    if(!IsAtFuelStation(playerid)) return SendClientMessageEx(playerid, COLOR_RED, "You're not at a fuel station.");
	    if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessageEx(playerid,COLOR_RED,"This vehicle doesn't need fuel.");
	    if(VehicleFuel[vehicleid] >= 100.0) return SendClientMessageEx(playerid, COLOR_RED, "This vehicle's tank is already full.");
	    if(RefuelingVehicle[playerid] == 1) return SendClientMessageEx(playerid, COLOR_RED, "You are refilling your vehicle's tank.");
       	SendClientMessageEx(playerid, COLOR_WHITE, "Refueling your vehicle's tank, please wait.");
       	RefuelingVehicle[playerid] = 1;
       	RefuelingVehicleTimer[playerid] = SetTimerEx("ReFill", 1000, true, "i", playerid);
	}
	return 1;
}
Refill (callback)

Код:
forward ReFill(playerid);
public ReFill(playerid)
{
	if(!IsAtFuelStation(playerid) || !IsPlayerInAnyVehicle(playerid) || VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0 || GetPlayerCash(playerid) < 1)
	{
		StopRefueling(playerid);
	}
	else
	{
	    new engine,lights,alarm,doors,bonnet,boot,objective;
    	GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
		if(engine == VEHICLE_PARAMS_ON) return StopRefueling(playerid);
		VehicleFuel[GetPlayerVehicleID(playerid)] += 1.0; RefuelingVehiclePrice[playerid] += 30;
		if(VehicleFuel[GetPlayerVehicleID(playerid)] >= 100.0) VehicleFuel[GetPlayerVehicleID(playerid)] = 100.0;
	}
	return true;
}
stock StopRefueling :

Код:
stock StopRefueling(playerid)
{
	GivePlayerCash(playerid, -100);
  	SendFormattedMessage(playerid, COLOR_WHITE,"Your vehicle's tank has been refilled for $100.");
  	
	new mypoint = -1;
	for (new i=0; i<MAX_POINTS; i++)
	{
		if(strcmp(Points[i][Name], "Fossil Fuel Company", true) == 0)
		{
			mypoint = i;
		}
	}
	for(new i = 0; i < sizeof(FamilyInfo); i++)
	{
		if(strcmp(Points[mypoint][Owner], FamilyInfo[i][FamilyName], true) == 0)
		{
			FamilyInfo[i][FamilyBank] = FamilyInfo[i][FamilyBank]+(RefuelingVehiclePrice[playerid]/10);
		}
	}

	RefuelingVehicle[playerid] = 0; RefuelingVehiclePrice[playerid] = 0; KillTimer(RefuelingVehicleTimer[playerid] = 6000);
	return true;
}

Can anyone, please, help me with this ?
I'm really stuck ..
Thanks in advance.



_
Reply


Messages In This Thread
Refueling Timer Problem - by MiiSha - 26.01.2017, 06:03
Re: Refueling Timer Problem - by BiosMarcel - 26.01.2017, 06:24
Re: Refueling Timer Problem - by MiiSha - 26.01.2017, 06:46
Re: Refueling Timer Problem - by SyS - 26.01.2017, 07:14
Re: Refueling Timer Problem - by MiiSha - 26.01.2017, 08:54
Re: Refueling Timer Problem - by Sew_Sumi - 26.01.2017, 09:59
Re: Refueling Timer Problem - by SyS - 26.01.2017, 10:16
Re: Refueling Timer Problem - by MiiSha - 26.01.2017, 10:17
Re: Refueling Timer Problem - by SyS - 26.01.2017, 10:28
Re: Refueling Timer Problem - by MiiSha - 26.01.2017, 11:11

Forum Jump:


Users browsing this thread: 1 Guest(s)