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. 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.
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:
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).
|
|
|
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:
print( "Loading spank system" ); dofile( SCRIPT_LOCATION + "Spank.nut" ); Script location is same with other scripts. Name is right too. What's wrong?
|
|
|
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
|
|
|
13
|
Scripting / Script Help / can't CallServerFunction
|
on: January 20, 2013, 11:31:40 am
|
Hi again Here is Client-side script local plr = FindLocalPlayer(); CallServerFunc( "Scripts/TC/Main.nut", "tdm1", plr, plr); And Server-side 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.
|
|
|
|