karma
Moderator
Posts: 178
Likes Given: 17
Likes Received: 32 in 29 posts
Joined: Jul 2012
Reputation: 3
|
RE: Loop on tags.
If you access frequently to these values you can consider using MySQL.
The way you are suggesting (but using commas as separators instead of blank spaces) may be better than having an high number of tags, if you have a reasonable limit of chars/enemies etc so that in any case the tag won't be too long.
You can use these functions (the code can be improved, it is old and i don't use it now, i think it works though):
Code:
[FUNCTION array_get] //item, source (0 based)
IF (<ISEMPTY <ARGV[<EVAL <ARGN1>+1>]>>)
RETURN ""
ENDIF
RETURN <ARGV[<EVAL <ARGN1>+1>]>
[FUNCTION array_count]
RETURN <ARGV>
[FUNCTION array_add] //array, item to add
IF (<ARGV>==1)
RETURN <Streat <ARGV[0]>>
ENDIF
RETURN <ARGS>
[FUNCTION array_remove] //item,array, 0 based
LOCAL.AR=<STREAT <ARGS>>
FOR (<Array_Count <LOCAL.AR>>)
IF (<LOCAL._FOR>!=<EVAL <ARGV[0]>+1>)
IF !(<ISEMPTY <VAR.ARRAY>>) //note that I use vars because locals are never empty
VAR.ARRAY=<VAR.ARRAY>,<Array_Get <EVAL <LOCAL._FOR>-1>,<LOCAL.AR>>
ELSE
VAR.ARRAY=<Array_Get <EVAL <LOCAL._FOR>-1>, <LOCAL.AR>>
ENDIF
ENDIF
ENDFOR
IF (<ISEMPTY <VAR.ARRAY>>)
VAR.ARRAY
RETURN
ENDIF
LOCAL.ARRAY=<VAR.ARRAY>
VAR.ARRAY
RETURN <LOCAL.ARRAY>
[FUNCTION array_update] //item, new val, array
LOCAL.AR=<STREAT <STREAT <ARGS>>>
FOR (<Array_Count <LOCAL.AR>>)
IF (<LOCAL._FOR>!=<EVAL <ARGV[0]>+1>)
IF !(<ISEMPTY <LOCAL.ARRAY>>)
LOCAL.ARRAY=<LOCAL.ARRAY>,<Array_Get <EVAL <LOCAL._FOR>+-1>,<LOCAL.AR>>
ELSE
LOCAL.ARRAY=<Array_Get <EVAL <LOCAL._FOR>+-1>, <LOCAL.AR>>
ENDIF
ELSE
IF !(<ISEMPTY <LOCAL.ARRAY>>)
LOCAL.ARRAY=<LOCAL.ARRAY>,<ARGV[1]>
ELSE
LOCAL.ARRAY=<ARGV[1]>
ENDIF
ENDIF
IF (<LOCAL._FOR>>1000)
RETURN 1
ENDIF
ENDFOR
LOCAL.ARRAY=<LOCAL.ARRAY>
LOCAL.ARRAY
RETURN <LOCAL.ARRAY>
Anyways, take in mind that guildstones and townstones already have properties to store these values: http://wiki.sphere.torfo.org/index.php/S...wn_Members
Also, check the current code in the "stones" folder, most of the stuff regarding guild/townstones is scripted.
(This post was last modified: 01-23-2016 06:16 AM by karma.)
|
|
01-23-2016 06:11 AM |
|
The following 1 user Likes karma's post:1 user Likes karma's post
rastrero (01-23-2016)
|
Sirocco
Apprentice
Posts: 3
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Apr 2015
Reputation: 0
|
RE: Loop on tags.
make it self with sources
Code:
[FUNCTION f_arraysort]
if !strlen(<args>)
local.count = "0"
return 0
endif
if <eval((<args> / 1000) * 1000)> > 0
local.count = "<eval(<args>)>"
elseif <eval((<args> / 100) * 100)> > 0
local.count = "0<eval(<args>)>"
elseif <eval(<args> / 10)> > 0
local.count = "00<eval(<args>)>"
elseif <eval(<args> / 10)> == 0
local.count = "000<eval(<args>)>"
endif
return 1
fortags member_*
local.num = 0<local.num> + 1
plocal.char= <local._var_value>
call f_arraysort <plocal.char.tag.char_questnumber>
ptag.charexp<local.count>_<plocal.char.uid> = <plocal.char.uid>
endfor
local.place = <eval <tag.char_count> + 1>
forptags charexp*
local.place = <local.place> - 1
plocal.char= <local._var_value>
tag.temp_<eval(<local.place>)> = <plocal.char.uid>
endfor
fortags temp_*
//
endfor
|
|
02-08-2016 06:04 PM |
|
|