SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 03/11/2010, 05:22 AM   #1
Deal-or-die
Huge Clucker
 
Deal-or-die's Avatar
 
Join Date: Oct 2010
Location: An Island 1000's of miles away
Posts: 366
Reputation: 22
Question Rentable cars are drivable without renting

when a person enter a car that can be rent, he can just do /engine or SHIFT to be unfroze instead of doing /rentcar.
im not quite sure what part of my script id place here. Please ask if i place the wrong bit.

Code:
	if(strcmp(cmd, "/rentcar", true) == 0)
	{
        if(IsPlayerConnected(playerid))
		{
			if(GetPlayerVehicleID(playerid) >= 135 && GetPlayerVehicleID(playerid) <= 154)
			{
				new hirefee = HireCost(GetPlayerVehicleID(playerid));
				if(SBizzInfo[1][sbProducts] == 0)
				{
					GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
					return 1;
				}
				if (GetPlayerMoney(playerid) <  SBizzInfo[1][sbEntranceCost])
				{
					SendClientMessage(playerid, COLOR_GRAD2, "   You dont have that much cash !");
					return 1;
				}
				if(HireCar[playerid] != 299)
				{
					gCarLock[HireCar[playerid]] = 0;
					UnLockCar(HireCar[playerid]);
					SendClientMessage(playerid, COLOR_GREY, "You need unrent your current car/bike/boat first !");
					return 1;
				}
				for(new i=0; i<MAX_PLAYERS; i++)
				{
				    if(HireCar[i] == GetPlayerVehicleID(playerid))
				    {
				        SendClientMessage(playerid, COLOR_GREY, "    Someone already rents this car !");
				        return 1;
				    }
				}
				/*if(PlayerInfo[playerid][pPbiskey] == 1)
				{
					GameTextForPlayer(playerid, "~w~No charge for the boss", 5000, 3);
					TogglePlayerControllable(playerid, 1);
					return 1;
				}*/
				SafeGivePlayerMoney(playerid,-SBizzInfo[1][sbEntranceCost]);
				SBizzInfo[1][sbTill] += SBizzInfo[1][sbEntranceCost];
				ExtortionSBiz(1, SBizzInfo[1][sbEntranceCost]);
				SBizzInfo[1][sbProducts]--;
				HireCar[playerid] = GetPlayerVehicleID(playerid);
				OnPropUpdate(3);
				PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				format(string, sizeof(string), "~w~Don't forget to ~r~/unrentcar~n~~g~/lock ~w~to lock your car.",hirefee);
				SendClientMessage(playerid, COLOR_YELLOW2, "You can start the engine up now !");
				gEngine[playerid] = 0;
				engineOn[GetPlayerVehicleID(playerid)] = false;
				//TogglePlayerControllable(playerid, 1);
				GameTextForPlayer(playerid, string, 5000, 3);

				new y, m, d;
				new h,mi,s;
				getdate(y,m,d);
				gettime(h,mi,s);
				format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /rentcar",d,m,y,h,mi,s,sendername);
				CommandLog(string);
			}
		}
		return 1;
	}
__________________
/////////////////////////// | Mini Moot | \\\\\\\\\\\\\\\\\\\\\\\\\\\

"I'm in the country that basically invented the Internet, and your getting faster speeds on an island 1,000miles away"

Last edited by Deal-or-die; 03/11/2010 at 06:04 AM.
Deal-or-die is offline  
Old 03/11/2010, 07:54 AM   #2
Grim_
High-roller
 
Grim_'s Avatar
 
Join Date: Sep 2008
Location: United States
Posts: 2,896
Reputation: 118
Default Re: Rentable cars are drivable without rent

You do not give information on what you want to be done with your code. Do you want to prevent the ability to drive rentable cars by typing the "/engine" command? If so, show the "/engine" command and the variables that store whether or not the vehicle is rentable.
Grim_ is offline  
Old 03/11/2010, 08:52 AM   #3
Deal-or-die
Huge Clucker
 
Deal-or-die's Avatar
 
Join Date: Oct 2010
Location: An Island 1000's of miles away
Posts: 366
Reputation: 22
Smile Re: Rentable cars are drivable without rent

Quote:
Originally Posted by Grim_ View Post
You do not give information on what you want to be done with your code. Do you want to prevent the ability to drive rentable cars by typing the "/engine" command? If so, show the "/engine" command and the variables that store whether or not the vehicle is rentable.
Thanks for the reply, here is the /engines code
Code:
	if(!strcmp(cmd, "/engine", true))
	{
	    if(IsPlayerConnected(playerid))
	    {
			if(IsPlayerInAnyVehicle(playerid))
			{
	    		if(!engineOn[GetPlayerVehicleID(playerid)])
	    		{
	        		if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
					{
						return 1;
					}
					if(IsAnOwnableCar(idcar))
					{
						if(PlayerInfo[playerid][pPcarkey] == idcar) { }
						else if(PlayerInfo[playerid][pPcarkey2] == idcar) { }
						else { return 1; }
					}
					if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509)
					{
						return 1;
					}
					if(idcar == 59 || idcar == 60)
					{
						return 1;
					}
					if(idcar >= 135 && idcar <= 154)
					{
					    if(HireCar[playerid] != idcar)
					    {
							return 1;
						}
					}
					if(IsAHarvest(idcar))
					{
					    return 1;
					}
					if(IsADrugHarvest(idcar))
					{
					    return 1;
					}
					if(IsASweeper(idcar))
					{
					    return 1;
					}
					if(gEngine[playerid] == 1) { return 1; }

					new playerveh = GetPlayerVehicleID(playerid);
					PutPlayerInVehicle(playerid, playerveh, 0);
					format(string, sizeof(string), "* %s spins a key and tries to start vehicle engine.", sendername);
					ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
					SetTimerEx("StartingTheVehicle",3500,0,"i",playerid);
					GameTextForPlayer(playerid, "~w~Starting vehicle engine...",3500,3);
					gEngine[playerid] = 1;
					new y, m, d;
					new h,mi,s;
					getdate(y,m,d);
					gettime(h,mi,s);
					format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /engine",d,m,y,h,mi,s,sendername);
					CommandLog(string);
					return 1;
				}
				if(engineOn[GetPlayerVehicleID(playerid)])
	    		{
	        		if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
					{
						return 1;
					}
					if(IsAnOwnableCar(idcar))
					{
					    if(PlayerInfo[playerid][pPcarkey] == idcar) { }
					    else if(PlayerInfo[playerid][pPcarkey2] == idcar) { }
						else { return 1; }
					}
					if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509)
					{
						return 1;
					}
					if(idcar == 59 || idcar == 60)
					{
						return 1;
					}
					if(idcar >= 135 && idcar <= 154)
					{
					    if(HireCar[playerid] != idcar)
					    {
							return 1;
						}
					}
					if(IsAHarvest(idcar))
					{
					    return 1;
					}
					if(IsADrugHarvest(idcar))
					{
					    return 1;
					}
					if(IsASweeper(idcar))
					{
					    return 1;
					}
					engineOn[GetPlayerVehicleID(playerid)] = false;
					//SafeRemovePlayerFromVehicle(playerid);
					TogglePlayerControllable(playerid, 0);
					format(string, sizeof(string), "* %s spins the vehicle key and turns off the engine.", sendername);
					ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
					gEngine[playerid] = 0;
					new y, m, d;
					new h,mi,s;
					getdate(y,m,d);
					gettime(h,mi,s);
					format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /engine",d,m,y,h,mi,s,sendername);
					CommandLog(string);
					return 1;
				}
			}
	    }
	    return 1;
	}
__________________
/////////////////////////// | Mini Moot | \\\\\\\\\\\\\\\\\\\\\\\\\\\

"I'm in the country that basically invented the Internet, and your getting faster speeds on an island 1,000miles away"
Deal-or-die is offline  
Old 03/11/2010, 09:12 AM   #4
Grim_
High-roller
 
Grim_'s Avatar
 
Join Date: Sep 2008
Location: United States
Posts: 2,896
Reputation: 118
Default Re: Rentable cars are drivable without rent

Just add a check into the command to check whether or not the car is rentable, if it is, don't unfreeze it. (You would need to do the same for when you check for the SHIFT key is pressed)
Grim_ is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"out of stock" - rent cars? kyoss Help Archive 1 04/02/2010 05:13 AM
[Need script] Rent Cars manunited1878 Help Archive 1 10/01/2010 06:47 PM
Help Me " Out Of Stock " Rent Cars In LA:RP Help me Please RastamaN[BzD] Help Archive 7 20/11/2009 03:33 PM
Hot to add rentable planes and boats without moving the car IDs Cutler-Beckett Help Archive 3 20/08/2009 01:05 PM
[Help] Cop Cars are for rent! MarqueZ92 Help Archive 11 18/07/2009 10:41 AM


All times are GMT. The time now is 07:50 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.