Vice City: Multiplayer

Server Development => Scripting and Server Management => Script and Content Requests => Topic started by: Kewun on Aug 06, 2016, 07:49 PM

Title: [Request] Police Mission
Post by: Kewun on Aug 06, 2016, 07:49 PM
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)
Title: Re: [Request] Police Mission
Post by: Xenon on Aug 06, 2016, 10:55 PM
Link. (https://goo.gl/5PGZbM)
Title: Re: [Request] Police Mission
Post by: jayant on Aug 07, 2016, 04:08 AM
You know about that mission right ? And I think you are doing scripting well,why not try it making yourself ;)
Title: Re: [Request] Police Mission
Post by: Kewun on Aug 07, 2016, 06:24 AM
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.
Title: Re: [Request] Police Mission
Post by: Kewun on Aug 07, 2016, 06:29 AM
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
Title: Re: [Request] Police Mission
Post by: Kewun on Aug 07, 2016, 10:00 AM
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)
}
}
Title: Re: [Request] Police Mission
Post by: EK.IceFlake on Aug 07, 2016, 10:07 AM
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.
Title: Re: [Request] Police Mission
Post by: Thijn on Aug 07, 2016, 10:13 AM
You don't need to script one since it's already in the squirrel plugin. Vector.Distance(Vector) or DistanceFromPoint( x1, y1, x2, y2 )
Title: Re: [Request] Police Mission
Post by: EK.IceFlake on Aug 07, 2016, 10:41 AM
Ee x1 y1? that doesnt account for z. imagine a troll is in a heli
Title: Re: [Request] Police Mission
Post by: DizzasTeR on Aug 07, 2016, 12:11 PM
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
Title: Re: [Request] Police Mission
Post by: Kewun on Aug 07, 2016, 04:36 PM
ok ill try playing with that
Title: Re: [Request] Police Mission
Post by: EK.IceFlake on Aug 07, 2016, 07:39 PM
I was talking about the DistanceFromPoint, though.
Title: Re: [Request] Police Mission
Post by: Kewun on Aug 10, 2016, 05:44 PM
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 ;/
Title: Re: [Request] Police Mission
Post by: Stormeus on Aug 10, 2016, 05:52 PM
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.
Title: Re: [Request] Police Mission
Post by: Kewun on Aug 10, 2016, 05:54 PM
hm, k. ill try
Title: Re: [Request] Police Mission
Post by: Kewun on Aug 10, 2016, 05:56 PM
works, thx to all !! <3
Title: Re: [Request] Police Mission
Post by: EK.IceFlake on Aug 10, 2016, 11:08 PM
Quote from: Stormeus on Aug 10, 2016, 05:52 PM
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.
Elaborate.
Title: Re: [Request] Police Mission
Post by: . on Aug 10, 2016, 11:16 PM
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));
}
Title: Re: [Request] Police Mission
Post by: Stormeus on Aug 11, 2016, 01:55 PM
@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.
Title: Re: [Request] Police Mission
Post by: EK.IceFlake on Aug 11, 2016, 09:45 PM
Okay, well, ./SLC released a Pythagoras Theorem function, so he can use that instead
Title: Re: [Request] Police Mission
Post by: Thijn on Aug 12, 2016, 06:01 AM
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.
Title: Re: [Request] Police Mission
Post by: Thijn on Aug 17, 2016, 04:07 PM
Quote from: vito on Aug 17, 2016, 03:10 PM
Quote from: Thijn on Aug 12, 2016, 06:01 AM
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.
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.
Title: Re: [Request] Police Mission
Post by: W3aPoN^ on Sep 05, 2016, 04:42 PM
Oh Can You Send Me Full Script Of That THANKS