Liberty Unleashed
Liberty Unleashed => Liberty Unleashed Chat => Topic started 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. :)
/*
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;
}
-
May be useful for beginners :).
-
cool, waitin on that wiki ;)
-
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.
-
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 : 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?
-
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:
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 :)
-
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?
-
Yerp that's right.
-
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?
-
You can create .cnut's which are compiled versions of the client scripts to stop people from doing just that. :)
-
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.
-
Good to hear that :).
-
Look's simple.
I started created my gamemode :D
-
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!!?
-
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).
-
I believe that script is using squirrell? Judging by "text" + "text" thing going on :D