XuN 
Sphere Developer
    
Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30
![]()
|
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 |
|
|