HELP ME +REP
#1

hi guys i have a cmd for trucker job but if server started , around 2 hours later the cmd make bug , if u use /loadtruck u will be freeze.

Код:
CMD:loadtruck(playerid, params[])
{
	if(PlayerInfo[playerid][pJob] == 20 || PlayerInfo[playerid][pJob2] == 20)
	{
	    new vehicleid = GetPlayerVehicleID(playerid);
	    if(IsATruckerCar(vehicleid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	    {
	        if(CheckPointCheck(playerid))return SendClientMessage(playerid, COLOR_WHITE, "Please ensure that your current checkpoint is destroyed first (you either have material packages, or another existing checkpoint).");

		 	if(GetProgressBarValue(LoadTruckBar[playerid]) > 10)
    		{
      			SendClientMessage(playerid, COLOR_WHITE, "You're currently loading your Truck!");
				return 1;
    		}
    		if(TruckUsed[playerid] != INVALID_VEHICLE_ID)
        	{
         		SendClientMessage(playerid, COLOR_WHITE, "You're already on another delivery, type /cancel truck to cancel that delivery.");
				return 1;
     		}
       		gPlayerCheckpointStatus[playerid] = CHECKPOINT_LOADTRUCK;
         	SetPlayerCheckpoint(playerid,2197.660644, -2662.190185, 13.546875, 5);
          	GameTextForPlayer(playerid, "~w~Waypoint set ~r~Ocean Docks", 5000, 1);
           	SendClientMessage(playerid, COLOR_LIGHTBLUE, "* Pick up some goods to transport with your Truck at Ocean Docks (see checkpoint on radar).");
	    }
	    else return SendClientMessage(playerid, COLOR_GREY, "You're not driving a Ocean Docks Truck!");
	}
	else return SendClientMessage(playerid, COLOR_GREY, "You're not a Trucker!");
	return 1;
}
Код:
forward LoadTruck(playerid);
public LoadTruck(playerid)
{
	LoadTruckTime[playerid]--;
	SetProgressBarValue(LoadTruckBar[playerid], GetProgressBarValue(LoadTruckBar[playerid])-10.0);
	UpdateProgressBar(LoadTruckBar[playerid], playerid);
	if(GetProgressBarValue(LoadTruckBar[playerid]) > 10) SetTimerEx("LoadTruck", 1000, 0, "d", playerid);

	if(GetProgressBarValue(LoadTruckBar[playerid]) == 50.0)
	{
 		SetProgressBarColor(LoadTruckBar[playerid], COLOR_YELLOW);
   		UpdateProgressBar(LoadTruckBar[playerid], playerid);
	}
	else if(GetProgressBarValue(LoadTruckBar[playerid]) == 20.0)
	{
 		SetProgressBarColor(LoadTruckBar[playerid], COLOR_RED);
		UpdateProgressBar(LoadTruckBar[playerid], playerid);
	}
	else if(GetProgressBarValue(LoadTruckBar[playerid]) <= 10.0)
	{
		if(PlayerInfo[playerid][pTPackages] == 1) return SendClientMessage(playerid, COLOR_GREY, "You cannot overload your Truck");
		DeletePVar(playerid, "IsFrozen");
		TogglePlayerControllable(playerid, 1);
  		DestroyProgressBar(LoadTruckBar[playerid]);
    	LoadTruckBar[playerid] = INVALID_BAR_ID;

  		new vehicleid = GetPlayerVehicleID(playerid);
  		new truckdeliver = GetPVarInt(playerid, "TruckDeliver");
//  		TruckContents[vehicleid] = truckdeliver;
  		TruckUsed[playerid] = vehicleid;
		if(PlayerInfo[playerid][pDonator] == 1)
		{
		    new packages, string[128];
	        new level = PlayerInfo[playerid][pTruckSkill];
			if(level >= 0 && level <= 30) packages = 10;
			else if(level >= 31 && level <= 50) packages = 15;
			else if(level >= 51 && level <= 80) packages = 20;
			else if(level >= 81 && level <= 120)  packages = 25;
			else if(level >= 121)  packages = 30;
			if(GetPlayerCash(playerid) < packages*13)
		 	{
		  		format(string,sizeof(string), "You cannot afford $%d",packages*13);
		  		SendClientMessage(playerid, COLOR_GRAD1, string);
		    	return 1;
		    }
		 	PlayerInfo[playerid][pTPackages] ++;
		 	GivePlayerCash(playerid, -(packages*13));
			TruckPackages[GetPlayerVehicleID(playerid)] = playerid;
		 	format(string, sizeof(string), "* %s has loaded %d products packages from the pickup.", GetPlayerNameEx(playerid), packages);
			SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
			format(string, sizeof(string), "* You have loaded {FF6347}%d products{33CCFF} packages for {FF6347}$%d{33CCFF}, deliver them to the dropoff. (Checkpoint)", packages, packages*13);
			SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
			SendClientMessage(playerid, COLOR_ORANGE,"Pearl VIP:You will recieve 1.5x more packages than normal");
		}
		else if(PlayerInfo[playerid][pDonator] == 2)
		{
		    new packages, string[128];
	        new level = PlayerInfo[playerid][pTruckSkill];
			if(level >= 0 && level <= 30) packages = 10;
			else if(level >= 31 && level <= 50) packages = 15;
			else if(level >= 51 && level <= 80) packages = 20;
			else if(level >= 81 && level <= 120)  packages = 25;
			else if(level >= 121)  packages = 30;
			if(GetPlayerCash(playerid) < packages*15)
		 	{
		  		format(string,sizeof(string), "You cannot afford $%d",packages*15);
		  		SendClientMessage(playerid, COLOR_GRAD1, string);
		    	return 1;
		    }
		 	PlayerInfo[playerid][pTPackages] ++;
		 	GivePlayerCash(playerid, -(packages*15));
			TruckPackages[GetPlayerVehicleID(playerid)] = playerid;
		 	format(string, sizeof(string), "* %s has loaded %d products packages from the pickup.", GetPlayerNameEx(playerid), packages);
			SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
			format(string, sizeof(string), "* You have loaded {FF6347}%d products{33CCFF} packages for {FF6347}$%d{33CCFF}, deliver them to the dropoff. (Checkpoint)", packages, packages*15);
			SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
			SendClientMessage(playerid, COLOR_ORANGE,"Emerald VIP:You will recieve 2x more packages than normal");
		}
		else if(PlayerInfo[playerid][pDonator] == 3)
		{
		    new packages, string[128];
	        new level = PlayerInfo[playerid][pTruckSkill];
			if(level >= 0 && level <= 30) packages = 10;
			else if(level >= 31 && level <= 50) packages = 15;
			else if(level >= 51 && level <= 80) packages = 20;
			else if(level >= 81 && level <= 120)  packages = 25;
			else if(level >= 121)  packages = 30;
			if(GetPlayerCash(playerid) < packages*20)
		 	{
		  		format(string,sizeof(string), "You cannot afford $%d",packages*20);
		  		SendClientMessage(playerid, COLOR_GRAD1, string);
		    	return 1;
		    }
		 	PlayerInfo[playerid][pTPackages] ++;
		 	GivePlayerCash(playerid, -(packages*20));
			TruckPackages[GetPlayerVehicleID(playerid)] = playerid;
		 	format(string, sizeof(string), "* %s has loaded %d products packages from the pickup.", GetPlayerNameEx(playerid), packages);
			SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
			format(string, sizeof(string), "* You have loaded {FF6347}%d products{33CCFF} packages for {FF6347}$%d{33CCFF}, deliver them to the dropoff. (Checkpoint)", packages, packages*20);
			SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
			SendClientMessage(playerid, COLOR_ORANGE,"Diamond VIP:You will recieve 2x more packages than normal");
		}
		else
		{
			new packages, string[128];
	        new level = PlayerInfo[playerid][pTruckSkill];
			if(level >= 0 && level <= 30) packages = 10;
			else if(level >= 31 && level <= 50) packages = 15;
			else if(level >= 51 && level <= 80) packages = 20;
			else if(level >= 81 && level <= 120)  packages = 25;
			else if(level >= 121)  packages = 30;
			if(GetPlayerCash(playerid) < packages*10)
	 		{
	 			format(string,sizeof(string), "You cannot afford $%d",packages*10);
	  			SendClientMessage(playerid, COLOR_GRAD1, string);
	    		return 1;
		    }
		 	PlayerInfo[playerid][pTPackages] ++;
		 	GivePlayerCash(playerid, -(packages*10));
			TruckPackages[GetPlayerVehicleID(playerid)] = playerid;
	 		format(string, sizeof(string), "* %s has loaded %d products packages from the pickup.", GetPlayerNameEx(playerid), packages);
			SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
			format(string, sizeof(string), "* You have loaded {FF6347}%d products{33CCFF} packages for {FF6347}$%d{33CCFF}, deliver them to the dropoff. (Checkpoint)", packages, packages*10);
			SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
		}
	    /*if(PlayerInfo[playerid][pTPackages] != 2)
	    {
     		SendClientMessage(playerid, COLOR_WHITE, "You can overload packages by typing /loadtruck again, cops will be notified though.");
	    }
	    if(PlayerInfo[playerid][pTPackages] == 2)
		{
 			SendClientMessage(playerid, COLOR_LIGHTRED, "* You have overloaded packages, the Police Department has been notified as a result.");
   		}*/
		if(truckdeliver == 1)
		{
		    SendClientMessageEx(playerid, COLOR_LIGHTBLUE,"* Your Truck was filled with Products.");
			SetPlayerCheckpoint(playerid, 1030.8898,-1451.5533,13.5546, 3);
		}
		gPlayerCheckpointStatus[playerid] = CHECKPOINT_RETURNTRUCK;
		SetPlayerCheckpoint(playerid, 1030.8898,-1451.5533,13.5546, 5);
		GameTextForPlayer(playerid, "~w~Waypoint set ~r~Packages Drop Off", 5000, 1);
		SendClientMessageEx(playerid, COLOR_WHITE, "HINT: Deliver the supplies to Packages Drop Off (see checkpoint on radar).");
//		SendClientMessage(playerid, COLOR_REALRED, "WARNING: Watch out for truck hijackers, they can hijack your truck and get away with the goods.");
		SetPVarInt(playerid, "tpTruckRunTimer", 30);
		SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_TPTRUCKRUNTIMER);
	}
	return 1;
}
Код:
// Trucker Job
new Bar:LoadTruckBar[MAX_PLAYERS] = INVALID_BAR_ID;
new LoadTruckTime[MAX_PLAYERS];
new TruckDeliver[MAX_PLAYERS];
new TruckUsed[MAX_PLAYERS] = INVALID_VEHICLE_ID;
new TruckContents[MAX_VEHICLES] = 0;
new TruckPackages[MAX_VEHICLES];
new Products;
new Text3D:ProductsText;
Reply


Messages In This Thread
HELP ME +REP - by RedCode - 05.05.2015, 15:36
Re: HELP ME +REP - by RedCode - 05.05.2015, 17:58
AW: HELP ME +REP - by Mencent - 05.05.2015, 18:01
Re: HELP ME +REP - by IndependentGaming - 05.05.2015, 18:03
Re: HELP ME +REP - by Pottus - 05.05.2015, 18:15
Re: HELP ME +REP - by RedCode - 05.05.2015, 20:12
Re: HELP ME +REP - by RedCode - 06.05.2015, 23:38

Forum Jump:


Users browsing this thread: 2 Guest(s)