Help: /breaklock command (Car Jacker) - 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: Help: /breaklock command (Car Jacker) (
/showthread.php?tid=413368)
Help: /breaklock command (Car Jacker) -
jakejohnsonusa - 05.02.2013
I have a few problems with the following code, None of the ClientMessage's show for some reason, and the second problem is that ALL vehicles unlock (not just the nearest vehicle)... Whats wrong with my code, and how can I fix it or rewrite it?
Thanks: jakejohnsonusa
/breaklock Command Code:
pawn Код:
if (strcmp(cmd, "/breaklock", true) == 0)
{
new vehicle[24];
new nearest = GetNearestVehicle(playerid, 20.0);
GetVehicleName(nearest, vehicle, sizeof(vehicle));
if(IsPlayerConnected(playerid) & PlayerInfo[playerid][pJob] == 5)// Job 5 is Car Jacker Job
{
new Float:X,Float:Y,Float:Z;
GetVehiclePos(nearest, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, 20.0, X, Y, Z))
{
//SendClientMessage(playerid, COLOR_GREY, "** You broke the cars lock. Now lets see if you can start it...");
CarInfo[nearest][cLock] = 0;
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(nearest, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(nearest, engine, lights, alarm, false, bonnet, boot, objective);
SendClientMessage(playerid, COLOR_GREY, "** You broke the cars lock. Now lets see if you can start it...");
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "** No vehicles in range to break into!");
}
}
return 1;
}
Re: Help: /breaklock command (Car Jacker) -
ThePhenix - 05.02.2013
Check the radius :
Re: Help: /breaklock command (Car Jacker) -
Threshold - 05.02.2013
Can you show your getnearestvehicle function?
Re: Help: /breaklock command (Car Jacker) -
jakejohnsonusa - 05.02.2013
Sure,
Here it is:
pawn Код:
stock GetNearestVehicle(playerid, Float:dis)
{
new Float:L, Float:O, Float:II;
if(GetPlayerPos(playerid, L, O, II))
{
new vehicleid = INVALID_VEHICLE_ID;
for(new v, Float:temp, Float:VL, Float:VO, Float:VII; v != MAX_VEHICLES; v++)
{
if(GetVehiclePos(v, VL, VO, VII) && v != GetPlayerVehicleID(playerid))
{
VL -= L, VO -= O, VII -= II;
temp = VL * VL + VO * VO + VII * VII;
if(temp < dis) dis = temp, vehicleid = v;
}
}
dis = floatpower(dis, 1.5);
return vehicleid;
}
return INVALID_VEHICLE_ID;
}
Thanks in advance!
Re: Help: /breaklock command (Car Jacker) -
jakejohnsonusa - 06.02.2013
Bump... Anyone know?