SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 09/04/2015, 12:28 PM   #1
izeatfishz
Huge Clucker
 
izeatfishz's Avatar
 
Join Date: Jun 2012
Posts: 231
Reputation: 43
Default Breaking into cars..

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..
izeatfishz is offline   Reply With Quote
Old 09/04/2015, 12:35 PM   #2
Andregood
Huge Clucker
 
Andregood's Avatar
 
Join Date: Oct 2009
Location: Sweden
Posts: 285
Reputation: 26
Default Re: Breaking into cars..

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
Andregood is offline   Reply With Quote
Old 09/04/2015, 12:37 PM   #3
izeatfishz
Huge Clucker
 
izeatfishz's Avatar
 
Join Date: Jun 2012
Posts: 231
Reputation: 43
Default Re: Breaking into cars..

Quote:
Originally Posted by Andregood View Post
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

Code:
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?
izeatfishz is offline   Reply With Quote
Old 09/04/2015, 12:39 PM   #4
Andregood
Huge Clucker
 
Andregood's Avatar
 
Join Date: Oct 2009
Location: Sweden
Posts: 285
Reputation: 26
Default Re: Breaking into cars..

No, it will set the closest vehicles only if ur using the if statements which you are
Andregood is offline   Reply With Quote
Old 09/04/2015, 12:42 PM   #5
izeatfishz
Huge Clucker
 
izeatfishz's Avatar
 
Join Date: Jun 2012
Posts: 231
Reputation: 43
Default Re: Breaking into cars..

Quote:
Originally Posted by Andregood View Post
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
izeatfishz is offline   Reply With Quote
Old 09/04/2015, 12:46 PM   #6
Andregood
Huge Clucker
 
Andregood's Avatar
 
Join Date: Oct 2009
Location: Sweden
Posts: 285
Reputation: 26
Default Re: Breaking into cars..

Quote:
Originally Posted by izeatfishz View Post
Aww baby it worked!

I had it all right I was just too scared to test it! THANKS
No problem man, anytime
Andregood is offline   Reply With Quote
Old 09/04/2015, 12:49 PM   #7
izeatfishz
Huge Clucker
 
izeatfishz's Avatar
 
Join Date: Jun 2012
Posts: 231
Reputation: 43
Default Re: Breaking into cars..

Quote:
Originally Posted by Andregood View Post
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..

Code:
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
izeatfishz is offline   Reply With Quote
Old 09/04/2015, 12:54 PM   #8
Andregood
Huge Clucker
 
Andregood's Avatar
 
Join Date: Oct 2009
Location: Sweden
Posts: 285
Reputation: 26
Default Re: Breaking into cars..

if(doors == 0 or alternatively 1)

That's what you're asking right?
Andregood is offline   Reply With Quote
Old 09/04/2015, 12:59 PM   #9
izeatfishz
Huge Clucker
 
izeatfishz's Avatar
 
Join Date: Jun 2012
Posts: 231
Reputation: 43
Default Re: Breaking into cars..

Quote:
Originally Posted by Andregood View Post
if(doors == 0 or alternatively 1)

That's what you're asking right?
Wow, so simple yet it works, massive props dude..
izeatfishz is offline   Reply With Quote
Old 09/04/2015, 01:00 PM   #10
Andregood
Huge Clucker
 
Andregood's Avatar
 
Join Date: Oct 2009
Location: Sweden
Posts: 285
Reputation: 26
Default Re: Breaking into cars..

Quote:
Originally Posted by izeatfishz View Post
Wow, so simple yet it works, massive props dude..
No problem, loops make shit easy
Andregood is offline   Reply With Quote
Reply

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
Checkpoints breaking Markus1337 Server Support 1 17/02/2014 09:19 AM
Breaking rcon BossArturKA Server Support 2 08/01/2014 04:58 PM
Is this breaking the rules? clarencecuzz Everything and Nothing 3 19/09/2012 12:46 PM


All times are GMT. The time now is 07:25 AM.


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