Conditional script problem - 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: Conditional script problem (
/showthread.php?tid=248630)
Conditional script problem -
Swiftz - 15.04.2011
I have this script
Код:
if(strcmp(cmd, "/pvlock", true) == 0)
{
if(gPlayercars[playerid] == 1)
{
new v, Float:vehx, Float:vehy, Float:vehz;
v = Vehicle[playerid];
GetVehiclePos(v, vehx, vehy, vehz);
if(IsPlayerInRangeOfPoint(playerid, 3.0, vehx, vehy, vehz))
{
if(VehicleInfo[playerid][Locked] == 0)
{
SetVehicleParamsForPlayer(v, playerid, 0, 1);
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid, "~r~Car locked!", 3000, 6);
VehicleInfo[playerid][Locked] = 1;
gVehLocked[v] = 1;
return 1;
}
if(VehicleInfo[playerid][Locked] == 1)
{
SetVehicleParamsForPlayer(v, playerid, 0, 0);
PlayerPlaySound(playerid, 1145, 0.0, 0.0, 0.0);
GameTextForPlayer(playerid, "~g~Car unlocked!", 3000, 6);
VehicleInfo[playerid][Locked] = 0;
gVehLocked[v] = 0;
return 1;
}
}
else
{
SendClientMessage(playerid, 0xAFAFAFAA, "You are too far away from your vehicle.");
return 1;
}
}
else
{
SendClientMessage(playerid, 0xAFAFAFAA, "You don't own a vehicle.");
}
return 1;
}
This is a script for locking a vehicle which you own and only works if ur near it. And Vehicle[playerid]; is the variable of the car you own. Now what i want is , If i have another car, say Vehicle2[playerid];, Then it has different location (x,y,z) from that of Vehicle[playerid]; , Now what i need is, If we are near Vehicle[playerid]; it should lock the first car and if we are near Vehicle2[playerid];, It should lock the second one, It shouldnt lock both of them. And if we near none of them, It returns. Can u tell how to make it. Thanks
Re: Conditional script problem -
Vince - 15.04.2011
pawn Код:
stock Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
{
x1 -= x2;
y1 -= y2;
z1 -= z2;
return floatsqroot((x1 * x1) + (y1 * y1) + (z1 * z1));
}
Then just find the car that is the least far away from the player.
Re: Conditional script problem -
Swiftz - 15.04.2011
Im new to this GetDistanceBetweenPoints function, can you rewrite the script with that function please, Thanks for replying fast
Re: Conditional script problem -
Swiftz - 16.04.2011
Bump! please help