AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Mattie's Plugins (https://forums.alliedmods.net/forumdisplay.php?f=71)
-   -   Thoughts (https://forums.alliedmods.net/showthread.php?t=37936)

Cr3V3TT3 05-15-2005 19:17

Thoughts
 
Just a thought about function definition :)

A function definition wich will work like a #define (macros) in cpp and like *_var(varname) in ES.

Code:

function "myfunc" 1 "echo $1"
            |    |    |
func name ---+    |    |
func params # ----+    |
func definition -------+


As :

Code:

es_setinfo myvar "test"
es echo server_var(myvar)

is took as:
Code:

es_setinfo myvar "test"
echo test

Code:

registervar "myfunc" 1 "echo $1"
es myfunc(So guess what ? IT WORK :])

will be taken as :
Code:

registervar "myfunc" 1 "echo $1"
echo So guess what ? IT WORK :]

@Anyone Does anybody need something like this ?

@Mani It' s a good idea?
(ps : i have a lot of stuff but i can break if you want and made some tries :])

Bye,
Cr3V3TT3

Cr3V3TT3 05-16-2005 12:48

Nobody love this ? :P

... :(

Simple example :

Server.cfg
Code:

function "add" 2 "es_math $1 + server_var($2)"
Whereyouwant.cfg
Code:

es_setinfo a 15
es_setinfo b 60
es add(a b)
echo a should be 75
es echo a = server_var(a)

This is an advanced example (More what i want to use with this function^^):
Server.cfg
Code:

es_setinfo __lib_pi_vars_a 0
es_setinfo __lib_pi_vars_b 0
es_setinfo __lib_pi_vars_c 0
alias __lib_pi_r_loop_0 es_format __lib_pi_vars_a "es_setinfo Player[%1].%2" __lib_pi_vars_b __lib_pi_vars_c
alias __lib_pi_r_loop_1 es server_var(__lib_pi_vars_a)
alias __lib_pi_r_loop_2 es_math __lib_pi_vars_b + 1
alias __lib_pi_r_loop_on __lib_pi_r_loop_0;__lib_pi_r_loop_1;__lib_pi_r_loop_2
alias __lib_pi_r_loop_off
alias __lib_pi_r_doloop "__lib_pi_r_loop; if ( server_var(__lib_pi_vars_b) equalto 64 ) then alias __lib_pi_r_loop __lib_pi_r_loop_off; if ( server_var(__lib_pi_vars_b) notequalto 64 ) then __lib_pi_r_doloop"
alias __lib_pi_r_iloop "alias __lib_pi_r_loop __lib_pi_r_loop_on;__lib_pi_vars_b 0;__lib_pi_r_doloop"

function "RegisterPlayerInfo" 1 "__lib_pi_vars_c $1;__lib_pi_r_iloop"

RegisterPlayerInfo(name)
RegisterPlayerInfo(userid)

This should register 128 vars :
Player[0].name
Player[1].name
[...]
Player[63].name
Player[64].name

Player[0].userid
Player[1].userid
[...]
Player[63].userid
Player[64].userid

yeah i can do it manualy but i think use this is cool :]

ajax 05-16-2005 12:56

seems like it would be a nice feature, but i don't have any need for this right now. i'm sure when i find a way to use it, i'll want it very much.

Cr3V3TT3 05-16-2005 13:12

Quote:

Originally Posted by ajax
seems like it would be a nice feature, but i don't have any need for this right now. i'm sure when i find a way to use it, i'll want it very much.

In fact, its not realy usefull, its more for script-styling ^^

I think :
Code:

function "LoadLib" 1 "exec ES_LIB/$1.rc"

// Is greater than, less, ect..
LoadLib(Comparse)

// Run lib' s commands
LoadLib(Events)

// Player[id].{info} , require EventLink
LoadLib(PlayerInfo)

Got a better looking as :
Code:

// Is greater than, less, ect..
exec ES_LIB/Comparse.rc

// Run lib' s commands
exec ES_LIB/Events.rc

// Player[id].{info} , require "Events"
exec ES_LIB/PlayerInfo.rc

and you can do something like
Code:

function "LoadLib" 1 "echo Loading $1 Module...; exec ES_LIB/$1.rc;echo Module $1 Loaded..."

ichthys 05-16-2005 13:24

Im not really understanding all of it. Never use "cpp" or whatever that is.
I dont really have any use for it now. But like ajax said.....might later.


All times are GMT -4. The time now is 07:00.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.