i want a script where when players get in a police car they start police mission and search wanted players and arrest them
i would like, appreicate that 8)
Link. (https://goo.gl/5PGZbM)
You know about that mission right ? And I think you are doing scripting well,why not try it making yourself ;)
idk if i know scripting well lol like 3/5
i only know things well about inis
well, ill try making the mission, if i fail, ill post code here maybe.
Quote from: Xenon on Aug 06, 2016, 10:55 PMLink. (https://goo.gl/5PGZbM)
i asked for REQUEST, not for some shitty polish senseless mindless pathologic youtube videos
so i did the cop mission, only idk how to arrest with distance :c, have /arrest cmd, and i want it to make from distance
someone help
code:
if(cmd=="arrest")
{
if (player.Skin == 1) {
local target = FindPlayer(text.tointeger())
if ( !text ) {
MessagePlayer("/arrest id",player)
}
if ( !target ) {
MessagePlayer("Target does not exist",player)
return false;
}
if ( target ) {
Arrest(player,target)
}
}
else {
MessagePlayer("You must be police to arrest players",player)
return false;
}
}
function Arrest :
function Arrest(player,target)
{
if (target.WantedLevel <1) {
MessagePlayer("This player is not wanted",player)
return false;
}
if (target.WantedLevel > 0) {
MessagePlayer("[#ffffff]Arrested "+target+" , you get $2500",player)
player.Cash += 2500;
target.WantedLevel = 0
Message("[#ffffff]Police "+player+ " has arrested "+target)
}
}
function GetDistance(pos1, pos2)
{
local dist = 0;
(pos1.x < pos2.x) ? dist += pos2.x - pos1.x : dist += pos1.x - pos2.x;
(pos1.y < pos2.y) ? dist += pos2.y - pos1.y : dist += pos1.y - pos2.y;
(pos1.z < pos2.z) ? dist += pos2.z - pos1.z : dist += pos1.z - pos2.z;
return dist / 3;
}
note that i'm not a mathematician so this might not be the best distance formula. theres another one with Pythagoras theorem but I don't feel like scripting that right now.
You don't need to script one since it's already in the squirrel plugin. Vector.Distance(Vector) or DistanceFromPoint( x1, y1, x2, y2 )
Ee x1 y1? that doesnt account for z. imagine a troll is in a heli
Quote from: EK.CrystalBlue on Aug 07, 2016, 10:41 AMEe x1 y1? that doesnt account for z. imagine a troll is in a heli
Quote from: Thijn on Aug 07, 2016, 10:13 AMVector.Distance(Vector)
^
@EK.CrystalBlue, Afaik Vector involves three of the coordinates right? :D
ok ill try playing with that
I was talking about the DistanceFromPoint, though.
the funciton get distance
function Arrest(player,target)
{
if (!target) {
MessagePlayer("[#ff0000]Target does not exist",player)
return false;
}
if (target.WantedLevel <1) {
MessagePlayer("[#ff0000]This player is not wanted",player)
return false;
}
if (target.WantedLevel > 0) {
local distance = GetDistance(player.Pos,target.Pos)
if ( distance < 5 ) {
MessagePlayer("[#ffffff]Arrested "+target+" , you get $2500",player)
player.Cash += 2500;
target.Pos = Vector(386.59, -502.732, 9.39561)
target.WantedLevel = 0
target.Skin = 7
SaveAccount(target)
Message("[#ffffff]Police "+player+ " has arrested "+target)
}
}
}
doesnt work. i can still arrest players from 2nd island remotely ;/
Quote from: Thijn on Aug 07, 2016, 10:13 AMYou don't need to script one since it's already in the squirrel plugin. Vector.Distance(Vector) or DistanceFromPoint( x1, y1, x2, y2 )
You probably want to do player.Pos.Distance(target.Pos) instead.
Quote from: EK.CrystalBlue on Aug 07, 2016, 10:07 AMfunction GetDistance(pos1, pos2)
{
local dist = 0;
(pos1.x < pos2.x) ? dist += pos2.x - pos1.x : dist += pos1.x - pos2.x;
(pos1.y < pos2.y) ? dist += pos2.y - pos1.y : dist += pos1.y - pos2.y;
(pos1.z < pos2.z) ? dist += pos2.z - pos1.z : dist += pos1.z - pos2.z;
return dist / 3;
}
This is absolutely mathematically incorrect.
hm, k. ill try
works, thx to all !! <3
Quote from: Stormeus on Aug 10, 2016, 05:52 PMQuote from: Thijn on Aug 07, 2016, 10:13 AMYou don't need to script one since it's already in the squirrel plugin. Vector.Distance(Vector) or DistanceFromPoint( x1, y1, x2, y2 )
You probably want to do player.Pos.Distance(target.Pos) instead.
Quote from: EK.CrystalBlue on Aug 07, 2016, 10:07 AMfunction GetDistance(pos1, pos2)
{
local dist = 0;
(pos1.x < pos2.x) ? dist += pos2.x - pos1.x : dist += pos1.x - pos2.x;
(pos1.y < pos2.y) ? dist += pos2.y - pos1.y : dist += pos1.y - pos2.y;
(pos1.z < pos2.z) ? dist += pos2.z - pos1.z : dist += pos1.z - pos2.z;
return dist / 3;
}
This is absolutely mathematically incorrect.
Elaborate.
Quote from: EK.CrystalBlue on Aug 10, 2016, 11:08 PMElaborate.
Because:
function GetDistance(pos1, pos2)
{
return sqrt(pow(pos1.x - pos2.x, 2) + pow(pos1.y - pos2.y, 2) + pow(pos1.z - pos2.z, 2));
}
@EK.CrystalBlue Your example suggests that the points (6, 6, 6) and (3, 3, 3) are 1 unit apart from each other. This is clearly erroneous. The Pythagorean method is the only way to accurately find the distance between two points.
Okay, well, ./SLC released a Pythagoras Theorem function, so he can use that instead
Quote from: EK.CrystalBlue on Aug 11, 2016, 09:45 PMOkay, well, ./SLC released a Pythagoras Theorem function, so he can use that instead
Like we said before, it's build into the plugin so there's absolutely no reason why you would use the pure-squirrel option.
Quote from: vito on Aug 17, 2016, 03:10 PMQuote from: Thijn on Aug 12, 2016, 06:01 AMQuote from: EK.CrystalBlue on Aug 11, 2016, 09:45 PMOkay, well, ./SLC released a Pythagoras Theorem function, so he can use that instead
Like we said before, it's build into the plugin so there's absolutely no reason why you would use the pure-squirrel option.
Client-side scripting is that reason...
You shouldn't handle checking critical things on the client side :P
If you're not allowed to do something while being too far away, the server needs to verify that, not the client.
Oh Can You Send Me Full Script Of That THANKS