Would you like some Water ?

Started by KrOoB_, Jul 13, 2020, 02:14 AM

Previous topic - Next topic

KrOoB_

Basic Thirst/Hunger Script
Thanks Xmair for helps <3
It can be "Hungery" script also, if you change the vars :D
Server Side
[spoiler][noae][noae][noae]function onScriptLoad()
{
   thirst <- array( 1000, 100 );
}

function onPlayerRequestSpawn( player )
{
    thirst[ player.ID ] = 100;
}

function onPlayerSpawn( player )
{
local th = thirst[ player.ID ]
                        local data = Stream();
                        data.StartWrite( );
                        data.WriteInt( 42 );
                        data.WriteString(th);
                        data.SendStream( player );
}
function Thirst()
{
for (local i = 0; i <GetMaxPlayers (); i ++)
{
local player = FindPlayer (i);
if (player)
{
if (player.IsSpawned)
{
if ( thirst[ player.ID ] >= 1 )
{
thirst[ player.ID ] -= 5;
local th = thirst[ player.ID ]
                        local data = Stream();
                        data.StartWrite( );
                        data.WriteInt( 42 );
                        data.WriteString(th);
                        data.SendStream( player );
}
if ( player.Vehicle )
{
thirst[ player.ID ] -= 0.00001;
local th = thirst[ player.ID ]
                        local data = Stream();
                        data.StartWrite( );
                        data.WriteInt( 42 );
                        data.WriteString(th);
                        data.SendStream( player );
}
else if ( thirst[ player.ID ] < 1 )
{
player.Speed = Vector( 0, 0, 0 );
                            player.Health -=100;
local th = thirst[ player.ID ]
                            local data = Stream();
                            data.StartWrite( );
                            data.WriteInt( 42 );
                            data.WriteString(th);
                            data.SendStream( player );
}
}
                if ( player.Health == 1 )
                {
                    thirst[ player.ID ] -= 0.001;
local th = thirst[ player.ID ]
                    local data = Stream();
                    data.StartWrite( );
                    data.WriteInt( 42 );
                    data.WriteString(th);
                    data.SendStream( player );
                }
}
}
}

 function onTimeChange(oldHour, oldMin, newHour, newMin)
{
switch( newMin )
{
case 0:
Thirst( );
break;
case 10:
Thirst( );
break;
case 20:
case 30:
case 40:
case 50:
Thirst( );
break;
}
}
[/noae][/noae][/noae][/spoiler]

Client Side [spoiler]
[noae][noae] Thirstu <- 100;

Peace <-
{
Tbar = null
Tlabel = null
Th = 100
}

function Server::ServerData(stream)
{
 local StreamReadInt = stream.ReadInt(),
  StreamReadString = stream.ReadString();
 switch (StreamReadInt.tointeger())
 {
case 42: local data = StreamReadString; Dude(); ::Thirstu = StreamReadString.tofloat(); break;
}
}

function Dude(){
Peace.Tbar = GUIProgressBar();
 Peace.Tbar.Pos = VectorScreen( sX * 0.0, sY*0.0 );
 Peace.Tbar.Size = VectorScreen( sX * 0.08, sY * 0.025 );
 Peace.Tbar.StartColour = Colour( 40, 255, 40 );
 Peace.Tbar.EndColour = Colour( 180, 110, 110 );
 Peace.Tbar.MaxValue = 100;
 Peace.Tbar.BackgroundShade = 0.3;
 Peace.Tbar.Thickness = 2;
 
 Peace.Tlabel = GUILabel( );
 Peace.Tlabel.Text = "Thirst";
 Peace.Tlabel.Pos = VectorScreen( sX * 0.0, sY*-0.01 );
 Peace.Tlabel.FontSize = 24;
 Peace.Tlabel.FontName = "Squada One";

 Peace.Tlabel.TextColour = Colour( 255, 255, 255 );
 Peace.Tbar.AddChild( Peace.Tlabel );


  Peace.Tbar.Value = ::Thirstu;
Peace.Th = ::Thirstu;
Peace.Tlabel.Text = "Thirst";
Peace.Tlabel.FontSize = 12;
Peace.Tlabel.FontName = "Squada One";

}
[/noae][/noae][/noae][/spoiler]

Have a nice day

There video gooo
https://www.youtube.com/watch?v=1vP4Q74Xe9c

Contact: Harun | KrOoB#2057
Test Server : 80.253.245.58:8191

Sebastian


habi


KrOoB_


SHy^


Sonmez

if (!perfect) createAgain();

KrOoB_

Quote from: Sebastian on Jul 13, 2020, 02:30 AMHard RPG in VCMP :D
PS: Pics ?
very hard :D
with this script panic hungery thirsty Fuel etc. can be done