SA-MP Forums Archive
cmd:refuel - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: cmd:refuel (/showthread.php?tid=564972)



cmd:refuel - rhandie02 - 24.02.2015

Someone Help me ?

When I type /refuel near gas pump with business



So It didn't work when near the gas pump



Command:
Код:
CMD:refuel(playerid, params[])
{
    if (GetPVarType(playerid, "Refueling"))
	{
	    SetPVarInt(playerid, "Refueling", -1);
	}
	else
	{

	    new vehicleid = GetPlayerVehicleID(playerid);

		new
			iBusinessID,
			iPumpID;

		GetClosestGasPump(playerid, iBusinessID, iPumpID);
		if (iBusinessID == INVALID_BUSINESS_ID)
		{
		        SendClientMessageEx(playerid, COLOR_RED, "You're not at a fuel station.");
                    	return 1;
		}
		if (!Businesses[iBusinessID][bStatus])
		{
			SendClientMessageEx(playerid, COLOR_RED, "This fuel station is closed.");
                    	return 1;
		}
		if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
		{
			SendClientMessageEx(playerid, COLOR_WHITE, "You are not driving a vehicle!");
                    	return 1;
		}
		if(VehicleFuel[vehicleid] >= 100.0)
		{
			SendClientMessageEx(playerid, COLOR_WHITE, "Your vehicle fuel tank is full!");
                    	return 1;
		}
		if (IsVIPcar(vehicleid))
		{
			SendClientMessageEx(playerid, COLOR_RED, "This is a vehicle from the VIP garage and it has already unlimited amount of fuel.");
                    	return 1;
		}
		if (CreatedCars[vehicleid] != INVALID_VEHICLE_ID)
		{
			SendClientMessageEx(playerid, COLOR_RED, "This is an admin-spawned vehicle and it has already unlimited amount of fuel.");
                    	return 1;
		}
		new engine,lights,alarm,doors,bonnet,boot,objective;
		GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
	        if(engine == VEHICLE_PARAMS_ON)
		{
	 		SendClientMessageEx(playerid, COLOR_RED, "You need to shut off the engine before filling up (/car engine).");
                    	return 1;
		}
		if (Businesses[iBusinessID][GasPumpGallons][iPumpID] == 0.0)
		{
			SendClientMessageEx(playerid, COLOR_RED, "No gas left in the gas station tank.");
                    	return 1;
		}
		if (GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
		{
			SendClientMessageEx(playerid,COLOR_RED,"This vehicle does not need fuel.");
                    	return 1;
		}
		if (Businesses[iBusinessID][GasPumpVehicleID][iPumpID] > 0)
		{
		        SendClientMessageEx(playerid, COLOR_RED, "This gas pump is occupied.");
                    	return 1;
		}
		SendClientMessageEx(playerid, COLOR_WHITE, "Refueling your vehicle's tank, please wait.");
		SendClientMessageEx(playerid, COLOR_YELLOW, "Type /refuel again to stop refueling.");
		SetPVarInt(playerid, "Refueling", vehicleid);
		Businesses[iBusinessID][GasPumpSaleGallons][iPumpID] = 0;
		Businesses[iBusinessID][GasPumpSalePrice][iPumpID] = 0;
		Businesses[iBusinessID][GasPumpVehicleID][iPumpID] = vehicleid;
		Businesses[iBusinessID][GasPumpTimer][iPumpID] = SetTimerEx("GasPumpSaleTimer", 200, true, "iii", playerid, iBusinessID, iPumpID);

	}
	return 1;
	
}



Re: cmd:refuel - Excips - 24.02.2015

Show the code related to GetClosestGasPump


Re: cmd:refuel - ball - 24.02.2015

Install crashdetect plugin. Probably one of arrays' size is to small.


Re: cmd:refuel - rhandie02 - 25.02.2015

Quote:
Originally Posted by Excips
Посмотреть сообщение
Show the code related to GetClosestGasPump
Код:
stock GetClosestGasPump(playerid, &businessid, &pumpslot)
{
	new Float: minrange = 5.0, Float: range;

	businessid = INVALID_BUSINESS_ID;

    for(new b = 0; b < MAX_BUSINESSES; b++)
    {
	    for(new i = 0; i < MAX_BUSINESS_GAS_PUMPS; i++)
	    {
	        range = GetPlayerDistanceFromPoint(playerid, Businesses[b][GasPumpPosX][i], Businesses[b][GasPumpPosY][i], Businesses[b][GasPumpPosZ][i]);
	 	    if (range < minrange)
			{
				businessid = b;
				pumpslot = i;
			    minrange = range;
		    }
	   	}
 	}
}
here.


Re: cmd:refuel - rhandie02 - 01.03.2015

Quote:
Originally Posted by ball
Посмотреть сообщение
Install crashdetect plugin. Probably one of arrays' size is to small.
how install that crashdetect to my server


Re: cmd:refuel - 1fret - 01.03.2015

Quote:
Originally Posted by rhandie02
Посмотреть сообщение
how install that crashdetect to my server
Download the plugin and in your serversamp.cfg folder add crashdetect.dll(or .so if your using linux verion). Then run script.


Re: cmd:refuel - Blade_Cervetti - 01.03.2015

put the crashdetect.so or .dll in your plugins folder and add it to the plugins line in server.cfg. Then restart your server


Re: cmd:refuel - rhandie02 - 04.03.2015

what happened if i install it ? it show what a problem in any commands or on my scripts ? lol ahahah .. many kinds of crashdetect i dont know what exactly is it ?


AW: cmd:refuel - Kaliber - 04.03.2015

Well, it shows you if some errors are comming up in your code.

E.g.

PHP код:
new 99;
new 
string[10];
string[x] = "hello"
Here crashdetect would send you an out of bounds error