SA-MP Forums Archive
Breaking into cars.. - 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)
+--- Thread: Breaking into cars.. (/showthread.php?tid=570344)



Breaking into cars.. - izeatfishz - 09.04.2015

I want to be able to allow players 5to break into cars, by using VehicleParams, but how could I do this, I've tried getting the closest vehicle but can't get it's vehicle id to set its params..

I want players to be able to /carbreakin and then the vehicleparams of the closest vehicle become unlocked..


Re: Breaking into cars.. - Andregood - 09.04.2015

Get the ID with a loop (loop through MAX_VEHICLES, I think I saw you had that)

new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParams or w/e the function is.

I finds the closest vehicle so yes you do have the ID


Re: Breaking into cars.. - izeatfishz - 09.04.2015

Quote:
Originally Posted by Andregood
Посмотреть сообщение
Get the ID with a loop (loop through MAX_VEHICLES, I think I saw you had that)

new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParams or w/e the function is.

I finds the closest vehicle so yes you do have the ID
I had

Код:
native IsValidVehicle(vehicleid);

CMD:carbreakin(playerid, params[])
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
	new
		Float: vX,
		Float: vY,
		Float: vZ
	;

   	for(new i = 0; i != MAX_VEHICLES; i++)
	{
		if (!IsValidVehicle(i))
			continue;

		GetVehiclePos(i, vX, vY, vZ);
  		if(IsPlayerInRangeOfPoint(playerid, 5.0, vX, vY, vZ))
    	{
        	SendClientMessage(playerid, COLOR_LIGHTRED, "You're near a car and the breakin bit needs adding");
        	break;
    	}
    	else
    	{

    	}
	}
	return 1;
}
But setting if I used 'i' to set vehicle params would it not set all the vehicle params?


Re: Breaking into cars.. - Andregood - 09.04.2015

No, it will set the closest vehicles only if ur using the if statements which you are


Re: Breaking into cars.. - izeatfishz - 09.04.2015

Quote:
Originally Posted by Andregood
Посмотреть сообщение
No, it will set the closest vehicles only if ur using the if statements which you are
Aww baby it worked!

I had it all right I was just too scared to test it! THANKS


Re: Breaking into cars.. - Andregood - 09.04.2015

Quote:
Originally Posted by izeatfishz
Посмотреть сообщение
Aww baby it worked!

I had it all right I was just too scared to test it! THANKS
No problem man, anytime


Re: Breaking into cars.. - izeatfishz - 09.04.2015

Quote:
Originally Posted by Andregood
Посмотреть сообщение
No problem man, anytime
Another question, if I want to check if the door is unlocked with vehicle params, how would I use that in a if statement..

Код:
GetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, boot, objective);
I want to check if doors are 1 and if so return my breakin, otherwise say there's no locked vehicles around


Re: Breaking into cars.. - Andregood - 09.04.2015

if(doors == 0 or alternatively 1)

That's what you're asking right?


Re: Breaking into cars.. - izeatfishz - 09.04.2015

Quote:
Originally Posted by Andregood
Посмотреть сообщение
if(doors == 0 or alternatively 1)

That's what you're asking right?
Wow, so simple yet it works, massive props dude..


Re: Breaking into cars.. - Andregood - 09.04.2015

Quote:
Originally Posted by izeatfishz
Посмотреть сообщение
Wow, so simple yet it works, massive props dude..
No problem, loops make shit easy