Forum Info Lugormod Strona Główna Info Lugormod
PSL - Polska Strona Lugormoda
 
 FAQFAQ   SzukajSzukaj   UżytkownicyUżytkownicy   GrupyGrupy   GalerieGalerie   RejestracjaRejestracja 
 ProfilProfil   Zaloguj się, by sprawdzić wiadomościZaloguj się, by sprawdzić wiadomości   ZalogujZaloguj 

Guide do JSCRIPT - T2 cz.2

 
Napisz nowy temat   Odpowiedz do tematu    Forum Info Lugormod Strona Główna -> Kursy
Zobacz poprzedni temat :: Zobacz następny temat  
Autor Wiadomość
Special
Administrator



Dołączył: 17 Lut 2007
Posty: 1006
Przeczytał: 0 tematów

Pomógł: 44 razy
Ostrzeżeń: 0/5
Skąd: Miasto Lugormoda

PostWysłany: Nie 13:41, 24 Maj 2009    Temat postu: Guide do JSCRIPT - T2 cz.2

Guide do Jedi-scripta do Lugormoda Tech-2 część 2.

Jest to nowsza wersja Jediscripta która jest na T2 2.1.5.3 lecz nie ma jej na 1.8.3

Tak jak wcześniej pokazuje możliwości, funkcje, używanie itp.


As you can see, Pipobona has made a redirection to his new forums from the ancient one.

You can't get the jscript cmds so I saved em.


v1.002.04

Jedi-Script Reference

Usage
Since I've been asked where to download jscript...
JScript isn't some external stuff you download. It's part of LMD T2. You use it by placing t2_jscript entities.
with a "file" spawnstring, containing the filename w/o extension.
The files are looked for in $fs_home/t2scripts/$filename.t2s
So if you use "file,echo_time" it will execute lugormod/t2scripts/echo_time.t2s
And this file might contain...
Code:
// month - day - year , hours : minutes
// 8-28-06, 17:26
tell time(4)." - ".time(3)." - ".time(6).", ".time(2).":".time(1);


Just use a jscript entity, with an appropriate targetname, and make a trigger target it.

Syntax
First for the types:
string = Text ("hello")
int = Integer value (132)
float = Floating point value (132.05)
mixed = Can be any of those values (this cannot be used as an actual type in your scripts...)
num = int or float (this cannot be used as an actual type in your scripts...)

Expressions
Mathematical ruleset:
Code:
factor := [NOT] var,immediate,bracket-bool-expression,text [. <bool-expression>]
term := <factor> * / % mod << >> <factor>
expression := <term> + - <term>
relation := <expression> < <= == != <> >= > <expression>
bool-term := <relation> | & ^ <relation>
bool-expression := <bool-term> AND,OR,XOR <bool-term>


% = divide by 100 and multiply (a%b == (a/100)*b)

mod = modulo - (remainder of a division)


the DOT up there, "[. <bool-expression>]" will cat strings together
"hello " . get("netname") . ", you're happy."

+, -, *, / simply add, subtract, multiply and divide.
<<, >> do binary shifts
& is a bitwise AND operator.
| is a bitwise OR operator.
^ is a bitwise XOR operator.
AND means both <relation>s must be not-null (true)
OR means either of them has to be true
XOR means exactly ONE of them has to be true (exclusive or)
mod means MODULO, it returns the remainder of the division 25 mod 11 is 3
<, <=, ==, >=, > compare 2 <bool-term>s, to see if one is less, less or equal, equal, greater or equal, or just greater
!= and <> are the same, both mean NOT-equal (but please stick to !=)

what does bitwise stuff do?
If you want to know if 2 expressions are true, or one of them, then you use AND, OR, XOR
But theoratically you can use & | and ^ too, the difference is:
AND OR and XOR only compare, and return 1 or 0, &, | and ^ will calculate a value, just like + and - do.
(stick to AND and OR when just comparing stuff)
&, | and ^ check each bit of the numbers, and set the bits, like when using AND, OR and XOR on each and every bit.
You can use this to combine FLAG numbers (like g_forcePowerDisable), or check if certain bits are set, or just change certain bits.
Code:
00010100 00101101 00100001
& 00010001 | 00000010 ^ 00001001
---------- ---------- ----------
= 00010000 = 00101111 = 00101000


Accessing single characters of strings:
You can get characters of a string using the operator[]. You canNOT assign them!.
int second_char = some_string[1]; OK!
some_string[1] = 'x'; NOT OK!

Defining vars
There are 2 types of vars: 1) global 2) local
global vars are defined once, and can then be used by any script executed.
local vars only exist within the current script.
generally it looks like this:
Code:
local varName;
global type varName;
local type varName = initial_value;
global type varName = initial_value;

When defining a global var with an initial value, the expression for this initial value will be ignored if the global var already exists. So you define a global a = 25; and can use it in any script. When it's value is changed, and the script defining global a = 25; is executed again, a WILL NOT be reset to 25.
Therefore, if you cannot be sure if a var has been initialized, it is best to put the global definition of all the used vars in a script right on top of that script, to make sure that if the vars aren't defined yet because the script which should define them has not been executed yet, they are still defined and usable.
Or you make one big script defining all the globals, and make sure that this one is executed as the very first script.

So here's an example of defining vars and using them:
Code:
local int a = 5;
local int b = 3;
local int c = 5*a + 3*b - 2;
// result of c is 32


Conditionals (if, elseif, else, endif)
Let's say we want to know if c is really 32, therefore we use the IF statement.
Code:
if <bool-expression 1> then
code 1
elseif <bool-expression 2> then
code 2
elseif <bool-expression 3> then
code 3
...
...
else
code x
endif

It is not necessary to use the elseif, you can use as many of them as you want.
So this means: if the <bool-expression 1> is not null, then code 1 is executed.
Otherwise, if it's null (false), but <bool-expression 2> is true, then code 2 is executed, and so on...
If none of these expressions is true, then the code x is executed, which is also optional.

So let's check our result:
Code:
local int a = 5;
local int b = 3;
local int c = 5*a + 3*b - 2;
// result of c is 32
if c == 32 then
echo "Right, c = " . c;
else
echo "!?";
endif

Or just
Code:
local int a = 5;
local int b = 3;
local int c = 5*a + 3*b - 2;
// result of c is 32
if c == 32 then
echo "Right, c = " . c;
endif

You can of course check for more conditions at once, combining them with AND, OR, or XOR
Code:
if a == 3 AND b > 5 AND c then ...


Loops (while, do, done)
If you want to execute a code until a certain condition is met, you use 'while'
it works like this:
Code:
while <bool-expression> do
code
done


Command Usage
You can execute a command directly, without brackets:
command arg1, arg2, arg3;
Or within an expression, but with brackets then:
echo get("health");
Since your scripts can also return values, you could do something like
echo runscript("whatever");

Commands
mixed runscript(string scriptfile)

Executes the give scriptfile.

echo(string text)

Prints out a text, like when using /rcon echo

int isset(string script_var)

Returns 0 if the given script_var does not exist, 1 if it's a global var, 2 if it's a local var.

print(string format, ...) Deprecated... Use if you want hex values

Prints a text in C Style printf (Only knows %i, %s, %f and %x)

tell(string text)
tell(int player, string text) v1.002.04
tell(string player, string text) v1.002.04

Tells a text to the current "victim" of the script. (it's echoed. to imitate an actual /tell cmd use chat with the appropriate style.)

tellf(string format, ...) --(same as for print)--

Like print, but tells like tell

set(string varname, mixed value)

Sets the current victim's var to the given value. A list of vars can be found below

mixed get(string varname)

Gets the current victim's varname-var.

load(string varname, string script_varname)

Loads the victim's varname-var into a global or local scriptvar with script_varname name - TEXT! Don't forget the "s

setother(mixed entity, string varname, mixed value)

Like set. If entity is of type text, it's treaten like a client-name, if it's an int, it's the entity-number.

mixed getother(mixed entity, string varname, mixed value)

Like get, works like setother.

loadother(mixed entity, string varname, string script_varname)

Like load, wirks like setother.

settarget(string targetname, string varname, mixed value)

Like set, but sets for every entity with the matching targetname.

mixed gettarget(string targetname, string varname)

Like get, works like settarget. Sets LERROR to 1 if no entity matches the targetname.

loadtarget(string targetname, string varname, string script_varname)

Like load, works like gettarget (also uses LERROR)

int IsValidClient(int clientNum)

Checks if the given client-number refers to a valid gameclient.

usetarget(string targetname)

Use every entity with the matching targetname

freeglobal(string script_varname)

Free the global with script_varname as name. Remember, you cannot have infinite global vars.

changelight(int index, string Rfunc, string Gfunc, string Bfunc)

Changes the lightstyle index to have the given values. Lightstyle 0 is the one you see. The others can be swaped by the engines normal light entities. There are styles 0 to 13 only!
Xfunc values are strings, which are looped through quite fast. a is null, black. z is bright, day. If you use only one letter the light is constant, otherwise it's going through the letters. Using something like "qrstuvwxyzyxwvutsrq" would be fading from a bit dark, to bright. You can use different values for RED, GREEN and BLUE in order to mix them however you want.

rcon(string command1[, string command2, ...])

Execute the given commands on the server, like when using rcon. You can either seperate the commands by a semicolon, or just add other commands as another argument to the function, that way you can avoid calling this function more than once in a row.

rangedmg(float range, float damage)
rangedmg(string targetname, float range, float damage)
rangedmg(int X, int Y, int Z, int range, int damage)

Do a radius-damage from the inflictor's origin, the entities with the matching targetnames, or the given X Y Z origin.

damage(int damage)
damage(int entitynum, int damage)
damage(string targetname, int damage)

Damage either the victim, a given entity by number, or a given entity by its targetname.

delent(string targetname)
delent(int entnumber)

Remove the entity with the matching targetname, or the given entity-number

string CleanName(string text)

Returns the cleaned text, strips color-codes etc. just like accounts are saved

chat(string text)
chat(int toNumber, string text)
chat(string toPlayername, string text)

Print a text in the chatbox to the given number/player, or the current 'victim'. Use number -1 to send it to everyone.

announce(string text)
announce(int toNumber, string text)
announce(string toPlayername, string text)

Print a text as announcement to the given number/player, or the current 'victim'. Use number -1 to send it to everyone.
Unlike in lugormod's announce cmd, you don't add any time here.

int random(int min, int max)

Return a random number (min <= x <= max) (min and max included)

exit(mixed returnval)
return(mixed returnvalue)

Exit the current script, and return the given value.

int findtarget(int currentNum, string targetname) DEPRECATED!!!

Returns the number of the next entity after currentNum that matches the targetname. LERROR is set to 1 if no other entity after currentNum matches the targetname.
Change: Returns 0 if nothing else was found.

string char(int number)

Converts an integer between 0 and 256 (between!) into it's ascii value.

q3set(int taskID, string setType, string data)
q3set(mixed ent, int taskID, string setType, string data)
q3setplayer(mixed player, int taskID, string setType, string data)

Does Q3_Set on an entity/player given by an integer number, or on a targetname (or playername with q3setplayer).
If no entity is given, it uses the current 'victim'
Click HERE for a Q3-Set List

int toint(mixed value)
float tofloat(mixed value)
string tostring(mixed value)

Converts <value> into the return type.

float scanfloat(string txt, int component)
int scanint(string txt, int component)

Returns the component of a series of 4 floats or ints.
eg.: scanfloat("4.0 6.0 2.3 5.92", 3) returns 2.3
scanint("5 6 7 8", 2) returns 6

teleport(string coord_vec3)
teleport(int cnum, string coord_vec3)
teleport(string playername, string coord_vec3)
teleport(int x, int y, int z)
teleport(int cnum, int x, int y, int z)
teleport(string playername, int x, int y, int z)

Teleports a player or the victim to the given coords. string coord_vec3 means a string like: "-30 594 118".

int fsopen(string filename)
int fsopen(string filename, int mode)

Opens a file and returns a jscript internal filehandle. If mode is NOT NULL the file is opened for writing, otherwise it's opened for reading.
Returns -1 and sets LERROR if too many file-handles are opened. You can only have 8 active filehandles during one script.
Unclosed filehandles are closed at the end of the script. You should still close them manually.

int fsclose(int handle)

Closes a filehandle.

string fsreadline(int filehandle)

Reads one line of a file and returns a string (of max. 255 characters).
Sets LERROR on errors.

fswriteline(int handle, string line)

Writes the given line to the given file (with a newline character at the end

fswriteword(int handle, string text)

same as writeline but doesn't add the \n newline.

string strtok(string text, string delimiter_list)
string strtok(0, string delimiter_list)

This one is a lil more complicated. It uses the C strtok() function.
When used with a TEXT string, it makes an internal copy of that string and returns the token until one of the delimiters is found. ALWAYS.
To get the NEXT token, call it with a 0 (null) as first argument.

string substr(string text, int start);
string substr(string text, int start, int length);

Returns a substring of the 'text' string, starting at start (where 0 is the first letter), with the given length (if any).

int strlen(string text)

This will open a portal from the game into your real-life house and flood it with tooth-brushes.

string trim(string text)
string trim(string text, 0) // left
string trim(string text, not null) // right

This will remove spaces, tabs, newlines and carriage-returns of the given string. With one argument, this will be done on both sides of the string. If the second argument is 0 (null), it will only do this on the left side, otherwise it will be the right side of the string.

give_credits(int credits)
give_credits(int to, int credits)
give_credits(string toPlayerName, int credits)

Gives credits to a player or the current victim.

int time(int component)

Returns one of those time-components:
0 = seconds (0-59)
1 = minutes (0-59)
2 = hours (0-23)
3 = day (1-31)
4 = month (1-12)
5 = year (2006)
6 = year (06) = substr(time(5), 2, 2)
7 = weekday (1-7)
8 = yearday (1-366)
9 = daylight savings time flag (0 or 1)
10 = level-milliseconds

int spawn(string spawnstring) (fix)v1.002.04

Spawns an entity. Returns the entity's number.

playfx(string origin, string angles, string fxfile)
playfx(string origin, num pitch, num yaw, num roll, string fxfile)
playfx(num x, num y, num z, string angles, string fxfile)
playfx(int x, int y, int z, int p, int y, int r, string fxfile)

Plays an EFX at the given position with the given angles.

useent(int num[,int num...])

Use those entities (by numbers).

int findclass(int currentNum, string classname) DEPRECATED!!!

Returns the number of the next entity after currentNum that matches the classname. LERROR is set to 1 and it returns 0 if no other entity after currentNum matches the targetname.

int findvar(int currentNum, string varname, string targetname) (USE INSTEAD OF findtarget OR findclass)

Returns the number of the next entity after currentNum that matches the targetname.
If no other entity is found it returns 0 and sets LERROR to 1.
It only accepts varnames of a stringpointer type. (Not every string is a pointer - there'll be a list of them.)

int setvar(string jsvarname, mixed value, int global)
mixed getvar(string jsvarname)

This sets a jscript var, like when using "local int blah" or "global string blah".
What's it good for then? Simple: You can "emulate" arrays, by concatenating strings and ints and use that as varname.
setvar("saved_weapons" . victim, get("weaponas"), qtrue);
This for example would create a var saved_weapons1 if client # 1 is the victim.
Then you can do: getvar("saved_weapons" . victim); to get it again.

int changeweapon(int weapon)

Changes the victim's weapon and returns 1 on success.

string cvars(string cvarname)
int cvari(string cvarname)
float cvarf(string cvarname)
cvarset(string cvarname, string value)

Get or set the value of the specified Cvar (not JS var, server CVar).

string info_value(string infostring, string keyname)

Get the key called 'keyname' of the given 'infostring'.
Infostrings have this format: "key\value\key\value...". There may be a leading backslash.

string info_set(string infostring, string keyname, string value)

Sets the given key to the given value, and returns the new infostring. The infostring provided as argument 1 is NOT changed.

int pay(int credits)
int pay(int player, int credits)
int pay(string player, int credits)

If the player can afford this amount of credits, he does so, and the function returns 1.
Otherwise the function returns 0.

activate()
activate(mixed entity)
deactivate()
deactivate(mixed entity)

Activates or deactivates the inflictor, or the given entity. Accepts targetnames and entitynumbers.



Remember to set LERROR to NULL again after handling an error:
LERROR = 0;

Usage example of findtarget:
Code:
// Kill All some_turrets:
local int things = 32; // 0 to 31 are players, they won't ever have targetnames

things = findvar(things, "targetname", "some_turrets");
while things != 0
// damage things, 1000; // Just set it... it might have more than 1K hp XD
setother things, "health", 0;
things = findvar(things, "targetname", "some_turrets");
done


More commands will follow...

Constants and Built-in read-only vars:
int time

Current Game-Time

int VERSION

Current version: 100204 (1.002.04)

int victim

Entity-number of the current victim of the script.

int inflictor

Entity-number of the current inflictor of the script.

int g_entities

Pointer to the start entity. Only necessary when calculating a number from a pointer like lastAttacker

int MAX_CLIENTS

Max. possible number of clients for a server. Should be 32 Razz

int LERROR

NOT READ-ONLY - Used by some functions to indicate that something went wrong. 0 if NO error occured. This var is NOT SET if a Syntax error in your script, or an INVALID argument for a function has been given if it is not said so in the function's description!


Weapons:
WP_STUN_BATON, WP_MELEE, WP_SABER, WP_BRYAR_PISTOL, WP_BLASTER, WP_DISRUPTOR, WP_BOWCASTER, WP_REPEATER
WP_DEMP2, WP_FLECHETTE, WP_ROCKET_LAUNCHER, WP_THERMAL, WP_TRIP_MINE, WP_DET_PACK, WP_CONCUSSION
WP_BRYAR_OLD, WP_EMPLACED_GUN, WP_TURRET
<--- VERSION >greater< 1.001.02 ----
WP_NUM_WEAPONS
Forcepowers:
FP_FIRST, FP_HEAL, FP_LEVITATION, FP_SPEED, FP_PUSH, FP_PULL, FP_TELEPATHY, FP_GRIP, FP_LIGHTNING,
FP_RAGE, FP_PROTECT, FP_ABSORB, FP_TEAM_HEAL, FP_TEAM_FORCE, FP_DRAIN, FP_SEE,
FP_SABER_OFFENSE, FP_SABER_DEFENSE, FP_SABERTHROW,
NUM_FORCE_POWERS
---- END OF VERSION > 1.001.02 --->
Holdable items:
HI_SEEKER, HI_SHIELD, HI_MEDPAC, HI_MEDPAC_BIG, HI_BINOCULARS, HI_SENTRY_GUN
HI_JETPACK, HI_HEALTHDISP, HI_AMMODISP, HI_EWEB, HI_CLOAK
Powerups:
PW_QUAD, PW_BATTLESUIT, PW_PULL, PW_REDFLAG, PW_BLUEFLAG, PW_NEUTRALFLAG, PW_SHIELDHIT, PW_SPEEDBURST
PW_DISINT_4, PW_SPEED, PW_CLOAKED, PW_FORCE_ENLIGHTENED_LIGHT, PW_FORCE_ENLIGHTENED_DARK, PW_FORCE_BOON
PW_YSALAMIRI note: there's no pw_ysalImAri
The WP_ and HI_ and PW_ vars up there are in correct order, starting by value 1, counting upwards.

Client-Vars for SET/GET/LOAD
pointer type: Use ((pointervar - g_entities)/4) to get it's entity-number
Code:
int clientnum = The client's number; (Use entitynum instead please )
int entitynum = The entity's number (same as clientnum);
int health;
int maxHealth; <- use stat_max_health for things with a playerstate
// What has a player-state? every player-like thing... clients, npcs, bots, creatures...
// i think this maxHealth only works for things like turrets?
// Since you need a maximum and not just a health to make the client show the correct percentage-line
// *looks in the code* ... Yea turrets use this

string netname; // Client's name (with color-codes)
string classname;
string NPC_type;
string NPC_target;
string NPC_targetname;
string target;
string target2;
string target3;
string target4;
string target5;
string target6;
string targetname;
float minsx;
float minsy;
float minsz;
float maxsx;
float maxsy;
float maxsz;
// JS: VERSION => 100102 (greater 2.1.6) {
float absminsx;
float absminsy;
float absminsz;
float absmaxsx;
float absmaxsy;
float absmaxsz;
int spawnflags;
// } END
int damage;
int splashDamage;
int splashRadius;
int count;
int delay;
float radius;
float random;
float wait;
int damageRedirect; // if 1, the entitie's damage is redirected to:
int damageRedirectTo; // entitynum to which the damage is redirected
float mass;
string message;
float speed;
pointer chain; // dunno
pointer enemy; // dunno
pointer lastEnemy; // Guess that's !sometimes! set to the last attacker?
pointer activator; // Activator, for buttons i guess?
pointer teamchain; // Guess it points to the next team-member
pointer teammaster; // Guess that's the team-leader in siege or sommat?
float gravity;
int jetpackFuel;
// { FIX in 1.002.04:
float originX; // do toint() with these values!
float originY;
float originZ;
float p.originX; // "player" originX (just for completion)
float p.originY;
float p.originZ;
// } END
float velocityX;
float velocityY;
float velocityZ;
float moveDirX;
float moveDirY;
float moveDirZ;
float speed;
string jscript; // script-file executed if the entity/the player dies or for items, if they're picked up
string jscript_die; // ... wait a minute, that's for death
int credits;

// Following are all of type INT: (vars prefixed with '_' are just there to have it complete)
// They are either useless or hard to use (only for ppl who know the engine code a bit)
score, team, spawncount, _playerevents, attacker, attackee_armor
hits = total inflicted damage
deathcount
award_impressive, award_excellent, award_defense, award_assist,
gauntlet_frag_count,
captures,
// Powerups, to set, do set "pw_blah", TIME + milliseconds-you-want
pw_quad
pw_battlesuit
pw_pull
pw_redflag
pw_blueflag
pw_neutralflag
pw_shieldhit
pw_speedburst
pw_disint_4
pw_speed
pw_cloaked
pw_force_enlightened_light
pw_force_enlightened_dark
pw_force_boon
pw_ysalimari, pw_ysalamiri <- both possible, since even in the original source code they use both names ...
// Ammunition
ammo_force, ammo_blaster, ammo_powercell, ammo_metal_bolts, ammo_rockets, ammo_emplaced
ammo_thermal, ammo_tripmine, ammo_detpack
<--- VERSION >greater< 2.1.5 ----
int forcePowersKnown (bitfield)
int forcePowersActive (bitfield)
int fp_level_first
int fp_level_heal
int fp_level_levitation
int fp_level_speed
int fp_level_push
int fp_level_pull
int fp_level_telepathy
int fp_level_grip
int fp_level_lightning
int fp_level_rage
int fp_level_protect
int fp_level_absorb
int fp_level_team_heal
int fp_level_team_force
int fp_level_drain
int fp_level_see
int fp_level_offense
int fp_level_defense
int fp_level_throw
int fp_duration*** (<- same as above, for duration)
<-- with VERSION >= 100103(plugged)
float absminx
float absminy
float absminz
float absmaxx
float absmaxy
float absmaxz
int genericInt1
... ( genericInt2, 3, 4....) until:
int genericInt15
// { v1.002.04
string GenericString1
...
string GenericString10
- Those strings are virtual strings, which use the GenericInts (genericValue spawnstring)
- Use at own risk... they might simply crash you if you haven't set them!
string vstring1
...
string vstring15
// } END


int svflags
int flags
int constantlight
float pos1x, pos2x
float pos1y, pos2y
float pos1z, pos2z
int moverstate
---- END OF VERSION >2.1.5 --->
stat_health <- "health" works fine... this is just to have it complete
holdable_item <- guess this is the current chosen item
holdable_items <- item bit value
persistant_powerup
weapons <- weapon bit-value, OR (1<<WP_*constants) to it (set "weapons", get("weapons") | (1<<WP_ROCKET_LAUNCHER) (holdables work the same way)
armor, dead_yaw, clients_ready
stat_max_health


Q3 Set

q3set[player] ( [mixed ent,] int taskID, string setType, string data )

Here's a list for the SET_ types + data:
SET_ORIGIN, "x y z"

Changes the entity's origin. x y and z are floating point values in C style.

SET_TELEPORT_DEST, "x y z"

Copies passed origin to ent running script once there is nothing there blocking the spot.
Sets Task to TID_MOVE_NAV.

SET_COPY_ORIGIN, "targetname"

Copies the target's origin and viewangles to the entity.

SET_ANGLES, "pitch yaw roll"

Sets the entity's viewangles. Yaw, pitch and roll are floating point values in C syle.

SET_XVELOCITY, "speed"
SET_YVELOCITY, "speed"
SET_ZVELOCITY, "speed"

Sets the entity's X, Y or Z velocity. Speed is are again C-Style floating point values.

SET_Z_OFFSET, "float"

Lerps the Z Offset. (Do not use on clients or target_scriptrunners)

SET_ENEMY, "targetname"

Sets the entity's gentity_t *enemy to be the current target. "NONE" or "NULL" as targetname will set the it to NULL.

SET_LEADER, "targetname"

Sets the entity's gentity_t *leader pointer. Use only on clients (or NPCs).

SET_NAVGOAL, "refname"

Sets the entity's nav goal to the reference-TAG-Name. (Yup pipo, this should move their asses :> )
Sets Task = TID_MOVE_NAV

SET_ANIM_UPPER, "animname"
SET_ANIM_LOWER, "animname"
SET_ANIM_BOTH, "animname"

Sets the entity's torso, leg or both animation. You can find an animation list here.
Sets Task = TID_ANIM_UPPER/LOWER or both :>

SET_ANIM_HOLDTIME_LOWER, "int"
SET_ANIM_HOLDTIME_UPPER, "int"
SET_ANIM_HOLDTIME_BOTH, "int"

Sets the animation-hold-time. (Doesn't accept hex or float values.)
Sets Task = TID_ANIM_LOWER/UPPER or both

SET_HEALTH, "int"

Guess what... IT SPAWNS AN UFO WHICH TELEPORTS YOU RIGHT INTO THE GAME!!!

SET_ARMOR, "int"

Sets the size of the ent's titts!

SET_BEHAVIOR_STATE, "behaviourname"

Changes the behaviour state, whatever that would do... Possible names:
BS_DEFAULT
BS_ADVANCE_FIGHT - advance to captureGoal and shoot enemies if you can
BS_SLEEP - Play awake script when startled by sound
BS_FOLLOW_LEADER - ...and shoot any enemies you come across
BS_JUMP - Face navgoal and jump to it
BS_SEARCH - Using current waypoint as base, search the immediate branches of waypoints for enemies
BS_WANDER - Walk around like a drunken prick... random waypoint paths...
BS_NOCLIP - Moves through walls, also through UFOs, and even through march-mellows!!!
BS_REMOVE - Waits for the player to leave PVS then removes itself
BS_CINEMATIC - Don't ask me... blah :>
Sets Task = TID_BSTATE

SET_DEFAULT_BSTATE, "behaviourname"

Sets the default BS.

SET_TEMP_BSTATE, "behaviourname"

Sets a temp bstate.
Sets Task = TID_BSTATE

SET_ICARUS_FREEZE/UNFREEZE, "targetname" or "scriptname"

Freezes the targetname... If u use icarus stuff Smile

SET_WEAPON, "weaponname"

Sets (and gives if necessary) the weapon and switches to it.
NULL, WP_NONE, WP_STUN_BATON, WP_MELEE, WP_SABER, WP_BRYAR_PISTOL, WP_BLASTER_PISTOL,
WP_BLASTER, WP_DISRUPTOR, WP_BOWCASTER, WP_REPEATER, WP_DEMP2, WP_FLECHETTE, WP_ROCKET_LAUNCHER,
WP_THERMAL, WP_TRIP_MINE, WP_DET_PACK, WP_CONCUSSION, WP_BRYAR_OLD, WP_EMPLACED_GUN, WP_TURRET

SET_WALKSPEED, "int"
SET_RUNSPEED, "int"

Changes the entity's walk/runSpeed. And gives you some pie.

SET_GRAVITY, "float"

Sets the entity's personal gravity. HAH, gotcha!

SET_WAIT, "float"

Sets the ent's wait value. For whatever that's good.

SET_SCALE, "float"

Scales a player. 1.0 = 100% You know...

SET_COUNT, "int"

Sets the ent's count value. Like when u use count,somevar in /place.

SET_NOTARGET, "false" or "true"

You know the chat...

SET_TIMESCALE, "value"

Sets the "timescale" CVar. Yep, the cheatprotected one! Wink

SET_LOOPSOUND, "soundfile"

Sets the ent's loopsound... Let's make our players sing!!!

SET_TARGETNAME, "targetname"
SET_TARGET, "blah"
SET_TARGET2, "blah"
(no, there's no 3, 4, ...)

This sets the lenght of the ent's penis.

SET_PARM1, "data"
SET_PARM2..16, "data"

Sets the "parm"... For whatever you need that... Like in /place... parm1,blah,parm2,blah...

SET_SPAWNSCRIPT, "name"
SET_USESCRIPT
SET_AWAKESCRIPT
SET_ANGERSCRIPT
SET_ATTACKSCRIPT
SET_VICTORYSCRIPT
SET_PAINSCRIPT
SET_FLEESCRIPT
SET_DEATHSCRIPT
SET_DELAYEDSCRIPT
SET_BLOCKEDSCRIPT
SET_FFIRESCRIPT
SET_FFDEATHSCRIPT
SET_MINDTRICKSCRIPT

Sets the scripts... for Icarus stuff i guess? Dunno... whatever...

SET_WALKING, "true" or "false"

Sets the SCF_WALKING script flag.

SET_INVINCIBLE, "true" or "false"

Godmode...

SET_NO_AVOID, "true" or "false"

Set the NPCAI_NO_COLL_AVOID flag.

SET_SOLID, "true" or "false

Sets the ent's solidity.

SET_INVISIBLE, "true" or "false"

Switches your gender...

SET_PLAYER_USABLE, "true" or "false"

Sets the ent's usability.

SET_SABERACTIVE, "true" or "false"

Toggles the ent's saber... if it has one Razz

SET_INACTIVE, "true" or "false", or "unlocked" or "locked"

Sets the FL_INACTIVE flag, locks or unlocks a mover.

SET_FUNC_USABLE_VISIBLE, "true" or "false"

Sets the SVF_NOCLIENT and the EF_NODRAW flags. Well... U can hide buttons with it Very Happy

SET_NO_KNOCKBACK, "true" or "false"

Can you knock back that guy?

SET_FULLNAME, "name"

Sets the ent's fullName var.

SET_FORCE_HEAL_LEVEL, "int"
SET_FORCE_JUMP_LEVEL
SET_FORCE_SPEED_LEVEL
SET_FORCE_PUSH_LEVEL
SET_FORCE_PULL_LEVEL
SET_FORCE_MINDTRICK_LEVEL
SET_FORCE_GRIP_LEVEL
SET_FORCE_LIGHTNING_LEVEL
SET_SABER_THROW
SET_SABER_DEFENSE
SET_SABER_OFFENSE

Sets the size of the entity's ears and nose.




Not available in MP: (You should ask robo to include some... like VIEWTARGET, that should be ease...
SET_PLAYER_TEAM, SET_ENEMY_TEAM, SET_CAPTURE, SET_DPITCH, SET_DYAW, SET_EVENT, SET_VIEWTARGET
SET_WATCHTARGET, SET_VIEWENTITY, SET_ITEM, SET_WIDTH, SET_YAWSPEED, SET_AGGRESSION
SET_AIM, SET_FRICTION, SET_FOLLOWDIST, SET_SHOT_SPACING, SET_IGNOREPAIN, SET_IGNOREENEMIES
SET_IGNOREALERTS, case SET_DONTSHOOT, SET_DONTFIRE, SET_LOCKED_ENEMY, SET_LEAN, SET_SHOOTDIST
SET_VISRANGE, SET_EARSHOT, SET_VIGILANCE, SET_VFOV, SET_HFOV, SET_LOCATION,SET_PAINTARGET
SET_DEFEND_TARGET, SET_NO_MINDTRICK, SET_CINEMATIC_SKIPSCRIPT, SET_DELAYSCRIPTTIME, SET_CROUCHED
SET_RUNNING, case SET_CHASE_ENEMIES, SET_LOOK_FOR_ENEMIES, SET_FACE_MOVE_DIR, SET_ALT_FIRE
SET_DONT_FLEE, SET_FORCED_MARCH, SET_NO_RESPONSE, SET_NO_COMBAT_TALK, SET_NO_ALERT_TALK
SET_USE_CP_NEAREST, SET_NO_FORCE, SET_NO_ACROBATICS, SET_USE_SUBTITLES, SET_NO_FALLTODEATH
SET_DISMEMBERABLE, SET_MORELIGHT, SET_UNDYING, SET_VAMPIRE, SET_FORCE_INVINCIBLE, SET_GREET_ALLIES
SET_PLAYER_LOCKED, SET_LOCK_PLAYER_WEAPONS, SET_NO_IMPACT_DAMAGE, SET_FORWARDMOVE, SET_RIGHTMOVE
SET_LOCKYAW, SET_CAMERA_GROUP, SET_CAMERA_GROUP_Z_OFS, SET_CAMERA_GROUP_TAG, SET_LOOK_TARGET
SET_ADDRHANDBOLT_MODEL, SET_REMOVERHANDBOLT_MODEL, SET_ADDLHANDBOLT_MODEL, SET_REMOVELHANDBOLT_MODEL
SET_FACEEYESCLOSED, SET_FACEEYESOPENED, SET_FACEAUX, SET_FACEBLINK, SET_FACEBLINKFROWN, SET_FACEFROWN
SET_FACENORMAL, SET_SCROLLTEXT, SET_LCARSTEXT, SET_CAPTIONTEXTCOLOR, SET_CENTERTEXTCOLOR
SET_SCROLLTEXTCOLOR, SET_STARTFRAME, SET_ENDFRAME, SET_ANIMFRAME, SET_LOOP_ANIM, SET_INTERFACE
SET_SHIELDS, SET_ADJUST_AREA_PORTALS, SET_DMG_BY_HEAVY_WEAP_ONLY, SET_SHIELDED, SET_NO_GROUPS
SET_FIRE_WEAPON, SET_END_SCREENDISSOLVE, SET_MISSION_STATUS_SCREEN, SET_VIDEO_PLAY
SET_VIDEO_FADE_IN, SET_VIDEO_FADE_OUT, SET_REMOVE_TARGET, SET_LOADGAME, SET_MENU_SCREEN
SET_OBJECTIVE_SHOW, SET_OBJECTIVE_HIDE, SET_OBJECTIVE_SUCCEEDED, SET_OBJECTIVE_FAILED
SET_OBJECTIVE_CLEARALL, SET_MISSIONFAILED, SET_MISSIONSTATUSTEXT, SET_MISSIONSTATUSTIME
SET_CLOSINGCREDITS, SET_SKILL, SET_DISABLE_SHADER_ANIM, SET_SHADER_ANIM, SET_MUSIC_STATE
SET_CLEAN_DAMAGING_ENTS, SET_HUD


Updated - I saved the conditional tutorial too!

But it was so long so I put it here

Conditional tutorial
1) Storing data in entities
2) Storing data in global vars with variable names
3) Storing data in info-strings



1) Storing data in entities

The Quake3/JKA engine provides many many variables for its entities. Not all of them are used all the time, and lugormod provides even more variables. A common way to save values are the generic-values: GenericValue1 to GenericValue15 and, in LMD T2, GenericString1 to GenericString10.
The GenericValues are called GenericInts in JScript, since they are integers, and because the JScript plugin provides virtual strings, assigned TO the generic integers: vstring1 to vstring15.
Those will make the integers point to strings. This can be fatal though!
When I was working on my Pazaak-Script, it caused random crashes, and it took me quite some time to figure out the problem:
I was using the entity's GenericInt1 to store the first player's number, and also, used vstring1 to store the global variable prefix. (In section 2 you'll learn what the prefix is good for.)

So what's the problem? Easy: GenericInt1 and vstring1 use the same physical data in memory, and so the playernumbers screwed up my string pointers. AND! JScript couldn't even print out the error that vstring1 was not set, since it was set to a "random" value, (the player's clientnumbers).
Stupid, eh?

So, some things to remember:
When using the generic values, make sure things like that don't happen.
If you still get random crashes, or random behaviour by the entity, it could be that the game itself uses the same variables as you use.
An example: t2_terminal uses GenericStringX for its cmdX spawnvars.
So you cannot use the GenericStrings to set information for it.
Keep that in mind :>
The HOW is easy:
Code:
setother inflictor, "some_variable", the_value;
getother inflictor, "some_Variable", the_value;

The inflictor is the entity causing the jscript to run, not the t2_jscript entity, but the button targetting it. Smile



Storing data in global vars with variable names

Of course you know global variables.
They're global, keep their values, not only in one script, but can be used in ANY script after they've been declared.
That's good, but not for storing INDIVIDUAL data for players or entities!
That's why I added the functions setvar() and getvar():


[/list]int setvar(string jsvarname, mixed value, int global)
mixed getvar(string jsvarname)

This sets a jscript var, like when using "local int blah" or "global string blah".
What's it good for then? Simple: You can "emulate" arrays, by concatenating strings and ints and use that as varname.
setvar("saved_weapons" . victim, get("weaponas"), qtrue);
This for example would create a var saved_weapons1 if client # 1 is the victim.
Then you can do: getvar("saved_weapons" . victim); to get it again.



Got it?
If you want to store data for individual entities, you can prefix the vars with their entity number, or if you want to "group" some entities, set GenericStringX to a prefix which should be used by those entities.


Code:
local string myGroup = getother(infictor, "GenericString15");
if NOT isset(myGroup."_my_client")
then
// FIRST one using the door is the owner
setvar myGroup."_my_client", victim, 1;
else
if victim != getvar(myGroup."_my_client")
then
tell "You're not allowed to get in!";
else
tell "Access granted.";
usetarget "open_door_the_door";
endif
endif


3) Storing data in info-strings

What are infostrings?
In quake3, infostrings are used for instance, to send the client's profile to the server.
They're the reason why you cannot use backslashes in your names, because of their format:
key\value\key\value
Like this: name\Blµb\saber1\kyle\saber2\none
See the problem if i had a backslash in my name?


string info_value(string infostring, string keyname)

Get the key called 'keyname' of the given 'infostring'.
Infostrings have this format: "key\value\key\value...". There may be a leading backslash.

string info_set(string infostring, string keyname, string value)

Sets the given key to the given value, and returns the new infostring. The infostring provided as argument 1 is NOT changed.


Nice, eh?

So you can use this to store different values, in one global var, and combine that with what you learned in section 2, it can be very powerful. For the next sample code we need the casting-functions:


int toint(mixed value)
float tofloat(mixed value)
string tostring(mixed value)

Converts <value> into the return type.


Those will be used to turn the "string" info values into whatever we want:
Code:
local string myGroup = getother(infictor, "GenericString15");
if NOT isset(myGroup."_my_data")
then
setvar myGroup."_my_data", "client\\-1\\time\\0";
endif

local string data = getvar(myGroup."_my_data");
local int client = toint(info_value(data, "client"));

if client == -1
OR toint(info_value(data, "time")) < TIME
then
data = info_set(data, "client", victim);
// the door is owned by the first one using it, for 50 minutes, then it some new player can have it
data = info_set(data, "time", TIME+50*60*1000);
elseif client == victim
tell "Access granted!";
usetarget myGroupd."_door_trigger";
else
tell "Access denied!";
endif


Post został pochwalony 0 razy
Powrót do góry
Zobacz profil autora
Wyświetl posty z ostatnich:   
Napisz nowy temat   Odpowiedz do tematu    Forum Info Lugormod Strona Główna -> Kursy Wszystkie czasy w strefie EET (Europa)
Strona 1 z 1

 
Skocz do:  
Możesz pisać nowe tematy
Możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach

fora.pl - załóż własne forum dyskusyjne za darmo
Powered by phpBB © 2001, 2005 phpBB Group
Regulamin