[Request] Police Mission

Started by Kewun, Aug 06, 2016, 07:49 PM

Previous topic - Next topic

Kewun

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)


jayant

You know about that mission right ? And I think you are doing scripting well,why not try it making yourself ;)

Kewun

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.

Kewun

Quote from: Xenon on Aug 06, 2016, 10:55 PMLink.

i asked for REQUEST, not for some shitty polish senseless mindless pathologic youtube videos

Kewun

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)
}
}

EK.IceFlake

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.

Thijn

You don't need to script one since it's already in the squirrel plugin. Vector.Distance(Vector) or DistanceFromPoint( x1, y1, x2, y2 )

EK.IceFlake

Ee x1 y1? that doesnt account for z. imagine a troll is in a heli

DizzasTeR

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

Kewun

ok ill try playing with that

EK.IceFlake

I was talking about the DistanceFromPoint, though.

Kewun

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 ;/

Stormeus

#13
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.

Kewun