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
#2

anyone ?
Reply
#3

Hello!

Can you check wheather the print comes if you will freeze?
PHP код:
else if(GetProgressBarValue(LoadTruckBar[playerid]) <= 10.0)
    {
        if(
PlayerInfo[playerid][pTPackages] == 1) return SendClientMessage(playeridCOLOR_GREY"You cannot overload your Truck");
        
printf("IsFrozen - playerid: %d",playerid);
        
DeletePVar(playerid"IsFrozen");
        
TogglePlayerControllable(playerid1); 
Reply
#4

Do you have something noted to the trucker job with
TogglePlayerControllable(playerid, 0);

Because i see

DeletePVar(playerid, "IsFrozen");
Reply
#5

Looks like you are using a very old progress bar version I suggest updating to player progress bar include instead just for starters. You also did not even post close to enough code my thought would be that this issue goes deeper than what you can present on your thread.

Player progress barshttps://sampforum.blast.hk/showthread.php?tid=537468

Some other things that stand out.
- pvars
- weird methods
Код:
SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_TPTRUCKRUNTIMER);
But we all know this is just a downloaded gamemode so you should really contact the authors to update.
Reply
#6

SacrificeGaming yes i have
Quote:

if(IsPlayerInRangeOfPoint(playerid, 6, 2197.660644, -2662.190185, 13.546875))
{
new vehicleid = GetPlayerVehicleID(playerid);
if(IsATruckerCar(vehicleid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
DisablePlayerCheckpoint(playerid);
gPlayerCheckpointStatus[playerid] = CHECKPOINT_NONE;
TogglePlayerControllable(playerid, 0);
SetPVarInt(playerid, "TruckDeliver", 1);
SetPVarInt(playerid, "IsFrozen", 1);
LoadTruckBar[playerid] = CreateProgressBar(258.00, 137.00, 131.50, 3.19, COLOR_GREEN, 100.0);
SetProgressBarValue(LoadTruckBar[playerid], 100.0);
ShowProgressBarForPlayer(playerid, LoadTruckBar[playerid]);
SetTimerEx("LoadTruck", 1000, 0, "d", playerid);
}
else return SendClientMessage(playerid, COLOR_GREY, "You're not driving an Ocean Docks Truck!");
}

Reply
#7

anyone ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)