SA-MP Forums Archive
ID 1 and up freezes when enter car. - 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: ID 1 and up freezes when enter car. (/showthread.php?tid=93550)



ID 1 and up freezes when enter car. - Devine - 25.08.2009

Only id 0 can enter a car without being frozen.. all other IDs get froze and need to be /unfreeze'd.. Help?


Re: ID 1 and up freezes when enter car. - Khelif - 25.08.2009

I believe we cant help you without code


Re: ID 1 and up freezes when enter car. - Joe Staff - 25.08.2009

Right, show us OnPlayerEnterVehicle and OnPlayerStateChange


Re: ID 1 and up freezes when enter car. - Devine - 25.08.2009

Код:
//------------------------------------------------------------------------------------------------------

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	if(GetVehicleModel(vehicleid)==427 &&!ispassenger) { GetPlayerArmour(playerid,parmor[playerid]); }
	if(gTeam[playerid] >= 3)
	{
		if (IsACopCar(vehicleid) && !ispassenger)
		{
			if(PlayerInfo[playerid][pLeader]==1||PlayerInfo[playerid][pLeader]==2||PlayerInfo[playerid][pLeader]==3) {}
		  else { WantedPoints[playerid]+=2; SetPlayerCriminal(playerid,255, "Stealing A Police Vehicle"); }
		}
		if (IsAnAmbulance(vehicleid) && !ispassenger)
		{
		  if(PlayerInfo[playerid][pMember]==4||PlayerInfo[playerid][pLeader]==4) { }
		  else { WantedPoints[playerid]+=2; SetPlayerCriminal(playerid,255, "Stealing An Ambulance"); }
		}
	}
	return 1;
}



Re: ID 1 and up freezes when enter car. - Devine - 25.08.2009

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	new string[256];
	if(newstate == PLAYER_STATE_ONFOOT)
	{
	  if(PlayerKarting[playerid] > 0 && PlayerInKart[playerid] > 0)
		{
		  PlayerInKart[playerid] = 0;
		  KartingPlayers --;
		}
	  if(TransportDuty[playerid] > 0)
		{
		  if(TransportDuty[playerid] == 1)
			{
		    TaxiDrivers -= 1;
			}
			else if(TransportDuty[playerid] == 2)
			{
			  BusDrivers -= 1;
			  DisablePlayerRaceCheckpoint(playerid);
			}
			TransportDuty[playerid] = 0;
			format(string, sizeof(string), "* You are now Off Duty and earned $%d.", TransportMoney[playerid]);
			SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
			GivePlayerMoney(playerid, TransportMoney[playerid]);
			ConsumingMoney[playerid] = 1; TransportValue[playerid] = 0; TransportMoney[playerid] = 0;
		}
		if(TransportCost[playerid] > 0 && TransportDriver[playerid] < 999)
		{
		  if(IsPlayerConnected(TransportDriver[playerid]))
			{
			  TransportMoney[TransportDriver[playerid]] += TransportCost[playerid];
			  TransportTime[TransportDriver[playerid]] = 0;
			  TransportCost[TransportDriver[playerid]] = 0;
			  format(string, sizeof(string), "~w~The ride cost~n~~r~$%d",TransportCost[playerid]);
			  GameTextForPlayer(playerid, string, 5000, 1);
			  format(string, sizeof(string), "~w~Passenger left the taxi~n~~g~Earned $%d",TransportCost[playerid]);
			  GameTextForPlayer(TransportDriver[playerid], string, 5000, 1);
				GivePlayerMoney(playerid, -TransportCost[playerid]);
				GivePlayerMoney(TransportDriver[playerid], TransportCost[playerid]);
				TransportCost[playerid] = 0;
				TransportTime[playerid] = 0;
				TransportDriver[playerid] = 999;
			}
		}
		TelePos[playerid][0] = 0.0;
		TelePos[playerid][1] = 0.0;
	}
	if(newstate == PLAYER_STATE_PASSENGER) // TAXI & BUSSES
	{
	  new name[MAX_PLAYER_NAME];
	  GetPlayerName(playerid, name, sizeof(name));
	  new vehicleid = GetPlayerVehicleID(playerid);
	  for(new i = 0; i < MAX_PLAYERS; i++)
	  {
	    if(IsPlayerConnected(i))
	    {
	      if(IsPlayerInVehicle(i, vehicleid) && GetPlayerState(i) == 2 && TransportDuty[i] > 0)
	      {
	        if(GetPlayerMoney(playerid) < TransportValue[i])
	        {
	          format(string, sizeof(string), "* You need $%d to enter.", TransportValue[i]);
						SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
						RemovePlayerFromVehicle(playerid);
	        }
	        else
	        {
	          if(TransportDuty[i] == 1)
	          {
	            format(string, sizeof(string), "* You paid $%d to the Taxi Driver.", TransportValue[i]);
							SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
							format(string, sizeof(string), "* Passenger %s has entered your Taxi.", name);
							SendClientMessage(i, COLOR_LIGHTBLUE, string);
							TransportTime[i] = 1;
	          	TransportTime[playerid] = 1;
	          	TransportCost[playerid] = TransportValue[i];
	          	TransportCost[i] = TransportValue[i];
	          	TransportDriver[playerid] = i;
	          }
	          else if(TransportDuty[i] == 2)
	          {
	            format(string, sizeof(string), "* You paid $%d to the Bus Driver.", TransportValue[i]);
							SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
							format(string, sizeof(string), "* Passenger %s has entered your Bus.", name);
							SendClientMessage(i, COLOR_LIGHTBLUE, string);
	          }
						GivePlayerMoney(playerid, - TransportValue[i]);
						TransportMoney[i] += TransportValue[i];
	        }
	      }
	    }
	  }
	}
	if(newstate == PLAYER_STATE_WASTED)
	{
		if(WantedLevel[playerid] >= 1)
		{
		  new price = WantedLevel[playerid] * 4000;
			new count;
			for(new i = 0; i < MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
				  if(gTeam[i] == 2 && CrimInRange(30.0, playerid,i))
				  {
						count = 1;
						format(string, sizeof(string), "~w~Running Suspect~r~Killed~n~Bonus~g~$%d", price);
						GameTextForPlayer(i, string, 5000, 1);
						ConsumingMoney[i] = 1;
						GivePlayerMoney(i, price / 2);
						PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
					}
				}
			}
			if(count == 1)
			{
				GivePlayerMoney(playerid, - price);
				PlayerInfo[playerid][pWantedDeaths] += 1;
				PlayerInfo[playerid][pJailed] = 1;
			  PlayerInfo[playerid][pJailTime] = (WantedLevel[playerid])*(600);
			  format(string, sizeof(string), "* You are in Jail for %d Seconds and lose $%d because of running away and getting shot by the Officer.", PlayerInfo[playerid][pJailTime], price);
			  SendClientMessage(playerid, COLOR_LIGHTRED, string);
			  WantedPoints[playerid] = 0;
				WantedLevel[playerid] = 0;
			}
		}
	}
	if(newstate == PLAYER_STATE_DRIVER) //buggy dont finnish
	{// 38 / 49 / 56 = SS
		gLastCar[playerid] = GetPlayerVehicleID(playerid);
		new newcar = GetPlayerVehicleID(playerid);
		//new carmodel = GetVehicleModel(newcar); Don't uncomment at the moment as this function does not check for model ID's ATM
		new oldcar = gLastCar[playerid];
		new housecar = PlayerInfo[playerid][pPhousekey]+1;
		TelePos[playerid][0] = 0.0;
		TelePos[playerid][1] = 0.0;
		if(IsABoat(newcar))
		{
		  if(PlayerInfo[playerid][pBoatLic] < 1)
			{
			  SendClientMessage(playerid, COLOR_GREY, "  You don't know how to Sail yet, so you left the Boat!");
			  RemovePlayerFromVehicle(playerid);
			}
		}
		else if(IsAPlane(newcar))
		{
		  if(PlayerInfo[playerid][pFlyLic] < 1)
			{
			  if(TakingLesson[playerid] == 1) { }
			  else {
			  SendClientMessage(playerid, COLOR_GREY, "  You don't know how to fly yet, so you left the plane!");
			  RemovePlayerFromVehicle(playerid); }
			}
		}
		else
		{
			if(PlayerInfo[playerid][pCarLic] < 1)
			{
			    if(PlayerDrunk[playerid] >= 5)
				{
				  WantedPoints[playerid] += 1;
					SetPlayerCriminal(playerid,255, "Drunk Driving");
				}
				  if(TakingLesson[playerid] == 1) { }
				  else {
				  SendClientMessage(playerid, COLOR_RED, "WARNING: You do not have a driving license.");
        }
			}
		}//Done with car check
		if(GetVehicleModel(newcar)==427) { SetPlayerArmour(playerid,parmor[playerid]); }
		if(IsACopCar(newcar))
		{
		  if(IsACop(playerid)||PlayerInfo[playerid][pMember]==8||PlayerInfo[playerid][pLeader]==8) { }
		  else { RemovePlayerFromVehicle(playerid); }
		}
		else if(IsAnAmbulance(newcar))
		{
		  if(PlayerInfo[playerid][pMember] == 4||PlayerInfo[playerid][pLeader] == 4) { }
		  else { RemovePlayerFromVehicle(playerid); }
		}
		if(IsATruck(newcar))
		{
			format(string, sizeof(string), "Products: %d/%d", PlayerHaul[newcar][pLoad],PlayerHaul[newcar][pCapasity]);
			SendClientMessage(playerid, TEAM_GROVE_COLOR, string);
			SendClientMessage(playerid, COLOR_WHITE, "INFO: You can deliver Products to Businesses.");
			SendClientMessage(playerid, COLOR_WHITE, "INFO: Commands are /load /buyprods /sellprods");
		}
		if(PlayerKarting[playerid] != 0)
		{
		  new kart = GetPlayerVehicleID(playerid);
		  if(kart==110||kart==111||kart==112||kart==113||kart==114||kart==115)
		  {
		    PlayerInKart[playerid] = 1;
		  	KartingPlayers ++;
			}
		}

        //if(newcar == 86 ||newcar == 87 ||newcar == 88 ||newcar == 89 ||newcar == 90 )
        //{
         //  if(PlayerInfo[playerid][pMember] = 4)
        //  {
        //    SendClientMessage(playerid,COLOR_GREY,"  You are not allowed to use this vehicle. (Faction vehicle)");
        ///     RemovePlayerFromVehicle(playerid);
       //   }
       //  }

		/*if(newcar == 64 ||newcar == 65)
		{
			if(IsACop(playerid)) { }
			else
			{
				SendClientMessage(playerid,COLOR_GREY,"  You are not a Law Enforcer !");
				RemovePlayerFromVehicle(playerid);
			}
		}*/
		if(IsADonatorHouseVehicle(newcar))
		{
   		if(PlayerInfo[playerid][pPhousekey]!=IsADonatorHouseVehicle(newcar))
   		{
   		  SendClientMessage(playerid,COLOR_RED,"* This is a donator house vehicle, you cannot drive it if you do not rent or own the house");
   		  RemovePlayerFromVehicle(playerid);
   		}
		}
		if(IsAnAztecaCar(newcar))
		{
		  if(PlayerInfo[playerid][pMember] != 3 && PlayerInfo[playerid][pLeader] != 3)
		  {
		    SendClientMessage(playerid,COLOR_GREY,"  You are not in this gang !");
		    RemovePlayerFromVehicle(playerid);
		  }
		}
		if(IsAnlsrsCar(newcar))
		{
		  if(PlayerInfo[playerid][pMember] != 20 && PlayerInfo[playerid][pLeader] != 20)
		  {
		    SendClientMessage(playerid,COLOR_GREY,"  You are not in this gang !");
		    RemovePlayerFromVehicle(playerid);
		  }
		}
		if(IsAnpavlovichCar(newcar))
		{
		  if(PlayerInfo[playerid][pMember] != 21 && PlayerInfo[playerid][pLeader] != 21)
		  {
		    SendClientMessage(playerid,COLOR_GREY," You cant drive this freind !");
		    RemovePlayerFromVehicle(playerid);
		  }
		}
		if(newcar == 62 || newcar == 63)
		{
		  if(PlayerInfo[playerid][pJob] != 14)
		  {
		    SendClientMessage(playerid,COLOR_GREY,"  You are not a Bus Driver !");
		    RemovePlayerFromVehicle(playerid);
		  }
		}
		if(IsAnIrishCar(newcar))
		{
			if(PlayerInfo[playerid][pMember] == 15 || PlayerInfo[playerid][pLeader] == 15) { }
			else{ SendClientMessage(playerid, COLOR_GREY, "You Cannot use this Vehicle"); RemovePlayerFromVehicle(playerid); }
		}
		if(newcar == 68 || newcar == 67 || newcar == 66)
		{
		  if(TakingLesson[playerid] == 1) { }
		  else if(!IsAnInstructor(playerid))
		  {
		    SendClientMessage(playerid,COLOR_GREY,"  You are not a School Instructor !");
		    RemovePlayerFromVehicle(playerid);
		  }
		}
		if(IsALuccheseCar(newcar))
		{ //Lucchese
		  if(PlayerInfo[playerid][pMember] == 6 || PlayerInfo[playerid][pLeader] == 6) { }
			else
			{
				SendClientMessage(playerid,0xFF000000, "You cannot steal family oriented vehicles!");
			  RemovePlayerFromVehicle(playerid);
		  }
		}
		if(IsALosSantosRaceSyndicateCar(newcar))
		{
		  if(PlayerInfo[playerid][pMember] == 18 || PlayerInfo[playerid][pLeader] == 18) { }
		  else
		  {
		    SendClientMessage(playerid,COLOR_GREY,"* You are not in this gang");
		    RemovePlayerFromVehicle(playerid);
		  }
		}
		if(IsAGuardCar(newcar))
		{
		if(PlayerInfo[playerid][pMember] == 17 || PlayerInfo[playerid][pLeader] == 17)
		{
		  if(newcar == 224 || newcar == 225)
		  {
			if(PlayerInfo[playerid][pRank] < 3)
			{
			SendClientMessage(playerid, 0xFF000000, "You need to be rank 3 to drive the tank!");
			RemovePlayerFromVehicle(playerid);
		  }
		  }
		  else if(newcar == 226)
		  {
      if(PlayerInfo[playerid][pRank] < 4)
			{
			SendClientMessage(playerid, 0xFF000000, "You need to be rank 4 to fly the hunter!");
			RemovePlayerFromVehicle(playerid);
		  }
		  }
		}
		else
		{
		    SendClientMessage(playerid,COLOR_GREY,"  You are not a member of the Nation Guard !");
		    RemovePlayerFromVehicle(playerid);
		}
		}
		if(IsALCNCar(newcar))
		{ //LCN
		  if(PlayerInfo[playerid][pMember] == 5 || PlayerInfo[playerid][pLeader] == 5) { }
			else
			{
				SendClientMessage(playerid,0xFF000000, "You cannot steal family oriented vehicles!");
			  RemovePlayerFromVehicle(playerid);
		  }
		}
		/*if(IsADiscipleCar(newcar)) //Gangsta
		{
		  if(PlayerInfo[playerid][pMember] == 13 || PlayerInfo[playerid][pLeader] == 13) { }
			else
			{
				SendClientMessage(playerid,0xFF000000, "You cannot steal family oriented vehicles!");
			  RemovePlayerFromVehicle(playerid);
		  }
		}*/
		if(IsAGroveCar(newcar)) //Grove
		{
		  if(PlayerInfo[playerid][pMember] == 16 || PlayerInfo[playerid][pLeader] == 16) { }
			else
			{
				SendClientMessage(playerid,0xFF000000, "You cannot steal faction vehicles!");
			  RemovePlayerFromVehicle(playerid);
		  }
		}
		if(IsATaxiCar(newcar))
		{
		  if(PlayerInfo[playerid][pMember] == 10||PlayerInfo[playerid][pLeader] == 10)
			{
			if(PlayerInfo[playerid][pRank] >= 5) { }
			else{ SendClientMessage(playerid, COLOR_GREY, "You need to be Rank 5 to drive this!"); RemovePlayerFromVehicle(playerid); }
			}
		  else
			{
		    SendClientMessage(playerid,COLOR_GREY,"  You are not a Taxi Driver !");
		    RemovePlayerFromVehicle(playerid);
		  }
		}

		if(IsAHitmanCar(newcar))
 		{
   		if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
   		 { }
   		else
   		{
     		SendClientMessage(playerid, COLOR_GREY, "  You are not a Hitman!");
     		RemovePlayerFromVehicle(playerid);
			}
		}

		if(IsAConstructionCar(newcar))
		{
			if(PlayerInfo[playerid][pMember] == 7 || PlayerInfo[playerid][pLeader] == 7) { }
			else
			{
			SendClientMessage(playerid, COLOR_GREY, "  You aren't the Mayor or one of the Mayor's employee's");
			RemovePlayerFromVehicle(playerid);
			}
		}

		if(IsAGambinoCar(newcar))
		{
			if(PlayerInfo[playerid][pMember] == 19 || PlayerInfo[playerid][pLeader] == 19) { }
			else
			{
			SendClientMessage(playerid, COLOR_GREY, "  You aren't a Gambino");
			RemovePlayerFromVehicle(playerid);
			}
		}

		if(newcar==108||newcar==106||newcar==107||newcar==109||newcar==110||newcar==111)
		{
		  if(PlayerKarting[playerid] != 1)
		  {
		    RemovePlayerFromVehicle(playerid);
		  }
		}
		if(newcar == 69 || newcar == 70 || newcar == 71)
		{
			if (HireCar[playerid] != newcar)
			{
				format(string, sizeof(string), "~w~You can Rent this car~n~Cost:~g~$%d~n~~w~To rent type ~g~/rentcar~w~~n~to get out type ~r~/exit",SBizzInfo[0][sbEntranceCost]);
				TogglePlayerControllable(playerid, 0);
				GameTextForPlayer(playerid, string, 5000, 3);
			}
		}
		if(newcar == 72 || newcar == 73 || newcar == 74)
		{
			if (HireCar[playerid] != newcar)
			{
				format(string, sizeof(string), "~w~You can Rent this car~n~Cost:~g~$%d~n~~w~To rent type ~g~/rentcar~w~~n~to get out type ~r~/exit",SBizzInfo[1][sbEntranceCost]);
				TogglePlayerControllable(playerid, 0);
				GameTextForPlayer(playerid, string, 5000, 3);
			}
		}
		if(oldcar != 301)
		{
			if((housecar != oldcar && oldcar != 0) && (HireCar[playerid] != oldcar && newcar != housecar))
			{
				if(gLastDriver[oldcar] == playerid && oldcar != newcar)
				{
					gLastDriver[oldcar] = 300;
					gCarLock[oldcar] = 0;
					UnLockCar(oldcar);
				}
			}
		}
		if(IsALatinCar(newcar)) //Genovese
		{
		  if(PlayerInfo[playerid][pMember] == 12 || PlayerInfo[playerid][pLeader] == 12) { }
			else
			{
				SendClientMessage(playerid,0xFF000000, "  You cannot steal faction vehicles!");
			  RemovePlayerFromVehicle(playerid);
		  }
		}
		if(IsAMOBCar(newcar)) //MOB
		{
		  if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9) { }
			else
			{
				SendClientMessage(playerid,0xFF000000, "  You are not a Balla!");
			  RemovePlayerFromVehicle(playerid);
		  }
		}
		if(IsABallaCar(newcar)) //Ballas
		{
		  if(PlayerInfo[playerid][pMember] == 14 || PlayerInfo[playerid][pLeader] == 14) { }
			else
			{
				SendClientMessage(playerid,0xFF000000, "  You are not a Balla!");
			  RemovePlayerFromVehicle(playerid);
		  }
		}
		if(IsABuggedCar(newcar))
		{
		  SendClientMessage(playerid,COLOR_RED,"* This is a bugged vehicle!");
			RemovePlayerFromVehicle(playerid);
		}
	}
	if(newstate == PLAYER_STATE_SPAWNED)
	{
		new Float: lwx, Float:lwy, Float:lwz;
		GetPlayerPos(playerid, lwx, lwy, lwz);
		if((lwz > 530.0 && PlayerInfo[playerid][pInt] == 0) || PlayerToPoint(1000.0, playerid, -1041.9,-1868.4,79.1)) //the highest land point in sa = 526.8
		{
			SetPlayerSpawn(playerid);
		}
		if(WantedPoints[playerid] > 0)
		{
		  new dstring[128];
			new wanted = WantedPoints[playerid];
			new diecash = 0;
		  while(WantedPoints[playerid] > 0)
		  {
		    diecash += 500;
		    WantedPoints[playerid] --;
		  }
		  format(dstring, sizeof(dstring), "You lost $%d for dieing with %d Wanted Points.", diecash, wanted);
		  SendClientMessage(playerid, COLOR_YELLOW, dstring);
		  GivePlayerMoney(playerid, - diecash);
		  PlayerInfo[playerid][pWantedDeaths] += 1;
		}
		if(PlayerOnMission[playerid] > 0)
		{
			GameTextForPlayer(playerid, "~r~Mission failed", 5000, 3);
			PlayerOnMission[playerid] = 0;
		  PlayerInfo[playerid][pMissionNr] = 0;
		}
		WantedPoints[playerid] = 0;
		WantedLevel[playerid] = 0;
		if(PlayerInfo[playerid][pDonateRank] > 0) { SetPlayerHealth(playerid, 100.0); }
		else { SetPlayerHealth(playerid, 50.0+PlayerInfo[playerid][pSHealth]); }
		MedicBill[playerid] = 1;
		TelePos[playerid][0] = 0.0;
		TelePos[playerid][1] = 0.0;
		gPlayerSpawned[playerid] = 1;
		SafeTime[playerid] = 60;
	}
	return 1;
}



Re: ID 1 and up freezes when enter car. - Joe Staff - 25.08.2009

Is this a recent symptom? Did you recently put in a filterscript? Because by looking at that script, there's no reason why a player should freeze unless the vehicle was rented.


Re: ID 1 and up freezes when enter car. - Devine - 25.08.2009

I put in LuxSpeedo but I honestly don't know if that did it because I was usually on 127.0.0.1 and I just portforwarded so I just had ID 1 and up..