Liberty Unleashed

Liberty Unleashed => Liberty Unleashed Chat => Topic started by: VRocker on December 22, 2008, 12:36:11 pm

Title: Squirrel Scripting
Post by: VRocker on December 22, 2008, 12:36:11 pm
Thought i'd make a topic on the scripting language used in Liberty Unleashed due to most of it being in the wish list.

LU uses Squirrel (http://squirrel-lang.org) for scripting. Squirrel is easy to use and is designed specifically for game scripting.
I chose Squirrel due to it being similar in ways to Lua, but also having the syntax which is C-like. Once you learn Squirrel you will see it is a very powerful language and boasts many nice features.
Another reason why Squirrel was chosen is that its very easy to impliment. Being easy to impliment means i can spend less time messing around with the scripts and more time with the actual code.

One of its nice features is that i can make my own variable types and impliment them into the scripting (via SqPlus) which allows me to pass data to the scripts as Vectors or full classes, making less work for me but also keeping the scripts easy to use.

There is some documentation on Squirrels internal functions Here (http://liberty-unleashed.co.uk/Squirrel.pdf) which is a modified version of the original document, but with the C++ stuff removed.

I will make an application to practice Squirrel on soon, instead of having to release the server. This should help in understanding it and why it has been chosen.
Title: Re: Squirrel Scripting
Post by: Rolan on December 22, 2008, 01:54:30 pm
pls send here the gamemode from test server i want to trry squirell
Title: Re: Squirrel Scripting
Post by: VRocker on December 22, 2008, 09:04:12 pm
This is the script that was running before admin levels were implimented. I wont upload the admin script due to it being made by Juppi and not me.

Code: (squirrel) [Select]
function OnServerStart(  )
{
print( "Server Started: "+ GetServerName() );
}

function OnPlayerJoin( id, name )
{
MessagePlayer( "Welcome " + name + " to the LU testing session", id, 153, 255, 0 );
SetPlayerCash( id, 2000 );
}

function OnPlayerDeath( iID, iWep )
{
Message( "* " + GetPlayerName( iID ) + " killed himself. ("+GetWeaponName( iWep )+")", 255, 165, 0 );
local vPos = GetPlayerPos( iID );
local iCash = GetPlayerCash( iID );
CreateCashPickup( iCash, vPos.x + 1.75, vPos.y + 1.75, vPos.z );
SetPlayerCash( iID, 0 );
}

function OnPlayerKill( iKiller, iID, iWep, iBodyPart )
{
if ( iKiller == iID )
{
Message( "* " + GetPlayerName( iID ) + " killed himself. ("+GetWeaponName( iWep )+")", 255, 165, 0 );
local vPos = GetPlayerPos( iID );
local iCash = GetPlayerCash( iID );
CreateCashPickup( iCash, vPos.x + 1.75, vPos.y + 1.75, vPos.z );
SetPlayerCash( iID, 0 );
}
else
{
local iScore = GetPlayerScore( iKiller );
SetPlayerScore( iKiller, ( iScore + 1 ) );

local iCash = 1000;

local iKilledCash = GetPlayerCash( iID );
if ( iKilledCash > 0 )
{
//MessagePlayer( "!! You stole $" + iKilledCash + " from " + GetPlayerName( iID ) + " !!", iKiller, 102, 254, 255 );
//MessagePlayer( "!! " + GetPlayerName( iKiller ) + " stole " + iKilledCash + " from you !!", iID, 102, 254, 255 );
iCash = iCash + iKilledCash;
SetPlayerCash( iID, 0 );
}
//SetPlayerCash( iKiller, iCash );
local vPos = GetPlayerPos( iID );
CreateCashPickup( iCash, vPos.x + 1.75, vPos.y + 1.75, vPos.z );

if ( GetWeaponName( iWep ) == "Vehicle" )
{
local vehicle = GetPlayerVehicle( iKiller );
if ( vehicle )
{
if ( GetVehicleModel( vehicle ) == 126 ) Message( "* " + GetPlayerName( iKiller ) + " dodokilled "+GetPlayerName( iID ), 255, 165, 0 );
else Message( "* " + GetPlayerName( iKiller ) + " carkilled "+GetPlayerName( iID ), 255, 165, 0 );
}
else Message( "* " + GetPlayerName( iKiller ) + " carkilled "+GetPlayerName( iID ), 255, 165, 0 );
}
else Message( "* " + GetPlayerName( iKiller ) + " killed "+GetPlayerName( iID )+". ("+GetWeaponName( iWep )+")", 255, 165, 0 );
}
}

function OnPlayerCommand( iID, szCmd, szText )
{
if ( szCmd == "health" )
{
if ( szText != null )
{
local a = split( szText, " " );

local ID = 0;
if ( !IsNum( a[0] ) ) ID = GetPlayerID( a[0] );
else ID = a[0].tointeger();

local Armour = GetPlayerArmour( ID );
if ( Armour == 0 ) Message( "* " + GetPlayerName( ID ) + "'s Health: " + GetPlayerHealth( ID ) );
else Message( "* " + GetPlayerName( ID ) + "'s Health: " + GetPlayerHealth( ID ) + ", Armour: " + Armour );
}
else
{
local Armour = GetPlayerArmour( ID );
if ( Armour == 0 ) Message( "* " + GetPlayerName( iID ) + "'s Health: " + GetPlayerHealth( iID ) );
else Message( "* " + GetPlayerName( iID ) + "'s Health: " + GetPlayerHealth( iID ) + ", Armour: " + Armour );
}
}
else if ( szCmd == "mypos" )
{
local v = GetPlayerPos( iID );
Message( GetPlayerName( iID ) + " is currently at " + v.x + ", " + v.y + ", " + v.z );
}
else if ( szCmd == "goto" )
{
if ( szText != null )
{
local a = split( szText, " " );

local ID = 0;
if ( !IsNum( a[0] ) ) ID = GetPlayerID( a[0] );
else ID = a[0].tointeger();

if ( GetPlayerName( ID ) != "Unknown" )
{
local vPos = GetPlayerPos( ID );

Message( GetPlayerName( iID ) + " is teleporting to " + GetPlayerName( ID ) );
SetPlayerPos( iID, vPos );
}
}
}
else if ( szCmd == "cash" )
{
Message( GetPlayerName( iID ) + " has $" + GetPlayerCash( iID ) );
}
else if ( szCmd == "hpickup" )
{
local v = GetPlayerPos( iID );
Message( "Creating Pickup At: " + v.x + ", " + v.y + ", " + v.z );
local pickup = CreatePickup( 1362, 3, v.x, v.y, v.z );
}
else if ( szCmd == "apickup" )
{
local v = GetPlayerPos( iID );
Message( "Creating Pickup At: " + v.x + ", " + v.y + ", " + v.z );
local pickup = CreatePickup( 1364, 3, v.x, v.y, v.z );
}
else if ( szCmd == "stinger" )
{
local v = GetPlayerPos( iID );
MessagePlayer( "Spawning a Stinger...", iID );
CreateVehicle( VEH_STINGER, v.x + 5, v.y, v.z, GetPlayerAngle( iID ) );
}
else if ( szCmd == "banshee" )
{
local v = GetPlayerPos( iID );
MessagePlayer( "Spawning a Banshee...", iID );
CreateVehicle( VEH_BANSHEE, v.x + 5, v.y, v.z, GetPlayerAngle( iID ) );
}
else if ( szCmd == "dodo" )
{
local v = GetPlayerPos( iID );
MessagePlayer( "Spawning a Dodo...", iID );
CreateVehicle( VEH_DODO, v.x + 5, v.y, v.z, GetPlayerAngle( iID ) );
}
else if ( szCmd == "spawncar" )
{
if ( szText != null )
{
local a = split( szText, " " );

local ID = 90;
if ( IsNum( a[0] ) ) ID = a[0].tointeger();

if ( ( ID >= 90 ) && ( ID <= 150 ) )
{
local v = GetPlayerPos( iID );
MessagePlayer( "Spawning a vehicle with model ID " + ID + "...", iID );
CreateVehicle( ID, v.x + 5, v.y, v.z, GetPlayerAngle( iID ) );
}
}
}
}

function OnScriptLoad( )
{
print( "Script Loaded!" );
}

function OnScriptUnload( )
{
print( "Script Unloaded!" );
}
Title: Re: Squirrel Scripting
Post by: [TDM]Relax on December 23, 2008, 01:21:44 am
WoW, It's simple! :P
Title: Re: Squirrel Scripting
Post by: Windlord on December 23, 2008, 09:24:29 am
orly?

Squirrel is really nice because VRocker can add in custom functions to the script and this makes it so much better since we won't need to spend time looking for alternative ways to do some stuff which could be solved easily by adding in a function into squirrel. (eg. irc echos)
Title: Re: Squirrel Scripting
Post by: BB101 on December 23, 2008, 10:45:11 am
Bunnies > Squirrels
Title: Re: Squirrel Scripting
Post by: XAOC on December 23, 2008, 06:47:01 pm
really easy scripting =)
Title: Re: Squirrel Scripting
Post by: rammar on May 24, 2009, 05:49:07 pm
please help some squirrel editor?? where is possibly to coulour syntax
Title: Re: Squirrel Scripting
Post by: Tamas on June 01, 2009, 10:24:51 pm
Use "Notepad+" you can use colour syntax with that.
Title: Re: Squirrel Scripting
Post by: MelKiY on April 10, 2010, 06:55:08 pm
woohoo easy :D
Title: Re: Squirrel Scripting
Post by: BooMario on May 18, 2010, 05:31:44 pm
too easy code ^^
Title: Re: Squirrel Scripting
Post by: Windlord on May 18, 2010, 09:25:37 pm
lol I can't wait to see posts with people asking for Squirrel scripting help.

.nuts ftw!
Title: Re: Squirrel Scripting
Post by: rammar on May 19, 2010, 02:45:31 pm
simple....is any list of functions? callbacks?
Title: Re: Squirrel Scripting
Post by: Force on May 19, 2010, 02:54:42 pm
You will have a full list of functions and callbacks/signals available to you once we release LU, there's that many we sometimes forget what we have available. :P
Title: Re: Squirrel Scripting
Post by: rammar on May 19, 2010, 02:58:15 pm
i think this will be best MP from unofficial gta series


- use many of SP things (pager, train. etc.)
- abnormaly good sync
VRocker and "his" team  is hero :D

GL, dont give up we are close :) :)
Title: Re: Squirrel Scripting
Post by: Windlord on May 19, 2010, 03:08:38 pm
Trains aren't synced just yet.
Title: Re: Squirrel Scripting
Post by: Windlord on June 09, 2010, 05:08:20 am
Apologies for the double post.

As the release of LU draws very close,
I would like to remind all potential server scripters
that VRocker released a nice tool (http://forum.vicecitymultiplayer.info/index.php?topic=2.0) last year
with the Squirrel scripting language implemented.

The tool I speak of is the VC-MP unofficial squirrel server.
The most up-to-date version can be found at this link (http://forum.vicecitymultiplayer.info/index.php?topic=2.0).

The function and event names used in this server
are in general similar to the LU server's functions
and therefore it would be a good idea to start creating scripts using the VC-MP squirrel server.
All squirrel functions and callbacks for the VC-MP server have been documented at this wiki page (http://liberty-unleashed.co.uk/VCWiki/Scripting/squirrel).

You WILL want to get your server out there as soon as possible!
Scripting using the mentioned server is the best way to go about preparing for the moment of release!
Title: Re: Squirrel Scripting
Post by: NC on June 09, 2010, 10:15:15 pm
I already forgot Squirrel Scripting!

However scm's wait XXXX ms > timers :).
Title: Re: Squirrel Scripting
Post by: Dominik on December 14, 2010, 09:20:31 pm
I can not register for http://www.scripting-unleashed.co.uk (http://www.scripting-unleashed.co.uk) Why ?
Title: Re: Squirrel Scripting
Post by: Force on December 14, 2010, 10:03:41 pm
As that is not officially part of Liberty Unleashed the developers asked for it to be put into maintenance mode by the owner.
Title: Re: Squirrel Scripting
Post by: _GHT_MarK445 on December 23, 2010, 07:34:26 pm
you could do better pawn
Title: Re: Squirrel Scripting
Post by: matheo on January 13, 2011, 10:42:23 pm
easy,its easy for vrocker and rest xddd for me is normal.a? is in wiki xd
Title: Re: Squirrel Scripting
Post by: Force on January 13, 2011, 11:24:37 pm
you could do better pawn

<late>
No you really couldn't, pawn is an overhyped pile of steaming shit, so inefficient and they way it does things is retarded.
Title: Re: Squirrel Scripting
Post by: Windlord on January 14, 2011, 12:55:47 am
To each his own.
To be honest, the language doesn't matter tooooo much.
The implementation does and LU's way of using instances is great.

His comment makes no grammatical sense anyways, "you could do better pawn" sounds like he's talking to a pawn.