Liberty Unleashed
Liberty Unleashed => Liberty Unleashed Chat => Topic started 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.
-
pls send here the gamemode from test server i want to trry squirell
-
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.
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!" );
}
-
WoW, It's simple! :P
-
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)
-
Bunnies > Squirrels
-
really easy scripting =)
-
please help some squirrel editor?? where is possibly to coulour syntax
-
Use "Notepad+" you can use colour syntax with that.
-
woohoo easy :D
-
too easy code ^^
-
lol I can't wait to see posts with people asking for Squirrel scripting help.
.nuts ftw!
-
simple....is any list of functions? callbacks?
-
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
-
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 :) :)
-
Trains aren't synced just yet.
-
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!
-
I already forgot Squirrel Scripting!
However scm's wait XXXX ms > timers :).
-
I can not register for http://www.scripting-unleashed.co.uk (http://www.scripting-unleashed.co.uk) Why ?
-
As that is not officially part of Liberty Unleashed the developers asked for it to be put into maintenance mode by the owner.
-
you could do better pawn
-
easy,its easy for vrocker and rest xddd for me is normal.a? is in wiki xd
-
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.
-
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.