All pastes #806001 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-12-04 21:29 UTC
rendered paste body
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;
			}
			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]);
				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
 		new newcar = GetPlayerVehicleID(playerid);
		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 need a licenses to drive that Boat !");
			    RemovePlayerFromVehicle(playerid);
			}
		}
		else if(IsAPlane(newcar))
		{
		    if(PlayerInfo[playerid][pFlyLic] < 1)
			{
			    if(TakingLesson[playerid] == 1) { }
			    else {
			    SendClientMessage(playerid, COLOR_GREY, "   You need a licenses to drive that Plane/Heli !");
			    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_GREY, "   You need a licenses to drive that Vehicle !");
                RemovePlayerFromVehicle(playerid); }
			}
			else if(PlayerDrunk[playerid] >= 5)
			{
			    WantedPoints[playerid] += 1;
				SetPlayerCriminal(playerid,255, "Drunk Driving");
			}
		}//Done with car check
		if(IsACopCar(newcar))
		{
		    if(IsACop(playerid)) { }
		    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 == 39 || newcar == 40)
		{
		    if(PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3)//national guard
		    {
		        if(PlayerInfo[playerid][pRank] < 3)
		        {
			        SendClientMessage(playerid,COLOR_GREY,"   You need Rank 3 to Fly this baby !");
			        RemovePlayerFromVehicle(playerid);
		        }
		    }
		    else
		    {
		        RemovePlayerFromVehicle(playerid);
		    }
		}
		if(newcar == 55 || newcar == 59)
		{
		    if(PlayerInfo[playerid][pMember] != 4)
		    {
		        SendClientMessage(playerid,COLOR_GREY,"   You are not a Fireman !");
		        RemovePlayerFromVehicle(playerid);
		    }
		}
		if(newcar == 64 || newcar == 65)
		{
		    if(PlayerInfo[playerid][pJob] != 14)
		    {
		        SendClientMessage(playerid,COLOR_GREY,"   You are not a Bus Driver !");
		        RemovePlayerFromVehicle(playerid);
		    }
		}
		if(newcar == 69 || newcar == 70 || newcar == 71 || newcar == 99 || newcar == 100 || newcar == 101 || newcar == 144 || newcar == 145 || newcar == 146 || newcar == 147 || newcar == 148 || newcar == 149 || newcar == 150)
		{
		    if(TakingLesson[playerid] == 1) { }
		    else if(!IsAnInstructor(playerid))
		    {
		        SendClientMessage(playerid,COLOR_GREY,"   You are not a School Instructor !");
		        RemovePlayerFromVehicle(playerid);
		    }
		}
		if(newcar == 82 || newcar == 84 || newcar == 85 || newcar == 94)
		{
		    if(PlayerInfo[playerid][pMember] == 10||PlayerInfo[playerid][pLeader] == 10) { }
		    else
			{
		        SendClientMessage(playerid,COLOR_GREY,"   You are not a Taxi Driver !");
		        RemovePlayerFromVehicle(playerid);
		    }
		}

		if(newcar == 95)
		{
		    if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
		    {
		        if(PlayerInfo[playerid][pRank] < 3)
			    {
			        SendClientMessage(playerid, COLOR_GREY, "   Your Rank is to Low !");
				    RemovePlayerFromVehicle(playerid);
			    }
		    }
		    else
		    {
		        SendClientMessage(playerid, COLOR_GREY, "   You are not a Hitman !");
			    RemovePlayerFromVehicle(playerid);
		    }
		}
		if(newcar == 96 || newcar == 97 || newcar == 98)
		{
			if(PlayerInfo[playerid][pMember] == 9 || PlayerInfo[playerid][pLeader] == 9){ }
			else
			{
			    SendClientMessage(playerid, COLOR_GREY, "   You are not a News Reporter !");
			    RemovePlayerFromVehicle(playerid);
			}
			if(PlayerInfo[playerid][pNewsSkill] < 200 && newcar == 96)
			{
			    SendClientMessage(playerid, COLOR_GREY, "   Your News Reporter Skill is to low, cant fly the Chopper yet !");
			    RemovePlayerFromVehicle(playerid);
			}
		}
		if(newcar == 173 )//Change CARID to the correct ID.
		{
	 		if(PlayerInfo[playerid][pMember] != 5 || PlayerInfo[playerid][pMember] != 5)
  			{
        		SendClientMessage(playerid,COLOR_GREY,"   You are not a LaCostraNostra member !");
 			 	RemovePlayerFromVehicle(playerid);
		  	}
		}
		if(newcar==110||newcar==111||newcar==112||newcar==113||newcar==114||newcar==115)
		{
		    if(PlayerKarting[playerid] != 1)
		    {
		        RemovePlayerFromVehicle(playerid);
		    }
		}
		if(newcar >= 72 && 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[0][sbEntranceCost]);
				TogglePlayerControllable(playerid, 0);
				GameTextForPlayer(playerid, string, 5000, 3);
			}
		}
		if(newcar >= 75 && newcar <= 77)
		{
			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);
				}
			}
		}
		gLastCar[playerid] = newcar;
		gLastDriver[newcar] = 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;
}