Liberty Unleashed

Liberty Unleashed => Liberty Unleashed Chat => Topic started by: Force on July 28, 2010, 02:20:31 pm

Title: Liberty Unleashed Public Beta Script
Post by: Force on July 28, 2010, 02:20:31 pm
VRocker has asked me to post the script that we've been using on the server for the public beta we are currently running, it's very easy to learn and understand so here you go. :)

Code: (squirrel) [Select]
/*
Beta Script - Script used for the LU Public Beta Tests
by Force
*/

function onPlayerJoin( pPlayer )
{
MessagePlayer( "Welcome to the server nablet! Hope you enjoy the beta testing!", pPlayer );
MessagePlayer( "/airport /heal /wep /goto", pPlayer );
}

function onPlayerKill( pKiller, pKilled, iWeapon, iBodyPart )
{
/* Get the weapon name and the body part name, putting in an offset for its Unknown */
local szWeapon = GetWeaponName( iWeapon ), szBodyPart = GetBodyPartName( iBodyPart );

if ( szBodyPart == "Unknown" ) szBodyPart = "Body";

Message( pKiller + " killed " + pKilled + " (" + szWeapon + ") (" + szBodyPart + ")", Colour( 255, 0, 0 ) );
}

function onPlayerDeath( pPlayer, iReason )
{
Message( pPlayer + " has died of a freak accident.", Colour( 255, 0, 0 ) );
}

function onPlayerCommand( pPlayer, szCommand, szParams )
{
local pTemp;

if ( szCommand == "heal" )
{
if ( pPlayer.Health < 100 )
{
Message( pPlayer + " has been healed.", Colour( 0, 255, 0 ) );
pPlayer.Health = 100;
}
else MessagePlayer( "Your health is full!", pPlayer );
}
else if ( szCommand == "wep" )
{
if ( !szParams ) MessagePlayer( "Error - Need to specify a weapon ID.", pPlayer );
else
{
pTemp = split( szParams, " " );
if ( IsNum( pTemp[ 0 ] ) )
{
local iWep = pTemp[ 0 ].tointeger();
if ( ( iWep > 0 ) && ( iWep < 12 ) ) pPlayer.SetWeapon( iWep, 250 );
else MessagePlayer( "Error - Invalid weapon ID!", pPlayer );
}
else MessagePlayer( "Error - Need to specify a weapon ID.", pPlayer );
}
}
else if ( szCommand == "goto" )
{
if ( !szParams ) MessagePlayer( "Error - Need to specify a target player.", pPlayer );
else
{
local pTemp = split( szParams, " " ), p = GetPlayer( pTemp[ 0 ] );
if ( p )
{
if ( p.Spawned )
{
Message( "Taking " + pPlayer + " to " + p, Colour( 0, 255, 0 ) );
pPlayer.Pos = p.Pos;
}
else MessagePlayer( "This person isn't spawned nub!", pPlayer );
}
else MessagePlayer( "Can't find anyone with that id/nick", pPlayer );
}
}
else if ( szCommand == "surface" )
{
local iValue = 4.5;
if ( szParams ) iValue = szParams.tofloat();
SetSurfaceTraction( 10, iValue );
}
else if ( szCommand == "gamespeed" )
{
local iValue = 1;
if ( szParams ) iValue = szParams.tofloat();
SetGamespeed( iValue );
}
else if ( szCommand == "gravity" )
{
local iValue = 0.008;
if ( szParams ) iValue = szParams.tofloat();
SetGravity( iValue );
}
else if ( szCommand == "irc" ) Message( "IRC - irc.manana.liberty-unleashed.co.uk - #lu.echo" );
}

function GetPlayer( target )
{
target = target.tostring();

if ( IsNum( target ) )
{
target = target.tointeger();

if ( FindPlayer( target ) ) return FindPlayer( target );
else return null;
}
else if ( FindPlayer( target ) ) return FindPlayer( target );
else return null;
}
Title: Re: Liberty Unleashed Public Beta Script
Post by: Stoku on July 28, 2010, 04:01:16 pm
May be useful for beginners :).
Title: Re: Liberty Unleashed Public Beta Script
Post by: Trip[ABK] on July 30, 2010, 11:35:52 pm
cool, waitin on that wiki  ;)
Title: Re: Liberty Unleashed Public Beta Script
Post by: NC on July 31, 2010, 02:29:49 pm
Quote
SetSurfaceTraction( 10, iValue );

Can someone explain what does 10 and iValue means here? I guess one is the ID of something and the second is the grip :p.
Title: Re: Liberty Unleashed Public Beta Script
Post by: Force on July 31, 2010, 03:02:11 pm
The 10 is the surface value to modify, in this case tarmac, the iValue (you've probably seen it being set) is how grippy that surface is.
Title: Re: Liberty Unleashed Public Beta Script
Post by: NC on July 31, 2010, 09:23:27 pm
Quote
; Title        :    Surface.dat
; Author    :    Richard Jobling
; Date        :    14/02/00
;
;    Currently WheelBase is the surface used for the tyres
;
;               Rubber          Hard           Road             Loose           Wet
;
Rubber          6.0
Hard            3.6             2.0
Road            4.5             3.0            6.0
Loose           3.2             3.5            2.0              1.0
Wet             2.4             2.0            1.0              1.0             0.5

And if I want to edit the grip for road, what should be instead of 10?
Title: Re: Liberty Unleashed Public Beta Script
Post by: Juppi on August 01, 2010, 03:35:45 pm
You don't need to worry about magical values like this used in the script, every index will have a self-explanatory constant to use with the function. The test script was written before surface constants were added to scripting which is why the script is using a seemingly random value.

Using a constant for different surfaces the function would look like this:

Code: (squirrel) [Select]
SetSurfaceTraction( SURFACE_ROAD_RUBBER, 4.5 );
This would set the grip between rubber (tyres) and road (tarmac) surfaces to 4.5 which is the default value (as you can see from surface.dat). For rubber and wet roads the index constant would be SURFACE_WET_RUBBER etc. All these values will obviously be listed in the scripting wiki.

In addition to scripting functions you can also load a custom surface.dat file on server start by placing the file to the server data folder. The values in the file will then be used for all clients joining the server, making it easy to create a drift server with optimal settings for example :)


Title: Re: Liberty Unleashed Public Beta Script
Post by: NC on August 01, 2010, 11:33:51 pm
Thanks for the answer :).

I am now looking at the sample script and I'm asking myself what is built-in to the server and can't be changed by script? I have counted 3 things: /kill, player join server and exit. Am I right?
Title: Re: Liberty Unleashed Public Beta Script
Post by: Force on August 01, 2010, 11:34:28 pm
Yerp that's right.
Title: Re: Liberty Unleashed Public Beta Script
Post by: NC on August 01, 2010, 11:39:46 pm
OMG answer in a second :O.

:D

If we are talking about scripting I have some doubts about the client side scripting. When we connect to a server, the script is saved on our PC, but it's still there after game end and everyone can have a look into it. I think that when LU will be released, someone might create a uber-cool-client-side-script. Someone who wants the script source just connect to the server and got something, on which someone may be a long time working. That's not fair. :(

Can't you somehow compile, code or whatever the script so that players couldn't read them?
Title: Re: Liberty Unleashed Public Beta Script
Post by: Force on August 02, 2010, 02:27:42 am
You can create .cnut's which are compiled versions of the client scripts to stop people from doing just that. :)
Title: Re: Liberty Unleashed Public Beta Script
Post by: VRocker on August 02, 2010, 07:55:17 am
As force said, scripts can be compiled and used like that. We will probably modify cnuts for LU for better security though. Dont think compiling client scripts is that vital though. Yes players can read it but they cant really steal it since most client scripts require the server script to function correctly (with the exception of the speedo)

Going on what you asked earlier, join and exit messages are hardcoded yes but they can be overridden.
Title: Re: Liberty Unleashed Public Beta Script
Post by: NC on August 03, 2010, 11:08:48 am
Good to hear that :).
Title: Re: Liberty Unleashed Public Beta Script
Post by: Toples on August 27, 2010, 08:19:54 pm
Look's simple.

I started created my gamemode :D
Title: Re: Liberty Unleashed Public Beta Script
Post by: Diavolo on September 16, 2010, 10:54:12 am
I believe that script is outdated and full of security issues?

Id suggest using phps mail function but you need to make sure you validate the input. Simple example of how easy it is to use without validation:

Code:

WTF ARE YOU TALKING ABOUT!!?
Title: Re: Liberty Unleashed Public Beta Script
Post by: Stoku on September 16, 2010, 12:05:00 pm
I believe that script is outdated and full of security issues?

Id suggest using phps mail function but you need to make sure you validate the input. Simple example of how easy it is to use without validation:

Code:

WTF ARE YOU TALKING ABOUT!!?
^

@FreekingDelphina: It's Squirrel, not PHP and it's safe. My advice for you is: stop making dumb (sorry, but I dont know how to call it) posts and start reading first.

The other post:
i want to know how can i upload cyrillic subtitles on the dvd.it reads the cyrillic when you play dvd but in dvx it doesnt display the letters they look like chinese or something of that sort how can i fix this the dvd is: Superior SP2070 with Sunplus 8281 DN chipset and something else hunix 712 e hy57v641620etp-7
Wtf? "Cyrylic letters" topic isn't related to hardware, it's related to LU (Liberty Unleashed - multiplayer mod for GTA3 which wont work on DVD, C64, Amiga, TV, MP3 player, hamburger etc).
Title: Re: Liberty Unleashed Public Beta Script
Post by: W4R10CK on September 27, 2010, 02:43:26 pm
I believe that script is using squirrell? Judging by "text" + "text" thing going on  :D