Can anybody give me the code of set time and weather? The time one in wiki is wrong
Please fix this code too.
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);
}
}
function heal(player, command, arguments)
{
Player.health == 100.0;
MessagePlayer( "[#FFFF81]---> You have been healed !", player);
}
Error in the code is because you aren't defining the player in timer and in the function you've set extra arguments.
Use: NewTimer ( "heal", 5000, 1, player.ID );
And change function to :
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 (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/SetTime)
And to set server weather use SetWeather function
Quote from: Decent_946 on Aug 11, 2017, 04:42 PMError in the code is because you aren't defining the player in timer and in the function you've set extra arguments.
Use: NewTimer ( "heal", 5000, 1, player.ID );
And change function to :
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 (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/SetTime)
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.
thissss
Player.Health = 100.;
P should be in small letter + why you added dot(.) at the end of 100 its should be 100;
Quote from: Cool on Aug 11, 2017, 06:23 PMthissss
Player.Health = 100.;
P should be in small letter + why you added dot(.) at the end of 100 its should be 100;
Still wrong number of parameters.
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.