This topic was marked solved by its starter, on August 15th, 2017, 05:56 PM

umar4911

  • Hero Member
  • Creating own server!
  • Posts: 527
Time, Weather and Heal
« on August 11th, 2017, 05:09 PM »Last edited on August 12th, 2017, 07:42 PM
Can anybody give me the code of set time and weather? The time one in wiki is wrong


Please fix this code too.
Code: [Select]
function onPlayerCommand(player, command, arguments)
{
if(cmd == "heal")
{
local hp = player.Health;
if(hp == 100) Message("[#FF3636]Error - [#8181FF]Use this command when you have less than 100% hp !");
else
{
MessagePlayer("[#FFFF81] ---> Please wait five seconds to heal !", player);
NewTimer("heal", 5000, 1);
}
}

Code: [Select]
function heal(player, command, arguments)
{
Player.health == 100.0;
MessagePlayer( "[#FFFF81]---> You have been healed !", player);
}
I am gamer, programmer and hacker. Try to find me!
xD

Decent_946

  • Jr. Member
  • Thankx To Allah For Everything I Have :)
  • Posts: 78
Re: Time, Weather and script fix
« Reply #1, on August 11th, 2017, 05:42 PM »
Error in the code is because you aren't defining the player in timer and in the function you've set extra arguments.

Use:
Code: [Select]
NewTimer ( "heal", 5000, 1, player.ID );

And change function to :
Code: [Select]
function heal(ID)
{
local player = FindPlayer (ID);

if (plr)
{

  Player.Health = 100.;
  MessagePlayer( "[#FFFF81]---> You have been healed !", player);

}
else return 0;





To set time, use this function

And to set server weather use SetWeather function

umar4911

  • Hero Member
  • Creating own server!
  • Posts: 527
Re: Time, Weather and script fix
« Reply #2, on August 11th, 2017, 06:27 PM »
Quote from Decent_946 on August 11th, 2017, 05:42 PM
Error in the code is because you aren't defining the player in timer and in the function you've set extra arguments.

Use:
Code: [Select]
NewTimer ( "heal", 5000, 1, player.ID );

And change function to :
Code: [Select]
function heal(ID)
{
local player = FindPlayer (ID);

if (plr)
{

  Player.Health = 100.;
  MessagePlayer( "[#FFFF81]---> You have been healed !", player);

}
else return 0;





To set time, use this function

And to set server weather use SetWeather function
It is giving error[ wrong number of parameters]

and the timer code in wiki is wrong. I Checked it. There are several mistakes in it.
I am gamer, programmer and hacker. Try to find me!
xD

Cool

  • Hero Member
  • Posts: 719
Re: Time, Weather and script fix
« Reply #3, on August 11th, 2017, 07:23 PM »
thissss
Code: [Select]
Player.Health = 100.;
P should be in small letter + why you added dot(.) at the end of 100 its should be 100;

umar4911

  • Hero Member
  • Creating own server!
  • Posts: 527
I am gamer, programmer and hacker. Try to find me!
xD

Xmair

  • Wiki Contributor
  • Posts: 952
Re: Time, Weather and Heal
« Reply #6, on August 13th, 2017, 01:36 PM »
Code: [Select]
function onPlayerCommand(player, command, text)
{
if(cmd == "heal")
 {
  local hp = player.Health;
  if(hp == 100) MessagePlayer("[#FF3636]Error - [#8181FF]Use this command when you have less than 100% hp !", player);
  else
  {
   MessagePlayer("[#FFFF81] ---> Please wait five seconds to heal !", player);
   NewTimer("heal", 5000, 1, player.ID);
  }
  else if( cmd == "settime" )
  {
 
if ( !text ) MessagePlayer( "/settime [Hour] [Minute]", player );
else
{

local
args = split( text, " " );
if ( args.len( ) != 2 ) MessagePlayer( "/settime [Hour] [Minute]", player );
else if ( !IsNum( args[ 0 ] ) || !IsNum( args[ 1 ] ) ) MessagePlayer( "Hour/Minute must be an integer.", player );
else
{

SetTime( args[ 0 ].tointeger( ), args[ 1 ].tointeger( ) );
Message( player.Name + " set the time to " + args[ 0 ] + ":" + args[ 1 ] + "!" );

}

}
 
  }
  else if( cmd == "weather" )
  {
 
if ( !text ) MessagePlayer( "/weather [ID]", player );
else if ( !IsNum( text ) ) MessagePlayer( "Weather must be an integer.", player );
else if ( GetWeather( ) == text.tointeger( ) ) MessagePlayer( "The ID you provided is already being used.", player );
else
{

SetWeather( text.tointeger( ) );
Message( player.Name + " set the weather to " + text + "!" );

}
 
  }
}
function heal( player )
{

player = FindPlayer( player );
if( player )
{

player.Health = 100;

}

}
Untested.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD