KrooB

  • Full Member
  • BEN TÜRKÜM
  • Posts: 141
Would you like some Water ?
«  »Last edited
Basic Thirst/Hunger Script
Thanks Xmair for helps <3
It can be "Hungery" script also, if you change the vars :D
Server Side
(click to show/hide)
Code: [Select]
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;
}
}

Client Side
(click to show/hide)
Code: [Select]
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";

}

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
We are his people !
Who can challange us ?

Sebastian

  • VC:MP Beta Tester
  • Something like this: hga hga hga
  • Posts: 1,059

habi

  • Full Member
  • Posts: 234

KrooB

  • Full Member
  • BEN TÜRKÜM
  • Posts: 141
We are his people !
Who can challange us ?

SHy^

  • Newbie
  • Posts: 26

Sonmez

  • Newbie
  • Yo! It's time to play the fair game!
  • Posts: 22
if (!perfect) createAgain();

KrooB

  • Full Member
  • BEN TÜRKÜM
  • Posts: 141
We are his people !
Who can challange us ?