It's a rob script with a little game :D I just think that while robing a bank or somewhere else it's kind a boring because we're doing nothing so i add a little something like a game good luck <3 ;D
Some Video
https://www.youtube.com/watch?v=oayn2wuKvZ8&feature=youtu.be
If you see bugs or error please notice ( tried 3 times )
Thanks to ysc3839 for Timers <3
Server Side
[noae][noae]
function onScriptLoad()
{
Rob <- array( GetMaxPlayers(), true);
teleport <- array(GetMaxPlayers(),0);
BankRob <- CreateCheckpoint(null, 0, true, Vector(-942.61, -343.512, 7.22693), RGB(255, 0, 200), 2.0);
CreateCheckpoint(null, 0, true, Vector(-939.282, -351.561, 7.22692), RGB(0, 0, 200), 1.0);
CreateCheckpoint(null, 0, true, Vector( -938.388, -351.363, 17.8038), RGB(0, 0, 200), 2.0);
VK_LEFT <- BindKey(true, 0x25, 0, 0);
VK_RIGHT <- BindKey(true, 0x27, 0, 0);
VK_UP <- BindKey(true, 0x26, 0, 0);
VK_DOWN <- BindKey(true, 0x28, 0, 0);
ENTER <- BindKey(true, 0x0D, 0, 0);
I_KEY <- BindKey(true, 0x49, 0, 0);
}
function onClientScriptData( player )
{
local int = Stream.ReadInt( ),
string = Stream.ReadString ( );
switch( int )
{
case 1:
player.Cash += 10000;
Message("[#eeeeee]"+ player.Name +" has been robbed a bank, Last seen at "+ GetDistrictName( player.Pos.x, player.Pos.y ) +". All cops requested to arrest him!");
player.IsFrozen = false;
break;
case 2:
player.Cash += 1;
player.IsFrozen = false;
Message("[#eeeeee]"+ player.Name +" tried to rob a bank, Last seen at "+ GetDistrictName( player.Pos.x, player.Pos.y ) +". All cops requested to arrest him!");
}
}
function onCheckpointEntered( player, checkpoint )
{
teleport[player.ID] = checkpoint.ID;
teleport[player.ID] += 1;
print(teleport[player.ID]);
}
function onCheckpointExited( player, checkpoint )
{
teleport[player.ID] = 99;
}
function onKeyUp( player, key )
{
if (key == ENTER)
{
switch(teleport[player.ID])
{
case 1:
if ( Rob[player.ID] == true )
{
Stream.StartWrite( );
Stream.WriteInt( 10 );
Stream.SendStream( player );
Rob[player.ID] = false;
player.IsFrozen = true;
local check = FindCheckpoint(0);
check.Remove();
}else
{
Message("You can't rob rn");
}
break;
case 2:
player.Pos = Vector(-939.282, -351.561, 17.22692);
break;
case 3:
player.Pos = Vector(-938.388, -351.363, 7.8038);
break;
}
}
if ( key == VK_LEFT)
{
Stream.StartWrite()
Stream.WriteInt(2)
Stream.WriteString("left")
Stream.SendStream(player)
}
if ( key == VK_RIGHT)
{
Stream.StartWrite()
Stream.WriteInt(2)
Stream.WriteString("right")
Stream.SendStream(player)
}
if ( key == VK_UP)
{
Stream.StartWrite()
Stream.WriteInt(2)
Stream.WriteString("upper")
Stream.SendStream(player)
}
if ( key == VK_DOWN)
{
Stream.StartWrite()
Stream.WriteInt(2)
Stream.WriteString("down")
Stream.SendStream(player)
}
}
[/noae][/noae]
Client Side
[noae][noae]
Timer <- {
Timers = {}
function Create(environment, listener, interval, repeat, ...)
{
// Prepare the arguments pack
vargv.insert(0, environment);
// Store timer information into a table
local TimerInfo = {
Environment = environment,
Listener = listener,
Interval = interval,
Repeat = repeat,
Args = vargv,
LastCall = Script.GetTicks(),
CallCount = 0
};
local hash = split(TimerInfo.tostring(), ":")[1].slice(3, -1).tointeger(16);
// Store the timer information
Timers.rawset(hash, TimerInfo);
// Return the hash that identifies this timer
return hash;
}
function Destroy(hash)
{
// See if the specified timer exists
if (Timers.rawin(hash))
{
// Remove the timer information
Timers.rawdelete(hash);
}
}
function Exists(hash)
{
// See if the specified timer exists
return Timers.rawin(hash);
}
function Fetch(hash)
{
// Return the timer information
return Timers.rawget(hash);
}
function Clear()
{
// Clear existing timers
Timers.clear();
}
function Process()
{
local CurrTime = Script.GetTicks();
foreach (hash, tm in Timers)
{
if (tm != null)
{
if (CurrTime - tm.LastCall >= tm.Interval)
{
tm.CallCount++;
tm.LastCall = CurrTime;
tm.Listener.pacall(tm.Args);
if (tm.Repeat != 0 && tm.CallCount >= tm.Repeat)
Timers.rawdelete(hash);
}
}
}
}
};
sX <- GUI.GetScreenSize().X;
sY <- GUI.GetScreenSize().Y;
Robbery<-
{
Window = null
tBar = null
times = 0
}
ScreenS <-
{
sprite = null
}
keys <-
{
stat = false
}
alt <- false;
upper <- false;
right <- false;
left <- false;
tus <- null;
keyf <- null;
gmode <- ["right", "left", "down", "upper"]
//-------------------------------------------------------------------
function rander()
{
::keyf = gmode[rand()% gmode.len()];
if( keys.stat == false )
{
::tus = null;
Timer.Create( this, verifa, 1000, 1 );
Sprites <- Timer.Create( this, KeySprites, 0.1, 1 );
}
}
function KeySprites()
{
if ( ::keyf == "down" )
{
ScreenS.sprite <- GUISprite("assagi.png", VectorScreen(sX * 0.30, sY * 0.30));
ScreenS.sprite.Size = VectorScreen(250, 250);
}
if ( ::keyf == "upper" )
{
ScreenS.sprite <- GUISprite("yukari.png", VectorScreen(sX * 0.30, sY * 0.30));
ScreenS.sprite.Size = VectorScreen(250, 250);
}
if ( ::keyf == "left" )
{
ScreenS.sprite <- GUISprite("sol.png", VectorScreen(sX * 0.30, sY * 0.30));
ScreenS.sprite.Size = VectorScreen(250, 250);
}
if ( ::keyf == "right" )
{
ScreenS.sprite <- GUISprite("sag.png", VectorScreen(sX * 0.30, sY * 0.30));
ScreenS.sprite.Size = VectorScreen(250, 250);
}
}
function verifa()
{
if( keyf == ::tus)
{
keys.stat = false;
ScreenS.sprite = null;
}else
{
Robbery.times += 1;
Robbery.tBar.Value -= 5 * Robbery.times;
keys.stat = false;
ScreenS.sprite = null;
}
}
function Script::ScriptProcess()
{
Timer.Process();
}
function Server::ServerData( stream )
{
local StreamReadInt = stream.ReadInt(),
StreamReadString = stream.ReadString();
switch (StreamReadInt.tointeger())
{
case 2: local data = StreamReadString; if ( StreamReadString ){ ::tus = StreamReadString; } break;
case 10: Criminal( ); break;
default: break;
}
}
function Criminal( )
{
Robbery.Window = GUIWindow(VectorScreen(sX * 0.35, sY * 0.75), VectorScreen(sX * 0.4, sY * 0.123), Colour(20, 20, 20, 200), "HAK YEDIN HACK YICEKSIN YAKINDA", GUI_FLAG_TEXT_TAGS);
Robbery.Window.AddFlags(GUI_FLAG_VISIBLE);
Robbery.Window.RemoveFlags(GUI_FLAG_DRAGGABLE | GUI_FLAG_WINDOW_CLOSEBTN | GUI_FLAG_WINDOW_RESIZABLE);
Robbery.tBar = GUIProgressBar();
Robbery.tBar.Pos = VectorScreen(sX * 0.005, sY * 0.0015);
Robbery.tBar.Size = VectorScreen( sX * 0.39, sY * 0.064 );
Robbery.tBar.StartColour = Colour( 40, 255, 40 );
Robbery.tBar.EndColour = Colour( 180, 110, 110 );
Robbery.tBar.MaxValue = 100;
Robbery.tBar.Value = 0;
Robbery.tBar.BackgroundShade = 0.3;
Robbery.tBar.Thickness = 2;
Robbery.Window.AddChild(Robbery.tBar);
Ilerleme <- Timer.Create( this, progressing, 2000, 21 );
Sallama <- Timer.Create( this, rander, 5000, 8 );
Check <- Timer.Create( this, Checking, 43000, 1 );
}
function progressing()
{
Robbery.tBar.Value += 5;
Conlefte.Print(Robbery.tBar.Value);
}
function Checking()
{
if ( Robbery.tBar.Value >= 100 )
{
ScreenS.sprite = null;
Timer.Destroy( Ilerleme );
Timer.Destroy( Sallama );
Robbery.Window = null;
local Datas = Stream();
Datas.WriteInt(1);
Server.SendData(Datas);
}
if ( Robbery.tBar.Value < 100 )
{
Timer.Destroy( Ilerleme );
Timer.Destroy( Sallama );
Robbery.Window = null;
local Datas = Stream();
Datas.WriteInt(2);
Server.SendData(Datas);
}
}
function GUI::GameResize( width, height )
{
if (Robbery.Window)
{
Robbery.Window.Pos = VectorScreen(sX * 0.35, sY * 0.75);
Robbery.Window.Size = VectorScreen(sX * 0.4, sY * 0.123);
Robbery.tBar.Pos = VectorScreen(sX * 0.005, sY * 0.0015);
Robbery.tBar.Size = VectorScreen(sX * 0.39, sY * 0.064);
}
}
seterrorhandler(errorHandling);
[/noae][/noae]
I like the way you see things.
Yes, vcmp needs such interactive things.
Btw, what happens when you don't press the buttons you see?
Quote from: Sebastian on Jul 19, 2020, 12:26 PMI like the way you see things.
Yes, vcmp needs such interactive things.
Btw, what happens when you don't press the buttons you see?
Bar value decrease,
Robbery.time equals to 1 and if u don't press button you see it increase 1
[code]Robbery.tBar.Value -= 5 * Robbery.times;
and you have 2 chance to done this, after 2 miss it still continues but in the end you get 0 money :D