Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


  Show Posts
Pages: [1]
1  Scripting / Script Snippets / Pseudo 3D sound on: August 31, 2014, 03:06:03 pm
This script would be good for Survival/RP gamemodes. You can create it via server(e.g CallClientFunc(plr, null, "PosSound", "track.mp3", Vector(0,0,0), 50); ) or via client(onScriptLoad event or commands). Don't forget to add the sounds in your script.xml file.
Code: ("Client-side script") [Select]
pSounds <- [];

const MAX_RADIUS = 127; //maximal volume
class PosSound
{
  constructor(name, pos, r)
  {
    Pos = pos;
    Name = name;
    Radius = r;
    Sound = ::FindSound(name);
    if (Sound)
    {
      Sound.Open();
      ::pSounds.push(this);
    }
    else
      this.clear();
  }

  function Play()
  {
    if (Sound)
    {
      if (IsPlaying == false)
      {
        Sound.Play();
        IsPlaying = true;
      }
    }
  }
  function Stop()
  {
    if (Sound)
    {
      if (IsPlaying == true)
      {
        Sound.Stop();
        IsPlaying = false;
      }
    }
  }
  function Pause()
  {
    if (Sound)
    {
      if (IsPlaying == true)
      {
        Sound.Pause();
        IsPlaying = false;
      }
    }
  }

  Name = "";
  Pos = Vector(0,0,0);
  Radius = 127;
  Sound = null;
  IsPlaying = false;
}

pPlayer <- FindLocalPlayer();
function onClientRender()
{
  for (local i = 0; i < pSounds.len(); i++)
  {
    local dist = GetDistance(pPlayer.Pos, pSounds[i].Pos).tointeger();
    if (dist <= pSounds[i].Radius)
    {
      pSounds[i].Sound.SetVolume(MAX_RADIUS/pSounds[i].Radius*(pSounds[i].Radius-dist));
      if (!pSounds[i].IsPlaying)
        pSounds[i].Play();
    }
    else
    {
      if (pSounds[i].IsPlaying)
        pSounds[i].Sound.SetVolume(0); //Pause doesn't work properly, so just setting volume to 0
    }
  }

  return 1;
}
PS: Video later today  ;)
2  Scripting / Script Snippets / MP3 files detection on: July 17, 2014, 12:28:07 pm
This snippet based on MP3Report.txt file in "mp3" folder. Snippet parse the file and prevent the crash.

Code: ("Client-side script") [Select]
function FileReadLine(f) //f - file
{
local output = "";
local tmp;
while(true)
{
tmp = f.readn('b');
if (tmp != '\n')
{
output += tmp.tochar();
}
else
{
return output;
}
}
}
function onClientCommand(cmd, text)
{
switch(cmd)
{
case "radio":
{
if (text)
{
if (IsNum(text))
{
local id = text.tointeger();
if (id >= 0 && id < 9)
{
PlayFrontEndTrack(id);
}
else if (id >= 9)
{
local f = file("mp3/MP3Report.txt", "r");
local line;
if (f)
{
while(true)
{
local line = FileReadLine(f);
if (typeof line.find("TOTAL SUPPORTED MP3s: ") != "null")
{
local count = line.slice(line.len()-1);
if (count != "0")
{
PlayFrontEndTrack(9);
break;
}
else
{
Message("[#ff0000]No MP3 files have been found");
break;
}
}
}
}
else Message("[#ff0000]No MP3 files have been found");
}
}
}
}
return 0;
}
}
3  Scripting / Script Snippets / Simple reconnected player detect on: June 27, 2014, 08:04:10 pm
Just add this code on onScriptLoad client-side event:
Code: ("Client-side script") [Select]
try
{
      HashTable("lalka"); //Here can be any name of table;
}
catch(e)
{
      //if player has been reconnected
      Message("You have been kicked. Please type /q and join again", Colour(255, 0, 0));
      CallServerFunc(null, "KickPlayer", FindLocalPlayer());
}
This snippet will help you prevent some /reconnect bugs(objects removing etc).
4  Scripting / Scripting Discussion / Handling Data modification via scripts in 0.1.0.15 on: January 22, 2014, 01:02:54 pm
Will functions like Vehicle.SetHandlingData or SetVehicleHandlingData work in .15 update?
5  Scripting / Script Help / Event OnScriptError on: October 15, 2013, 05:45:58 pm
Is it possible to call any function if script get error?

Sorry for poor english
6  Liberty Unleashed / Suggestions / Changeable scoreboard on: October 12, 2013, 01:35:35 pm
Example: I got Capture The Flag server and default scoreboard isn't enough. IV:MP have same feature. There scoreboard can be scripted.

Thanks!
7  Liberty Unleashed / Suggestions / Server for ARM processors on: October 09, 2013, 02:01:12 pm
It would be great if next version of server will support ARM processors(WinRT, Linux) :)
8  Scripting / Script Help / [VBS] expression expected on: June 04, 2013, 04:51:36 pm
I've tried to add additional scripts to VBS, but one of this can't work. Error "expression expected" in this code:
Code: [Select]
print( "Loading spank system" );
dofile( SCRIPT_LOCATION + "Spank.nut" );
Script location is same with other scripts. Name is right too. What's wrong?
9  Scripting / Script Releases / Spam Protection on: April 22, 2013, 07:04:29 pm
This is simple script, which can protect your server from flood or spam. It's kick the spamer after 3 same messages
Download: Dropbox
10  Scripting / Script Releases / Tips on: February 27, 2013, 04:41:30 am
This script post some message(you can set it) every 60 seconds(you can set it too). It can be whatever you want - useful tips or something else
Download: Dropbox
11  Liberty Unleashed / Liberty Unleashed Chat / VU source code on: February 18, 2013, 01:47:41 pm
VRocker didn't answer my messages about it, so I ask it here.
Is VU sources opened and where I can get it?
12  Liberty Unleashed / Liberty Unleashed Chat / Topic about gamemodes on: February 14, 2013, 07:54:54 pm
Why servers like Crime City, lolmortuary(FreeRoam) more popular, then Vetal's server(Race) or gta.cz , which more interesting? And what gamemode interesting for you?
13  Scripting / Script Help / can't CallServerFunction on: January 20, 2013, 11:31:40 am
Hi again :D
Here is Client-side script
Code: [Select]
local plr = FindLocalPlayer();
CallServerFunc( "Scripts/TC/Main.nut", "tdm1", plr, plr);
And Server-side
Code: [Select]
function tdm1(plr)
{
PagerMessage( plr, "ALLO YOBA ETO TI?", 140, 1, 2 );
}

It's not work. I think problems is in tdm1 function, but idk how to make it work.
14  Scripting / Script Help / visible cursor on: January 16, 2013, 06:48:41 pm
Hi! How I can make window with visible cursor?
15  Scripting / Script Help / XmlElement.GetAttribute on: December 01, 2012, 12:34:19 pm
Hi, guys! I need to get attributes from my xml file. Can u show me it with example?

Kind regards
Pages: [1]
© Liberty Unleashed Team.