Breaking into cars..
#1

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..
Reply
#2

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
Reply
#3

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?
Reply
#4

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

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
Reply
#6

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
Reply
#7

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
Reply
#8

if(doors == 0 or alternatively 1)

That's what you're asking right?
Reply
#9

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..
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)