Vice Underdogs

Scripting => Script Showroom => Topic started by: stormeus on April 06, 2012, 11:21:22 pm

Title: [Squirrel] Undocumented Functions
Post by: stormeus on April 06, 2012, 11:21:22 pm
Seeing that most of us here are pretty decent scripters, I'm going to leave a list of undocumented functions in the Squirrel server that were found. I really don't like the idea of having "zomg excloosive" scripts when these functions are present in every copy of the Squirrel server. I also don't like having one server be able to use scripts that were accidentally skipped over when documenting the wiki, as it lowers the quality of other servers and makes the community overall shittier.

tl;dr morphine and gudio be mad

I did not do this alone. Gudio had found some other functions, and Morphine encouraged me to find the functions and, if my memory serves me right, found a couple as well. If you must ask what these do or how you use these, close this tab or window right now.

I decided not to post this on the official VC:MP Squirrel forum because god knows how many nabs await there.



Level 1
Stuff with no wiki pages

Player.SetIgnoredBy( Player playerToBlock, Boolean toBlock )
This will make the player ignore the given playerToBlock parameter, if toBlock is true. In other words, they'll be muted only to that player. When set to false, they are unmuted to the blocking player.

Player.IsIgnoredBy( Player playerPossiblyBlocked )
Returns boolean (true/false) value of whether the Player object is ignoring the playerPossiblyBlocked parameter.

SetWeaponDamage( Integer weapon, Float damage )
Does what it says on the label; default values for weapons are unknown. It's likely they correspond to the game's weapon configuration.

RemoveAllPickups( void )
Does what it says on the label; should remove all pickups.



Level 2
Shit that doesn't even appear on the wiki

onPlayerCrashDump( Player player, CrashAddress crash )
Called when a player performs a crash dump. However, their disconnection is not automatic. You will need to kick the player to make good use of this event.

onBannedConnectionAttempt( String IP )
Called when an RCON-banned player queries or attempts to join the server. Only their IP is passed, as a proper Player object is impossible to create given the nature of the event.

String Player.Velocity
Simply prints the string "Velocity" and is of no use.

Vector2D Vehicle.Velocity
Working vehicle velocity counter which can be useful for making speedometers. Returns a two-dimensional vector (x, y) which can then be used to calculate speed using this code:

Code: (Squirrel) [Select]
local v = player.Vehicle.Velocity;
local s = ( ( sqrt( (v.x * v.x) + (v.y * v.y) ) * 230 ) + 0.5).tointeger(); // kilometers per hour

GetPickupCount( void )
Simply returns the pickup count. Good if you dynamically create pickups but don't want to reach the limit.

GetVehicleCount( void )
Like GetPickupCount, returns the number of vehicles on the server.

CreateStaticVehicle( Integer model, Vector pos, Float angle, Integer col1, Integer col2 )
Working alias to CreateVehicle and can be used at any point in the script like CreateVehicle.

SetPlayerDesyncedPos( Player player, Vector pos )
Unknown if working. If it does work, this function presumably sets a desynced player's position, which will appear unchanged to synced players.

SetVehicleDesyncedPos( Vehicle vehicle, Vector pos )
See SetPlayerDesyncedPos



Level 3
Console commands

unload_script filename
Unloads a script according to filename

load_script filename
Loads a script according to filename (see: load_script)



Orange -- Unknown if working



This information is likely going to be copied to the official Squirrel wiki... eventually. ::)
Title: Re: [Squirrel] Undocumented Functions
Post by: Zeke on April 06, 2012, 11:28:02 pm
Cool stuff, good work.
If you can add all the MySQL missing thingys from the wiki, id be pro.
Title: Re: [Squirrel] Undocumented Functions
Post by: GranDoIz on April 06, 2012, 11:58:38 pm
GoooD  ;D
Title: Re: [Squirrel] Undocumented Functions
Post by: morphine on April 07, 2012, 12:36:20 am
Edited onPlayerCrashDump.
Title: Re: [Squirrel] Undocumented Functions
Post by: tato on April 07, 2012, 06:12:41 am
omfg!! awesome great..i bet there are more out there :thumbsup: :thumbsup: :thumbsup:
Title: Re: [Squirrel] Undocumented Functions
Post by: Midiox on April 07, 2012, 08:24:07 am
Good job  :thumbsup:
Title: Re: [Squirrel] Undocumented Functions
Post by: Charley on April 07, 2012, 10:16:26 am
Nice one Stormeus. I played around with the IgnoredBy functions about a year ago and encountered some problems, I can't remember their exact nature though.
Title: Re: [Squirrel] Undocumented Functions
Post by: morphine on April 07, 2012, 12:49:08 pm
player.SetIgnoredBy( plr, true );

Blocks messages sent by "player" to "plr". This includes private messages and public chat messages. i.e. chat messages sent by "player" will not be seen by "plr".
Title: Re: [Squirrel] Undocumented Functions
Post by: stormeus on April 07, 2012, 01:56:17 pm
Modified Player.SetIgnoredBy, GetIgnoredBy

Added GetVehicleCount

Added Player.Velocity which requires testing
doesn't work lol

Added Vehicle.Velocity as a presumption, since Player.Velocity exists in the code. Requires testing.
Works!

Modified CreateStaticVehicle
Title: Re: [Squirrel] Undocumented Functions
Post by: Charley on April 07, 2012, 05:27:17 pm
Yeah it wasn't a problem in the syntax Morphine, it was to do with sync. The actual function didn't function how it should, that's all I remember.
Title: Re: [Squirrel] Undocumented Functions
Post by: morphine on April 08, 2012, 07:53:15 am
It's extremely confusing at first. I had to ask AdTec how to get it to work and.. I got it to work. :D

This is a little cut from the command which uses this function in Vice Legends (and works, surprisingly):

Code: [Select]
player.SetIgnoredBy( playerToIgnore, true );
                                        VCLPrivMessage( "You have muted everything related to " +  playerToIgnore.Name + " from your game.", player );

I've made a mistake in the last post I think.. it's a bit vice-versa with the player pointers here. Mixing them up is deadly.   :thumbsdown:
Title: Re: [Squirrel] Undocumented Functions
Post by: stormeus on April 08, 2012, 10:49:20 pm
Modified SetIgnoredBy, IsIgnoredBy