The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop on tags.
Author Message
rastrero
Master
**

Posts: 250
Likes Given: 41
Likes Received: 28 in 24 posts
Joined: Jan 2016
Reputation: 3



Post: #1
Loop on tags.
Hi
Need to know something


Imagine i got all this tags

tag.enemy.player1=<player_Uid>
tag.enemy.player2=<player_Uid>
tag.enemy.player3=<player_Uid>
tag.enemy.player4=<player_Uid>
tag.enemy.player5=<player_Uid>
tag.any=1
tag.asdas=1


Now I want to do a loop among enemy group tag.
How do I this?
01-22-2016 03:57 PM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: Loop on tags.
I don't understand, you can loop through similar tags by using this
PHP Code:
for 1 5
  
// Print in server console the Uid of the player at tag.enemy.player1/2/34/5 
 
 
serv.log <tag.enemy.player<dlocal._for>>  
endfor 
But i think it's better you use the ATTACKER functions
http://wiki.sphere.torfo.org/index.php/ATTACKER
01-22-2016 07:24 PM
Find all posts by this user Like Post Quote this message in a reply
rastrero
Master
**

Posts: 250
Likes Given: 41
Likes Received: 28 in 24 posts
Joined: Jan 2016
Reputation: 3



Post: #3
RE: Loop on tags.
Ok, I knew that way but its not the way im looking for.

Anyway thx.
01-23-2016 01:42 AM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #4
RE: Loop on tags.
What you mean then ?
01-23-2016 02:59 AM
Find all posts by this user Like Post Quote this message in a reply
rastrero
Master
**

Posts: 250
Likes Given: 41
Likes Received: 28 in 24 posts
Joined: Jan 2016
Reputation: 3



Post: #5
RE: Loop on tags.
Im doing my own "guild system"

I need to safe the members list, enemy, friends, allys, etc etc.
so I want to safe them on tags but Im not sure how to do it.

It this way better?
Tag0.exampleMembers= <Uid> <uid> <uid> <uid>



OR its better at the other way?

ok, Im going to use lists better.
Ty all anyway.
(This post was last modified: 01-23-2016 05:04 AM by rastrero.)
01-23-2016 04:46 AM
Find all posts by this user Like Post Quote this message in a reply
karma
Moderator
****

Posts: 178
Likes Given: 17
Likes Received: 32 in 29 posts
Joined: Jul 2012
Reputation: 3



Post: #6
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
Find all posts by this user Like Post Quote this message in a reply
[+] 1 user Likes karma's post
Sirocco
Apprentice
*

Posts: 3
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Apr 2015
Reputation: 0



Post: #7
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
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)