Need Help With This Script I am No Good At Scripting
#1

Код:
#include<streamer>
#include<string>

#define JOBMENU 1307
#define HELPMENU 1306

/* Trunk System */
#define MAX_TRUNK_SLOTS		(5) //Only 4

new LoadTankerTime[MAX_PLAYERS];//ftjob
new UnloadTankerTime[MAX_PLAYERS];//ftjob

	pTankerTime,//ftjob
	LoadTankerTime[playerid] = 0;
	UnloadTankerTime[playerid] = 0;//ftjob
    PlayerInfo[playerid][pTankerTime] = 0;//ftjob

public OnFilterScriptInit()
{

	Create3DTextLabel("Trucker Job \nDo /join to become one ",COLOR_RED,358.2409,182.4902,1008.3828+0.5,10.0, 0);// Trucker
	CreateDynamicPickup(1239,1,358.2409,182.4902,1008.3828);//Trucker Registration
	CreateDynamicPickup(1239,1,261.1522,1451.3818,10.1481);//Trucker Buyfuel
	CreateDynamicPickup(1239,1,998.0496,-896.8078,42.2531);//Trucker Sellfuel
}
 //----------------------------------[JOB HELP]----------------------------------------------
			if(listitem == 1) //
			{
				SendClientMessage(playerid, COLOR_LIGHTBLUE, "|===[Trucker Commands ]===|");
				SendClientMessage(playerid, COLOR_GREEN, "** /buyfuel [amount] - /sellfuel **");
			}

        else if(PlayerInfo[targetid][pJob] == 16) { jtext = "Trucker"; }//ftjob
    }
	if(strcmp(cmd, "/jobhelp", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            ShowPlayerDialog(playerid, JOBMENU, DIALOG_STYLE_LIST, "Job Help","nTrucker", "Help", "Cancel");
            SendClientMessage(playerid, COLOR_GREEN, " ** Select a job you want help in !");
        }
        return 1;
    }
    	if(strcmp(cmd, "/jobs", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
            ShowPlayerDialog(playerid,DIALOG_CDEDITPARK,DIALOG_STYLE_MSGBOX,"Jobs:","16:Trucker","Close","Cancel");
		}
		return 1;
	}
	if(strcmp(cmd, "/join", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(PlayerInfo[playerid][pJob] == 0)
			{
			if (GetPlayerState(playerid) == 1 && PlayerToPoint(3.0, playerid,358.2409,182.4902,1008.3828))//ftjob
		  		{
		  		    SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You are about to become a Trucker.");
				    SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You have to forfill this Contract first, if you want to Quit the job later.");
				    SendClientMessage(playerid, COLOR_LIGHTBLUE, "* If you are sure to become a Trucker, type /accept job.");
				    GettingJob[playerid] = 16;
				}
 //----------------------------------[new line]----------------------------------------------
			if(LoadTankerTime[i] >= 1)
			{
			    LoadTankerTime[i] += 1;
			    if(LoadTankerTime[i] == 5)
			    {
				  	SendClientMessage(i, COLOR_PURPLE, "   25 percent");
			    }
			    else if(LoadTankerTime[i] == 8)
			    {
				  	SendClientMessage(i, COLOR_PURPLE, "   50 percent");
			    }
			    else if(LoadTankerTime[i] == 11)
			    {
				  	SendClientMessage(i, COLOR_PURPLE, "   75 percent");
			    }
			    else if(LoadTankerTime[i] == 14)
			    {
				  	SendClientMessage(i, TEAM_GROVE_COLOR, "   The Tanker is now Full, deliver the fuel to Vinewood Gas Station");
			    }
			    else if(LoadTankerTime[i] == 15)
			    {
			        LoadTankerTime[i] = 0;
					TogglePlayerControllable(i, 1);
			    }
			}
			if(UnloadTankerTime[i] >= 1)
			{
			    new tmpcar = GetPlayerVehicleID(i);
			    new tmptrailer = GetVehicleTrailer(tmpcar);
			    UnloadTankerTime[i] += 1;
			    if(LoadTankerTime[i] == 2)
			    {
				  	SendClientMessage(i, COLOR_PURPLE, "   The Fuel is being unloaded, please wait");
			    }
			    else if(UnloadTankerTime[i] == 5)
			    {
				  	SendClientMessage(i, COLOR_PURPLE, "   75 percent");
			    }
			    else if(UnloadTankerTime[i] == 8)
			    {
				  	SendClientMessage(i, COLOR_PURPLE, "   50 percent");
			    }
			    else if(UnloadTankerTime[i] == 11)
			    {
				  	SendClientMessage(i, COLOR_PURPLE, "   25 percent");
			    }
			    else if(UnloadTankerTime[i] == 14)
			    {
				  	SendClientMessage(i, COLOR_RED, "   The Tanker is now Empty, you will receive a message when more fuel is available.");
			    }
			    else if(UnloadTankerTime[i] == 15)
			    {
			        UnloadTankerTime[i] = 0;
					TogglePlayerControllable(i, 1);
		        	Gas[tmpcar] = GasMax;
    		    	SetVehicleToRespawn(GetPlayerVehicleID(i));
        			SetVehicleToRespawn(tmptrailer);
			    }
			}
			if(PlayerInfo[i][pTankerTime] > 0)
			{
			    if(PlayerInfo[i][pTankerTime] == 1)
			    {
			        if(PlayerInfo[i][pJob] == 16)
			        {
				        SendClientMessage(i, COLOR_GRAD2, "   The next load of Fuel is ready at the Refinery.");
				        PlayerInfo[i][pTankerTime] -= 1;
					}
			        else
			        {
				        PlayerInfo[i][pTankerTime] -= 1;
					}
			    }
			    else if(PlayerInfo[i][pTankerTime] <= 0)
			    {
			        PlayerInfo[i][pTankerTime] = 0;
			    }
			    else
			    {
			        PlayerInfo[i][pTankerTime] -= 1;
			    }
			}
	if(strcmp(cmd, "/buyfuel", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
		{
            if ((PlayerInfo[playerid][pJob] == 16))
			{
				new tmpcar = GetPlayerVehicleID(playerid);
				new compcost = 10;
				if(PlayerToPoint(5.0, playerid, 261.1522,1451.3818,10.1481))
				{
				    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 (PlayerToPoint(5.0, playerid, 998.0496,-896.8078,42.2531))
				{
					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, TEAM_GROVE_COLOR, "   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 Idlewood Gas Station.");
				    return 1;
				}
			}
			else
			{
			    SendClientMessage(playerid, COLOR_GRAD1, "   You are not in a Fuel Tanker or do not have a Trailer attached.");
			    return 1;
			}
		}
	}
i have cut it out of a game mode and want it as a filterscript
Reply
#2

save as a .PWN file, compile, and in your server.cfg file add next to the word "filterscripts" whatever you saved this at

Example:
-> Save as "trucker.pwn" in the filterscripts folder
in server.cfg -> "filterscripts trucker"
Reply
#3

it doesnt compile
Reply
#4

That is because you have made some errors, wich indicates that you have coded something wrong in the script. Can we see the errors so we can fix them maybe?
Reply
#5

When you compile, does the compiler crash or does it show the erros you get?
Reply
#6

it crashes
Reply
#7

Umm maybe you need to add:

Quote:

#include <a_samp>

at the top of your script, not sure but yeah give it a go.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)