SA-MP Forums Archive
Trucker Job Issue - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Trucker Job Issue (/showthread.php?tid=268056)



Trucker Job Issue - EdeniaGaming - 11.07.2011

Код:
		if(IsAFuelTruck(newcar))//ftjob
		{
		    if(PlayerInfo[playerid][pJob] == 16)
			{
				format(string, sizeof(string), "Fuel: %d,000/%d,000 Gallons", PlayerHaul[newcar][pFuelLoad],PlayerHaul[newcar][pCapasity]);
				SendClientMessage(playerid, COLOR_YELLOW, string);
				SendClientMessage(playerid, COLOR_WHITE, "INFO: You can deliver Fuel to Los Santos Trucking Docks.");
				SendClientMessage(playerid, COLOR_WHITE, "INFO: Commands are /buyfuel [amount] /sellfuel");
			}
			else
			{
   				SendClientMessage(playerid, COLOR_WHITE, "  You are not a Truck Driver.");
			    RemovePlayerFromVehicle(playerid);
			    TogglePlayerControllable(playerid, 1);
			}
		}
Код:
enum pHaul
{
	pCapasity,
	pLoad,
	pFuelLoad,//ftjob
};

new PlayerHaul[][pHaul];
Ok the problem is when i enter a 'fueltruck' it says something like

Fuel: -12391782591725,000/20,000 Gallons

Its suppose to be saying when I enter a fueltruck 0/20,000

Why is it saying this weird number ?


Re: Trucker Job Issue - dowster - 11.07.2011

you made the enum wrong, there is no coma after pFuelLoad. should be like this.
Код:
enum pHaul
{
	pCapasity,
	pLoad,
	pFuelLoad
}

new PlayerHaul[][pHaul];
also i removed the semicolon after the enum, no need for it.


Re: Trucker Job Issue - EdeniaGaming - 11.07.2011

Код:
PlayerHaul[1801][pCapasity] = 100;
Ok now i was in the truck id 1801 , the only thing that changed was it removed the minus sign for the pFuelload

Instead of saying -12391782591725,000/100,000 Gallons
It now says 12391782591725,000/100,000 Gallons


Re: Trucker Job Issue - Adil - 11.07.2011

Set it to 0 on OnPlayerConnect.
pawn Код:
PlayerHaul[newcar][pFuelLoad] = 0;



Re: Trucker Job Issue - EdeniaGaming - 11.07.2011

Still gives me 12391782591725,000/100,000 Gallons


Re: Trucker Job Issue - Toreno - 11.07.2011

These codes are not enough for us to help you with your problem.


Re: Trucker Job Issue - EdeniaGaming - 11.07.2011

Код:
enum pHaul
{
	pCapasity,
	pLoad,
	pFuelLoad
}

new PlayerHaul[][pHaul];
This code below = On Player State Driver ( When I enter a vehicle the "Fuel: %d,000/%d,000 Gallons" is saying the 1000123812091/100,000 Gallons )
Код:
if(IsAFuelTruck(newcar))//ftjob
		{
		    if(PlayerInfo[playerid][pJob] == 16)
			{
				format(string, sizeof(string), "Fuel: %d,000/%d,000 Gallons", PlayerHaul[newcar][pFuelLoad],PlayerHaul[newcar][pCapasity]);
				SendClientMessage(playerid, COLOR_YELLOW, string);
				SendClientMessage(playerid, COLOR_WHITE, "INFO: You can deliver Fuel to Los Santos Trucking Docks.");
				SendClientMessage(playerid, COLOR_WHITE, "INFO: Commands are /buyfuel [amount] /sellfuel");
			}
			else
			{
   				SendClientMessage(playerid, COLOR_WHITE, "  You are not a Truck Driver.");
			    RemovePlayerFromVehicle(playerid);
			    TogglePlayerControllable(playerid, 1);
			}
		}
Код:
forward IsAFuelTruck(carid);//ftjob
Код:
public IsAFuelTruck(carid)//ftjob
{
	if(carid == 1801 || carid == 1825 || carid == 1806 || carid == 1792 || carid == 1794)
	{
		return 1;
	}
	return 0;
}
This code below = OnGameModeInt

Код:
	PlayerHaul[1801][pCapasity] = 100;
	PlayerHaul[1825][pCapasity] = 100;
	PlayerHaul[1806][pCapasity] = 50;
	PlayerHaul[1792][pCapasity] = 20;//ftjob
	PlayerHaul[1794][pCapasity] = 20;//ftjob
Код:
if(strcmp(cmd, "/buyfuel", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
		{
            if(PlayerInfo[playerid][pJob] == 16)
			{
				new tmpcar = GetPlayerVehicleID(playerid);
				new compcost = 10;
				if(IsPlayerInRangeOfPoint(playerid,5.0, -1033.5093,-625.7611,32.0078))
				{
				    if(IsAFuelTruck(tmpcar) && IsTrailerAttachedToVehicle(tmpcar))
					{
					    if(PlayerHaul[tmpcar][pFuelLoad] < PlayerHaul[tmpcar][pCapasity])
						{
						    new amount;
						    tmp = strtok(cmdtext, idx);
							if(!strlen(tmp))
							{
								SendClientMessage(playerid, COLOR_GRAD1, "   USAGE: /buyfuel [amount]");
								return 1;
							}
							amount = strval(tmp);
							if(amount < 1 || amount > 10) { SendClientMessage(playerid, COLOR_GREY, "   Can't buy less than 1 Fuel Product or more then 10 !"); return 1; }
							new check= PlayerHaul[tmpcar][pFuelLoad] + amount;
							if(check > PlayerHaul[tmpcar][pCapasity])
							{
							    format(string, sizeof(string), "   You went over the Truck's Fuel Load Limit of %d, you currently have %d Fuel loaded.",PlayerHaul[tmpcar][pCapasity],PlayerHaul[tmpcar][pFuelLoad]);
	                            SendClientMessage(playerid, COLOR_GREY, string);
							    return 1;
							}
							new cost = amount*compcost;
							if(GetPlayerMoney(playerid) >= cost)
							{
							    if(PlayerInfo[playerid][pTankerTime] == 0)
							    {
									if(LoadTankerTime[playerid] <= 1)
									{
									    PlayerInfo[playerid][pTankerTime] = 1800;
									    LoadTankerTime[playerid] += 1;
									    TogglePlayerControllable(playerid, 0);
										PlayerHaul[tmpcar][pFuelLoad] += amount;
										format(string, sizeof(string), "   Fuel: %d,000/%d,000 Gallons.", PlayerHaul[tmpcar][pFuelLoad],PlayerHaul[tmpcar][pCapasity]);
										SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
										format(string, sizeof(string), "   You bought %d,000 Gallons of fuel for $%d.", amount,cost);
										SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
										SendClientMessage(playerid, COLOR_PURPLE, "   The Fuel Tanker is being filled, please wait");
										GivePlayerMoney(playerid,-cost);
										PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
										return 1;
									}
								}
								else
								{
								    SendClientMessage(playerid, COLOR_GREY, "   There is no Fuel available at the moment, please wait");
								    return 1;
								}
							}
							else
							{
								format(string, sizeof(string), "   You cant afford %d,000 Gallons of Fuel at $%d !", amount,cost);
								SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
								return 1;
							}
						}
						else
						{
								format(string, sizeof(string), "   Fuel: %d,000/%d,000 Gallons.", PlayerHaul[tmpcar][pFuelLoad],PlayerHaul[tmpcar][pCapasity]);
								SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
								return 1;
						}
					}
					else
					{
						SendClientMessage(playerid, TEAM_GROVE_COLOR, "   This Vehicle does not deliver Fuel Products or there is no trailer attach.");
						return 1;
					}
				}
				else
				{
					SendClientMessage(playerid, TEAM_GROVE_COLOR, "   Your not at the Fuel Refinery.");
					return 1;
				}
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_GRAD1, "   You are not a Truck Driver.");
			return 1;
		}
		return 1;
	}
	if(strcmp(cmd, "/sellfuel", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
		{
		    new tmpcar = GetPlayerVehicleID(playerid);
			if(IsAFuelTruck(tmpcar) && IsTrailerAttachedToVehicle(tmpcar))
			{
				if (IsPlayerInRangeOfPoint(playerid, 5.0, 2486.4705,-2082.4055,13.1109))
				{
					if (PlayerHaul[tmpcar][pFuelLoad] >= 1)
					{
						new cashmade = PlayerHaul[tmpcar][pFuelLoad]*15;
					    UnloadTankerTime[playerid] += 1;
					    TogglePlayerControllable(playerid, 0);
						ConsumingMoney[playerid] = 1;
						GivePlayerMoney(playerid,cashmade);
						PlayerHaul[tmpcar][pFuelLoad] = 0;
						SendClientMessage(playerid, COLOR_YELLOW, "All fuel in the Truck has been Sold.");
					}
					else
					{
						SendClientMessage(playerid, COLOR_GRAD1, "   There is no fuel Loaded, return to the Fuel Refinery.");
						return 1;
					}
				}
				else
				{
				    SendClientMessage(playerid, COLOR_GRAD1, "   You are not at Los Santos Trucker Docks.");
				    return 1;
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GRAD1, "   You are not in a Fuel Tanker or do not have a Trailer attached.");
			    return 1;
			}
		}
	}



Re: Trucker Job Issue - EdeniaGaming - 11.07.2011

bump ?


Re: Trucker Job Issue - beauhobbs - 11.07.2011

Have you got teamviewer? I may be able to lend a hand. Send me your Info over PM's if you still need a hand.


Re: Trucker Job Issue - dowster - 12.07.2011

try
Код:
new PlayerHaul[2001][pHaul];
the one is there because if you used vehicle ID 2000 it would crash because there would be no slot 2000 in the array, if it started at 0,