Squirrel/Functions/Server/SetFallEnabled

From VC-MP Wiki

Jump to: navigation, search

Contents

Syntax

SetFallEnabled(boolean);

Arguments

The Boolean is, as you all know, a true/false data type. SetFallEnabled is used to trigger the switching off and on of the /fall command on VC-MP which until now has only given the VC-MP players grief because it tends to be used for the wrong purposes.

boolean - True/False

Example

Disabling the /fall command. This should only be done once since it affects the entire server as one so we will put it in onScriptLoad(). It is up to you to put the function wherever you want though but it might not be as efficient in some places as in the others.

 function onScriptLoad()
{
  // All your crap for onScriptLoad goes here and voila, the next function.
  SetFallEnabled(false);
}

This is for disabling it. Enabling it would only need false to be set to true.

Example 2

Enabling it.

function onScriptLoad()
{
  // Your shit here
  SetFallEnabled(true);
}

Or if you have the knowledge how to, you can make a command which compiles strings in-game to avoid having to run through the scripts all the time.

Using it with commands

Enabling

function onPlayerCommand(player, command, text)
{
 if (command == "fallon")
 {
   SetFallEnabled(true);
   Message("Fall has been enabled.");
}
}

Disabling.

function onPlayerCommand(player, command, text)
{
 if(command == "falloff")
 {
   SetFallEnabled(false);
   Message("Fall has been disabled.");
}
}

edit:// An easier way to do the above:

function onPlayerCommand( player, command, text )
{
    if( command == "setfall" )
    {
        if( text.tolower() == "on" )
        {
          if( GetFallEnabled() == true ) PrivMessage( "/fall is already enabled.", player );
          else
          {
               SetFallEnabled( true );
               PrivMessage( "/fall has been enabled.", player );
          }
        }
        else if( text.tolower() == "off" )
        {
         if( GetFallEnabled() == false ) PrivMessage( "/fall is already disabled.", player );
         else
         {
               SetFallEnabled( false );
               PrivMessage( "/fall has been disabled.", player );
         }
        }
        else PrivMessage( "Nab", player );
     }
}
    • Not tested though **

The End

Thank you for reading.


squirrel scripting