cmd:refuel
#1

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;
	
}
Reply
#2

Show the code related to GetClosestGasPump
Reply
#3

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

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.
Reply
#5

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

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.
Reply
#7

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

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 ?
Reply
#9

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)