Author Topic: Liberty Unleashed Public Beta Script  (Read 6124 times)

Force

  • Developer
  • Full Member
  • *****
  • Posts: 204
  • Karma: +6/-2
    • View Profile
Liberty Unleashed Public Beta Script
« on: July 28, 2010, 03: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;
}
Quote
[Tue - 20:09:35] <&VRocker> CRAP!
[Tue - 20:09:43] <&VRocker> i think i just followed through...
Quote
[Sat - 22:11:56] <~Smapy> [R3V]breSt12 killed [R3V]Jack_Bauer. (Splat)

Stoku

  • lck.gudio.eu
  • Full Member
  • ***
  • Posts: 276
  • Karma: +26/-2
  • Liberty City Killers
    • View Profile
    • Liberty City Killers (GTA3/VC Clan)
Re: Liberty Unleashed Public Beta Script
« Reply #1 on: July 28, 2010, 05:01:16 pm »
May be useful for beginners :).

Trip[ABK]

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
    • [ABK]AnyBody Killas
Re: Liberty Unleashed Public Beta Script
« Reply #2 on: July 31, 2010, 12:35:52 am »
cool, waitin on that wiki  ;)

NC

  • Full Member
  • ***
  • Posts: 101
  • Karma: +2/-3
  • cipa
    • View Profile
Re: Liberty Unleashed Public Beta Script
« Reply #3 on: July 31, 2010, 03: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.

Website online:
My YT channel: http://www.youtube.com/user/1234sdg131

Force

  • Developer
  • Full Member
  • *****
  • Posts: 204
  • Karma: +6/-2
    • View Profile
Re: Liberty Unleashed Public Beta Script
« Reply #4 on: July 31, 2010, 04: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.
Quote
[Tue - 20:09:35] <&VRocker> CRAP!
[Tue - 20:09:43] <&VRocker> i think i just followed through...
Quote
[Sat - 22:11:56] <~Smapy> [R3V]breSt12 killed [R3V]Jack_Bauer. (Splat)

NC

  • Full Member
  • ***
  • Posts: 101
  • Karma: +2/-3
  • cipa
    • View Profile
Re: Liberty Unleashed Public Beta Script
« Reply #5 on: July 31, 2010, 10: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?

Website online:
My YT channel: http://www.youtube.com/user/1234sdg131

Juppi

  • Developer
  • Jr. Member
  • *****
  • Posts: 86
  • Karma: +3/-1
    • View Profile
    • Kuslahden alaste GTA:MP clan
Re: Liberty Unleashed Public Beta Script
« Reply #6 on: August 01, 2010, 04: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 :)


« Last Edit: August 01, 2010, 04:39:33 pm by Juppi »

NC

  • Full Member
  • ***
  • Posts: 101
  • Karma: +2/-3
  • cipa
    • View Profile
Re: Liberty Unleashed Public Beta Script
« Reply #7 on: August 02, 2010, 12:33:51 am »
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?

Website online:
My YT channel: http://www.youtube.com/user/1234sdg131

Force

  • Developer
  • Full Member
  • *****
  • Posts: 204
  • Karma: +6/-2
    • View Profile
Re: Liberty Unleashed Public Beta Script
« Reply #8 on: August 02, 2010, 12:34:28 am »
Yerp that's right.
Quote
[Tue - 20:09:35] <&VRocker> CRAP!
[Tue - 20:09:43] <&VRocker> i think i just followed through...
Quote
[Sat - 22:11:56] <~Smapy> [R3V]breSt12 killed [R3V]Jack_Bauer. (Splat)

NC

  • Full Member
  • ***
  • Posts: 101
  • Karma: +2/-3
  • cipa
    • View Profile
Re: Liberty Unleashed Public Beta Script
« Reply #9 on: August 02, 2010, 12:39:46 am »
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?

Website online:
My YT channel: http://www.youtube.com/user/1234sdg131

Force

  • Developer
  • Full Member
  • *****
  • Posts: 204
  • Karma: +6/-2
    • View Profile
Re: Liberty Unleashed Public Beta Script
« Reply #10 on: August 02, 2010, 03:27:42 am »
You can create .cnut's which are compiled versions of the client scripts to stop people from doing just that. :)
Quote
[Tue - 20:09:35] <&VRocker> CRAP!
[Tue - 20:09:43] <&VRocker> i think i just followed through...
Quote
[Sat - 22:11:56] <~Smapy> [R3V]breSt12 killed [R3V]Jack_Bauer. (Splat)

VRocker

  • Liberty Unleashed Developer
  • Administrator
  • Full Member
  • ******
  • Posts: 342
  • Karma: +43/-15
    • View Profile
    • Madnight Software
Re: Liberty Unleashed Public Beta Script
« Reply #11 on: August 02, 2010, 08: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.


NC

  • Full Member
  • ***
  • Posts: 101
  • Karma: +2/-3
  • cipa
    • View Profile
Re: Liberty Unleashed Public Beta Script
« Reply #12 on: August 03, 2010, 12:08:48 pm »
Good to hear that :).

Website online:
My YT channel: http://www.youtube.com/user/1234sdg131

Toples

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
  • Get High
    • View Profile
Re: Liberty Unleashed Public Beta Script
« Reply #13 on: August 27, 2010, 09:19:54 pm »
Look's simple.

I started created my gamemode :D

Diavolo

  • Tester
  • Newbie
  • ****
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Liberty Unleashed Public Beta Script
« Reply #14 on: September 16, 2010, 11: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!!?

 

© Liberty Unleashed Team.