SA-MP Forums Archive
Rentable cars are drivable without rent - 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: Rentable cars are drivable without rent (/showthread.php?tid=187507)



Rentable cars are drivable without renting - Deal-or-die - 03.11.2010

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;
	}



Re: Rentable cars are drivable without rent - Grim_ - 03.11.2010

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.


Re: Rentable cars are drivable without rent - Deal-or-die - 03.11.2010

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;
	}



Re: Rentable cars are drivable without rent - Grim_ - 03.11.2010

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)