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
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
Post Reply 


Messages In This Thread
Army Job - x77x - 10-25-2015, 03:13 AM
RE: Army Job - XuN - 10-25-2015 05:24 AM
RE: Army Job - x77x - 10-25-2015, 05:59 AM
RE: Army Job - x77x - 10-25-2015, 08:34 AM
RE: Army Job - XuN - 10-26-2015, 05:01 AM

Forum Jump:


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