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
Army Job
Author Message
x77x
Master
**

Posts: 488
Likes Given: 0
Likes Received: 15 in 15 posts
Joined: Mar 2012
Reputation: -4



Post: #1
Army Job
a better and working way to do this please?

Code:
[EVENTS e_army_job]
ON=@CLICK
IF (<EVAL <SRC.TAG0.MILITARY>>==1) && !(STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>"))//IS A PLAYER IN THE MILITARY AND NOT SAME ARMY
ATTACK
SAY Die soldier of <SRC.TAG.ARMY>!
ELSE
SAY Hi//DO NOTHING LEAVE CIVILIANS WITH NO MILITARY TAG ALONE
RETURN 0
//
IF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
Say Beat it criminal!
ATTACK
ELSE
IF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
ATTACK
//
ENDIF
RETURN 1

ON=@NPCSeeNewPlayer
IF !(STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>"))//FOR NPCS TO ATTACK OTHER NPCS NOT IS SAME ARMY
ATTACK
SAY Die!

i want them to attack military PLAYERS and other military NPCS in any other army other than their own! (all armies are at war)
i want them to leave non criminal civilians alone.
i want them to attack criminal players.(civilian or military dont matter...)
i want them to attack any player made guild.

Dragons of Time 2000-2020
http://dragonsoftime.com
(This post was last modified: 10-25-2015 03:20 AM by x77x.)
10-25-2015 03:13 AM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #2
RE: Army Job
First: Do you really need tag.army to be a text? Using numbers makes the comparisons SO MUCH faster and you can use defs to store and show the text.
Second: your ELSE -> IF (in separate lines) is NOT the same as ELSEIF, per each opened IF you need one closing ENDIF to give your code some sense, this is how you code looks like:
Code:
ON=@CLICK
IF (<EVAL <SRC.TAG0.MILITARY>>==1) && !(STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>"))//IS A PLAYER IN THE MILITARY AND NOT SAME ARMY
    ATTACK
    SAY Die soldier of <SRC.TAG.ARMY>!
ELSE
    SAY Hi//DO NOTHING LEAVE CIVILIANS WITH NO MILITARY TAG ALONE
    RETURN 0
    //
    IF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
        Say Beat it criminal!
        ATTACK
    ELSE
        IF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
            ATTACK
        //
        ENDIF
        RETURN 1
    // you should have one ENDIF for this IF block.
// and another one for this one.

However, if you read carefully that code you'll realize that what is there is doing nothing similar to what you requested... the first ELSE has a return 0, which is STOPPING EVERYTHING under it so in this case you have to check first under which scenario the NPC should attack and then what to do if nothing of this requiremets were achieved.


Code:
[defname armynames] // using this you can define anything to use in scripts in an easier way
army_01=Army_1_Name //change 'Army_1_Name' with the name of one of your armies
army_02=Army_2_Name //and so on
army_03=Army_3_name
etc

[events e_army_job]
ON=@Click
// First I should know if TAG.MILITARY and TAG.ARMY are working together, I mean if TAG.MILITARY is ONLY present when someone has a TAG.ARMY, if so use the first if ... use the second if not
//first if
IF ( <SRC.TAG0.MILITARY> && (<TAG.ARMY>==<SRC.TAG.ARMY>) )
//second if
IF ( (<SRC.TAG0.MILITARY>) && (<TAG.ARMY> && <SRC.TAG.ARMY>) && (<SRC.TAG0.ARMY> != <TAG0.ARMY>) ) //You must check too that they have an army, or the tag.military is only set when tag.army is set too?
    ATTACK
    SAY Die solder of <DEF0.army_<SRC.TAG.ARMY>>
ELSEIF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
    Say Beat it criminal!
    ATTACK
ELSEIF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
    ATTACK
ENDIF
return 0
10-25-2015 05:24 AM
Find all posts by this user Like Post Quote this message in a reply
x77x
Master
**

Posts: 488
Likes Given: 0
Likes Received: 15 in 15 posts
Joined: Mar 2012
Reputation: -4



Post: #3
RE: Army Job
players are tagged with
"TAG.MILITARY 1" and "TAG.ARMY Wei"
when they join the Wei army,
there are 7 different armies (Wei, Wu, Shu, YS, LB, YT, MH)

you will have both tags, or none

both tags are removed when they are not in an army and are civilians

you can resign at anytime

Code:
ON=I resign from my guild
SRC.TAG.ARMY
SRC.TITLE Villager
src.events -e_armylife_wei
src.events -e_armylife_wu
src.events -e_armylife_shu
src.events -e_armylife_ys
src.events -e_armylife_lb
src.events -e_armylife_yt
src.events -e_armylife_mh
SRC.TAG.MILITARY
findid.i_military_cap.remove
findid.i_military_leggings.remove
findid.i_military_tunic.remove
findid.i_military_overplate.remove
findid.i_military_apron.remove
findid.i_military_uniform.remove
findid.i_military_boots.remove

TAG.ARMY=xxxx designates what army they belong to
TAG.MILITARY=1 is used for an item check, only military players can use military items

Dragons of Time 2000-2020
http://dragonsoftime.com
(This post was last modified: 10-25-2015 06:06 AM by x77x.)
10-25-2015 05:59 AM
Find all posts by this user Like Post Quote this message in a reply
x77x
Master
**

Posts: 488
Likes Given: 0
Likes Received: 15 in 15 posts
Joined: Mar 2012
Reputation: -4



Post: #4
RE: Army Job
with...
Code:
[defname armynames] // using this you can define anything to use in scripts in an easier way
army_01=Wei
army_02=Wu
army_03=Shu
army_04=YS
army_05=LB
army_06=YT
army_07=MH

[events e_army_job]
ON=@Click
// First I should know if TAG.MILITARY and TAG.ARMY are working together, I mean if TAG.MILITARY is ONLY present when someone has a TAG.ARMY, if so use the first if ... use the second if not
//first if
IF ( <SRC.TAG0.MILITARY> && (<TAG.ARMY>==<SRC.TAG.ARMY>) )
//second if
//IF ( (<SRC.TAG0.MILITARY>) && (<TAG.ARMY> && <SRC.TAG.ARMY>) && (<SRC.TAG0.ARMY> != <TAG0.ARMY>) ) //You must check too that they have an army, or the tag.military is only set when tag.army is set too?
    ATTACK
    SAY Die solder of <DEF0.army_<SRC.TAG.ARMY>>
ELSEIF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
    Say Beat it criminal!
    ATTACK
ELSEIF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
    ATTACK
ENDIF
return 0

i get

Code:
18:33:ERROR:(3kuo_E_ARMYLIFE_NPCS.scp,18)Undefined symbol 'Wei' ['Wei==) )']
18:33:ERROR:(3kuo_E_ARMYLIFE_NPCS.scp,18)Undefined symbol '' [') )']
18:33:ERROR:(3kuo_E_ARMYLIFE_NPCS.scp,18)Undefined symbol 'Wu' ['Wu==) )']
18:33:ERROR:(3kuo_E_ARMYLIFE_NPCS.scp,18)Undefined symbol '' [') )']

did i mention i want NPCs to fight each other too?

okay this seems to be working
I NOW TAGGED NPCS with TAG.MILITARY 1
Code:
[events e_army_job]
ON=@Click//TO INTERACT WITH PLAYERS
IF (<SRC.TAG0.MILITARY>) && !STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>")
    ATTACK
    SAY Die solder of <SRC.TAG.ARMY>
ELSEIF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
    Say Beat it criminal!
    ATTACK
ELSEIF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
    ATTACK
ENDIF
return 0

ON=@NPCLookAtChar//TO INTERACT NPCS
IF (<SRC.TAG0.MILITARY>) && !STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>")
    ATTACK
    SAY Die solder of <SRC.TAG.ARMY>
ELSEIF (<SRC.FLAGS>&statf_criminal) || (<SRC.KILLS> >= 3 ) || (<SRC.KARMA> <= -2000 )//ATTACK ALL CRIMINALS, MILITARY AND CIVILIAN
    Say Beat it criminal!
    ATTACK
ELSEIF (<SRC.MEMORYFINDTYPE.0400.LINK>>040004010)//ATTACK every PLAYER made guild
    ATTACK
ENDIF
return 0

Dragons of Time 2000-2020
http://dragonsoftime.com
(This post was last modified: 10-25-2015 09:06 AM by x77x.)
10-25-2015 08:34 AM
Find all posts by this user Like Post Quote this message in a reply
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #5
RE: Army Job
The idea on using defs was to use numbers instead of strings for the armies, BTW '!STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>")' will be true if the strings does NOT match, change it to STRMATCH("<SRC.TAG.ARMY>","<TAG.ARMY>") (just remove the !).
10-26-2015 05:01 AM
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)