You have the right to remain silent

Started by KrOoB_, Oct 01, 2020, 11:56 PM

Previous topic - Next topic

KrOoB_

Better cuff system

Credits: KrOoB_

SERVER
[noae]
class Playerstatus
{
 InJail = "false";
 JailFor = null;
 Skor = 0;
 crim = false;
 breaks = false;
}

function onScriptLoad()
{
status <- array(GetMaxPlayers(), null);
}

function onPlayerJoin( player )
{
status[player.ID] = Playerstatus();
}

function tutukla( player, plr )
{
    local player = FindPlayer(player);
    local plr = FindPlayer(plr);
    if (plr.Score > 0)
{
if( status[plr.ID].breaks == true)
{
plr.IsFrozen = false;
status[plr.ID].breaks = false;
Message("[#ac9000][VCPD] [#FFFFFF]WTF he just escaped");
Stream.StartWrite();
Stream.WriteInt(40);
Stream.SendStream(plr);
}else{
                    if(plr.Vehicle)
                        {
                            plr.Eject();
                            plr.Pos = player.Pos;
                            plr.IsFrozen = true;
                            plr.SetAnim(0,162);
                            MessagePlayer("[#ac9000][VCPD] [#FFffff]Can't escape from VCPD",plr);
                            MessagePlayer("[#ac9000][VCPD] [#FFffff]That was funny, do not try again!!",player);
                        }
                        else {
plr.Health = 100;
plr.Pos = Vector(390.863, -508.094, 9);
local Value = plr.Score; // if i write here 1 then player(criminal) stays 1 min in jail
if (Value > 6) Value = 6;
local reward = Value * 5, RealJailTime = Value * 60;
MessagePlayer("[#ac9000][VCPD] [#ffffff]Police Officer " + player.Name + " just arrest you!", plr);
                        MessagePlayer("[#ac9000][VCPD][#ffffff]Got Medical attention", plr);
Message("[#ac9000][VCPD] [#FFFFFF]Police Officer " + player.Name + " just arrest a criminal named " + plr.Name + " . Duration:" + Value + " Min");
IncCash(player, reward); // u can find this function in forum
plr.Skin = 7;
plr.Disarm();
status[ plr.ID ].JailFor = RealJailTime;
Stream.StartWrite( );
Stream.WriteInt( 33 );
Stream.SendStream( plr );
                        if(plr.IsFrozen == true) plr.IsFrozen = false;
Stream.StartWrite();
Stream.WriteInt(40);
Stream.SendStream(player);                       
}
        }
}
}

function onTimeChange(oldHour, oldMin, newHour, newMin)
{
for (local i = 0; i < GetMaxPlayers(); ++i)
{
local player = FindPlayer(i);

if (player)
{
if (player.IsSpawned)
{
if ( status[player.ID].JailFor != null )
{
if (status[player.ID].InJail == "true" && status[player.ID].JailFor > 0)
{
local Time = status[player.ID].JailFor,
mins = (Time % 3600) / 60,
secs = Time % 60;
Stream.StartWrite();
Stream.WriteInt(35);
Stream.WriteString(mins + ":" + secs);
Stream.SendStream(player);
status[player.ID].JailFor--;
local polyarest;
polyarest = InPoly( player.Pos.x, player.Pos.y, 411.836, -482.679, 286.270, -467.721, 350.046, -482.532, 391.226, -522.587);
if( !polyarest && status[player.ID].InJail == "true" ) player.Pos = Vector(390.863, -508.094, 9);
}
else if (status[player.ID].JailFor < 1)
{
Stream.StartWrite();
Stream.WriteInt(34);
Stream.SendStream(player);
                        player.Score = 0;
                       
}
}
}
        }
    }
}
 function onPlayerCommand( player, cmd, text )
{
if (cmd == "tutukla" || cmd == "t")
{
if (!text) MessagePlayer("Error - /" + cmd + " [Name/id]", player);
else
{
local plr = text != "" ? IsNum(text) ? FindPlayer(text.tointeger()) : FindPlayer(text) : player;
if (!plr) MessagePlayer("[#ac9000][VCPD] Unkown Player", player);
else if (status[plr.ID].InJail == "true") MessagePlayer("[#ac9000][VCPD] He's already in jail bruh", player)
else if (plr.Name == player.Name) MessagePlayer("[#ac9000][VCPD] Trying to cuff himself kekW", player)
else if (DistanceFromPoint(player.Pos.x, player.Pos.y, plr.Pos.x, plr.Pos.y) < 2)
{
      status[plr.ID].crim = true;
                      Stream.StartWrite();
Stream.WriteInt(38);
Stream.SendStream(plr);
                        plr.IsFrozen = true;
                        hapiss <- NewTimer("tutukla",5000,1,player.ID,plr.ID);

}
else MessagePlayer("[#ac9000][VCPD] [#FFFFFF]Away",player)
}
}
}
function onClientScriptData( player )
{
local int = Stream.ReadInt( ),
string = Stream.ReadString ( );
  switch( int.tointeger() )
{
case 3:
if( status[player.ID].breaks == false)
{
status[player.ID].breaks = true;
}
break;
}
}

[/noae]

CLIENT
[noae]ask<-KeyBind(0x4B);

Cuff<-
{
    Window = null
    tBar = null
    stat = 0
}


function Server::ServerData(stream)
{
 local StreamReadInt = stream.ReadInt(),
 StreamReadString = stream.ReadString();
 switch (StreamReadInt.tointeger())
 {
case 38: Criminal( ); break;
case 40: DeCrim(); break;
 }
}

function KeyBind::OnDown( key )
{
if( key == ask)
{
if ( Cuff.Window)
{
if ( Cuff.stat > 0)
{
if ( Cuff.tBar.Value == 6 || Cuff.tBar.Value == 7 || Cuff.tBar.Value == 8 || Cuff.tBar.Value == 9 || Cuff.tBar.Value == 10 )
{
local Data = Stream();
Data.WriteInt(3);
Server.SendData(Data);
}else
  {
Cuff.Window = null;
Cuff.tBar = null;
Cuff.stat = 0;
Console.Print("[#FFFFFF]Unsuccessful");
  }
}
}
}
}

// bad code sorry  :(
function Script::ScriptProcess( )
{
if (Cuff.Window)
{
if( Cuff.stat == 1 )
{
Cuff.tBar.Value += 1;
}
else if ( Cuff.tBar.Value == 15 )
{
Cuff.stat = 2;
}
else if( Cuff.stat == 2 )
{
Cuff.tBar.Value -= 1;
}
else if( Cuff.stat == 2 && Cuff.tBar.Value == 0 )
{
Cuff.stat = 1;
}
durduran <- Timer.Create( this, DeCrim, 2000, 1);
}
}

function Criminal( )
 {
    Cuff.Window = GUIWindow(VectorScreen(sX * 0.35, sY * 0.75), VectorScreen(sX * 0.4, sY * 0.123), Colour(20, 20, 20, 200), "DECUFF", GUI_FLAG_TEXT_TAGS);
    Cuff.Window.AddFlags(GUI_FLAG_VISIBLE);
    Cuff.Window.RemoveFlags(GUI_FLAG_DRAGGABLE | GUI_FLAG_WINDOW_CLOSEBTN | GUI_FLAG_WINDOW_RESIZABLE);

    Cuff.tBar = GUIProgressBar();
    Cuff.tBar.Pos = VectorScreen(sX * 0.005, sY * 0.0015);
    Cuff.tBar.Size = VectorScreen( sX * 0.39, sY * 0.064 );
    Cuff.tBar.StartColour = Colour( 40, 255, 40 );
    Cuff.tBar.EndColour = Colour( 180, 110, 110 );
    Cuff.tBar.MaxValue = 15;
    Cuff.tBar.Value = 0;
    Cuff.tBar.BackgroundShade = 0.3;
    Cuff.tBar.Thickness = 2;
    Cuff.stat = 1;
    Cuff.Window.AddChild(Cuff.tBar);
 }

 function DeCrim()
{
Cuff.Window = null;
Cuff.tBar = null;
Cuff.stat = 0;
}
[/noae]