[FilterScript] Vehicle Turbo System !
#1

! VEHICLE TURBO SYSTEM !
So i had this question, why we can't upgrade vehicle engines in samp ? So i made a little script that allows you to install Turbo system(Its nothing to do with realistic Turbo charged vehicle, just a name) in you car, so here it is

You have to have some kind of accounting system like i have : PlayerInfo[playerid][!Something!]
Add to you accounting system variables like !!!! TurboType, vTruboType (Second car), vTurbo, vVTrubo (Second car) !!!!
You probalby have to change few things to get this script to work.
Please be nice and leave a rep or comment about it, im new at pawno so you can show me the mistakes i made, and maybe if you have an idea how to make this better, please share it with me

Code:
new TurboTime;
new TurboOn[MAX_PLAYERS];
new bool:ThrottleActivated[MAX_PLAYERS];
Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys == KEY_NO)
	{
		new vehicleid = GetPlayerVehicleID(playerid), string[256];
	    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return 1;
	    if(vehicleid != PlayerInfo[playerid][pVeh] && vehicleid != PlayerInfo[playerid][pVVeh]) return 1;
		if(!TurboOn[playerid])
		{
			if(vehicleid == PlayerInfo[playerid][pVeh])
			{
				if(!PlayerInfo[playerid][TurboType]) return SendClientMessage(playerid, COLOR_GREY, "You dont have a Turbo installed in this vehicle.");
				if(!PlayerInfo[playerid][vTurbo]) return SendClientMessage(playerid, COLOR_GREY, "You'r turbo system is broken !");
				if(PlayerInfo[playerid][TurboType] == 1){
				TurboTime = SetTimerEx("TurboTimer", 800, true, "i", playerid);}
				else if(PlayerInfo[playerid][TurboType] == 2){
				TurboTime = SetTimerEx("TurboTimer", 650, true, "i", playerid);}
				else if(PlayerInfo[playerid][TurboType] == 3){
				TurboTime = SetTimerEx("TurboTimer", 500, true, "i", playerid);}
				format(string, sizeof(string), "* %s pushes the button to engage the turbo system.", RPN(playerid));
				SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
				TurboOn[playerid] = 1;
			}
			if(vehicleid == PlayerInfo[playerid][pVVeh])
			{
				if(!PlayerInfo[playerid][vTurboType]) return SendClientMessage(playerid, COLOR_GREY, "You dont have a Turbo installed in this vehicle.");
				if(!PlayerInfo[playerid][vVTurbo]) return SendClientMessage(playerid, COLOR_GREY, "You'r turbo system is broken !");
				if(PlayerInfo[playerid][vTurboType] == 1){
				TurboTime = SetTimerEx("TurboTimer", 800, true, "i", playerid);}
				else if(PlayerInfo[playerid][vTurboType] == 2){
				TurboTime = SetTimerEx("TurboTimer", 650, true, "i", playerid);}
				else if(PlayerInfo[playerid][vTurboType] == 3){
				TurboTime = SetTimerEx("TurboTimer", 500, true, "i", playerid);}
				format(string, sizeof(string), "* %s pushes the button to engage the turbo system.", RPN(playerid));
				SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
				TurboOn[playerid] = 1;
			}
		}
		else if(TurboOn[playerid])
		{
			KillTimer(TurboTime);
			TurboOn[playerid] = 0;
			format(string, sizeof(string), "* %s pushes the button to disengage the turbo system.", RPN(playerid));
			SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
		}
	    return 1;
	}
}
Code:
forward TurboTimer(playerid);
public TurboTimer(playerid)
{
	new vehicleid = GetPlayerVehicleID(playerid);
	if(IsPlayerInAnyVehicle(playerid) && vehicleid == PlayerInfo[playerid][pVeh])
	{
	    if(ThrottleActivated[playerid] == true)
	    {
			if(PlayerInfo[playerid][vTurbo] > 0)
			{
				new Float: mx, Float: my, Float: mz, Float: ma;
				GetVehicleZAngle(vehicleid,ma);
				GetVehicleVelocity(vehicleid,mx ,my,mz);
				mx+=(0.1*floatsin(-ma,degrees));my+=(0.05*floatcos(-ma,degrees));
				SetVehicleVelocity(vehicleid,mx ,my,mz);
				PlayerInfo[playerid][vTurbo] --;
			}else{
				TurboOn[playerid] = 0;
		    	KillTimer(TurboTime);
		    	SendClientMessage(playerid, COLOR_RED, "Your cars Turbo system has broken.");
			}
		}
	}
	else if(IsPlayerInAnyVehicle(playerid) && vehicleid == PlayerInfo[playerid][pVVeh])
	{
	    if(ThrottleActivated[playerid] == true)
	    {
			if(PlayerInfo[playerid][vVTurbo] > 0)
			{
				new Float: mx, Float: my, Float: mz, Float: ma;
				GetVehicleZAngle(vehicleid,ma);
				GetVehicleVelocity(vehicleid,mx ,my,mz);
				mx+=(0.1*floatsin(-ma,degrees));my+=(0.05*floatcos(-ma,degrees));
				SetVehicleVelocity(vehicleid,mx ,my,mz);
				PlayerInfo[playerid][vVTurbo] --;
			}else{
				TurboOn[playerid] = 0;
		    	KillTimer(TurboTime);
		    	SendClientMessage(playerid, COLOR_RED, "Your cars Turbo system has broken.");
			}
		}
	}else{
		TurboOn[playerid] = 0;
 		KillTimer(TurboTime);
	}
}
Now here is the turbo shop script, you can probably get it working without this too !

Code:
CMD:turboshop(playerid, params[])
{
    if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
    if(!IsPlayerInRangeOfPoint(playerid, 4, 1636.4352,-1526.3444,13.5073)) return SendClientMessage(playerid, COLOR_GREY, "You are not at the turbo shop.");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle.");
    if(GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pVeh] && GetPlayerVehicleID(playerid) != PlayerInfo[playerid][pVVeh]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your personal vehicle.");
	if(Bikes(GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, COLOR_GREY, "Sorry, we cant install turbo on bikes.");
    ShowDialog(playerid, 58);
    return 1;
}
Code:
stock ShowDialog(playerid, dialogid)
{
    new string[256], line1[256];
	switch(dialogid)
	{
		case 58: // Turbo shop menu
		{
		    ShowPlayerDialog(playerid, 58, DIALOG_STYLE_LIST, "Vehicle turbo shop:", "Stock 5psi turbo - 5000$\nAvarge 10psi turbo - 10000$\nPremium 15psi turbo - 15000$\nRepair - Stock 1000$, Avarage 2000$, Platinum 3000$\nRemove turbo - 1000$", "Buy", "Cancel");
		}
        }
}
Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	else if(dialogid == 58)
	{
	    if(response)
	    {
		    switch(listitem)
		    {
	        	case 0: // 5psi turbo
		        {
          			if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
  					{
       					if(!PlayerInfo[playerid][TurboType])
       					{
  					     	if(5000 > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money on you.");
		        			PlayerInfo[playerid][vTurbo] = 100;
		        			PlayerInfo[playerid][TurboType] = 1;
		        			TurboOn[playerid] = 0;
		        			GiveDodMoney(playerid, -5000);
		        			SendClientMessage(playerid, COLOR_LIGHTBLUE, "Cheap 5psi turbo installed (type /turbo to turn turbo in you car on/off)");
	        			}else{SendClientMessage(playerid, COLOR_GREY, "You have to remove old Turbo to install a new one.");}
					}
      				if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
  					{
  						if(!PlayerInfo[playerid][vTurboType])
  						{
			     			if(5000 > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money on you.");
						    PlayerInfo[playerid][vVTurbo] = 100;
						    PlayerInfo[playerid][vTurboType] = 1;
						    TurboOn[playerid] = 0;
						    GiveDodMoney(playerid, -5000);
						    SendClientMessage(playerid, COLOR_LIGHTBLUE, "Cheap 5psi turbo installed (type /turbo to turn turbo in you car on/off)");
					    }else{SendClientMessage(playerid, COLOR_GREY, "You have to remove old Turbo to install a new one.");}
					}
		        }
		        case 1: // 10psi turbo
		        {
          			if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
  					{
       					if(!PlayerInfo[playerid][TurboType])
       					{
       					    if(10000 > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money on you.");
		        			PlayerInfo[playerid][vTurbo] = 100;
		        			PlayerInfo[playerid][TurboType] = 2;
		        			TurboOn[playerid] = 0;
		        			GiveDodMoney(playerid, -10000);
		        			SendClientMessage(playerid, COLOR_LIGHTBLUE, "Avarge 10psi turbo installed (type /turbo to turn turbo in you car on/off)");
	        			}else{SendClientMessage(playerid, COLOR_GREY, "You have to remove old Turbo to install a new one.");}
					}
      				if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
  					{
  						if(!PlayerInfo[playerid][vTurboType])
  						{
  							if(10000 > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money on you.");
					    	PlayerInfo[playerid][vVTurbo] = 100;
	 				    	PlayerInfo[playerid][vTurboType] = 2;
				   		 	TurboOn[playerid] = 0;
				   	 	 	GiveDodMoney(playerid, -10000);
			   			 	SendClientMessage(playerid, COLOR_LIGHTBLUE, "Avarge 10psi turbo installed (type /turbo to turn turbo in you car on/off)");
		   			 	}else{SendClientMessage(playerid, COLOR_GREY, "You have to remove old Turbo to install a new one.");}
					}
		        }
		        case 2: // 15psi turbo
		        {
          			if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
  					{
       					if(!PlayerInfo[playerid][TurboType])
       					{
       						if(15000 > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money on you.");
		        			PlayerInfo[playerid][vTurbo] = 100;
		        			PlayerInfo[playerid][TurboType] = 3;
		        			TurboOn[playerid] = 0;
		        			GiveDodMoney(playerid, -15000);
		        			SendClientMessage(playerid, COLOR_LIGHTBLUE, "Premium 15psi turbo installed (type /turbo to turn turbo in you car on/off)");
	        			}else{SendClientMessage(playerid, COLOR_GREY, "You have to remove old Turbo to install a new one.");}
					}
      				if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
  					{
  						if(!PlayerInfo[playerid][vTurboType])
  						{
  							if(15000 > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money on you.");
					    	PlayerInfo[playerid][vVTurbo] = 100;
	 				    	PlayerInfo[playerid][vTurboType] = 3;
		 				    TurboOn[playerid] = 0;
		 				    GiveDodMoney(playerid, -15000);
		 				    SendClientMessage(playerid, COLOR_LIGHTBLUE, "Premium 15psi turbo installed (type /turbo to turn turbo in you car on/off)");
	 				    }else{SendClientMessage(playerid, COLOR_GREY, "You have to remove old Turbo to install a new one.");}
	 				    
					}
		        }
		        case 3: // Repair turbo
		        {
          			if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
  					{
       					if(PlayerInfo[playerid][TurboType])
       					{
       					    new money;
		        			money = PlayerInfo[playerid][TurboType] * 1000;
		        			if(5000 > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money on you.");
		        			PlayerInfo[playerid][vTurbo] = 100;
		        			TurboOn[playerid] = 0;
		        			GiveDodMoney(playerid, -money);
		        			SendClientMessage(playerid, COLOR_LIGHTBLUE, "You'r turbo is now fixed and ready to be used.");
	        			}else{SendClientMessage(playerid, COLOR_GREY, "You dont have any Turbo installed in your vehicle.");}
					}
      				if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
  					{
  						if(PlayerInfo[playerid][vTurboType])
  						{
  						    new money;
  						    money = PlayerInfo[playerid][vTurboType] * 1000;
		        			if(money > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money on you.");
						    PlayerInfo[playerid][vVTurbo] = 100;
						    TurboOn[playerid] = 0;
						    GiveDodMoney(playerid, -money);
						    SendClientMessage(playerid, COLOR_LIGHTBLUE, "You'r turbo is now fixed and ready to be used.");
					    }else{SendClientMessage(playerid, COLOR_GREY, "You dont have any Turbo installed in your vehicle.");}
					}
		        }
		        case 4: // Remove turbo
		        {
          			if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVeh])
  					{
       					if(PlayerInfo[playerid][TurboType])
       					{
       					    if(1000 > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money on you.");
		        			PlayerInfo[playerid][vTurbo] = 0;
		        			PlayerInfo[playerid][TurboType] = 0;
		        			TurboOn[playerid] = 0;
		        			GiveDodMoney(playerid, -1000);
		        			SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have removed Turbo system from your vehicle.");
	        			}else{SendClientMessage(playerid, COLOR_GREY, "You dont have any Turbo installed in your vehicle.");}
					}
      				if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pVVeh])
  					{
  						if(PlayerInfo[playerid][vTurboType])
  						{
  							if(1000 > PlayerInfo[playerid][pMoney]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money on you.");
						    PlayerInfo[playerid][vVTurbo] = 0;
						    PlayerInfo[playerid][vTurboType] = 0;
						    TurboOn[playerid] = 0;
						    GiveDodMoney(playerid, -1000);
						    SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have removed Turbo system from your vehicle.");
					    }else{SendClientMessage(playerid, COLOR_GREY, "You dont have any Turbo installed in your vehicle.");}
					}
		        }
			}
		}
	}
}
Sorry for my bad english skills Please rate
Reply


Messages In This Thread
Vehicle Turbo System ! - by scout322 - 14.02.2015, 00:03
Re: Vehicle Turbo System ! - by SetPlayerNameTag - 14.02.2015, 17:32

Forum Jump:


Users browsing this thread: 1 Guest(s)