Jump to content
  • 0

Check Script


Question

Posted

Is This The Correct Way of Writing This Type of Code? coz whenever the red team wins it keeps announcing the blue team wins.....

Announce "Battleground has Ended, Team [ "+( ( .winside == 1 )?"Blue":"Red" )+" ] is the Winner.",bc_all;

4 answers to this question

Recommended Posts

Posted

if a battleground script that is using .winside variable, there's high chance that's my script

OnRedDown: callsub L_EmpDown, 2;
OnBlueDown: callsub L_EmpDown, 1;
L_EmpDown:
   .empkiller$ = strcharinfo(0);
   .winside = getarg(0);
   awake strnpcinfo(3);

if you can read these lines, it means

if a blue side crystal is down, the .winside is set to 1, where the getarg(0) is called from OnBlueDown

means ...

when .winside == 1, red side wins

when .winside == 2, blue side wins

so you have to switch your position of "Blue":"Red" into "Red":"Blue"


btw ... didn't I already did this ?

	if ( .winside ) {
	mapannounce "bat_a01", ( ( .winside == 1 )?"Red":"Blue" )+" side wins !", 0;

Posted

depend on your script....

if your script set .winside to 1 when Blue Team win....then it will announce Blue Team ...else it will announce Red Team...

check your script on

set .winside,xxxxxx;

Edit : LOL....annie is faster ...>.<

Posted (edited)

Annie just said everything you need to correct your code.

Anyway, just to add the general case to help you on this kind of structure..

Is This The Correct Way of Writing This Type of Code?

( <condition> ) ? <note 1> : <note 2>

Means: if <condition> is met, solve <note 1>; solve <note 2> otherwise.

<note 1> and <note 2> actually must be of the same type (2 string or 2 integers about rA)

Example with integers:

set .@a, ( ( .@b == 2 ) ? 1 : 2 );
// IF .@b == 2, .@a -> 1 else .@a -> 2

Example with strings:

mes " + ( ( .@b == 2 ) ? ".@b is equal to 2" : ".@b is NOT equal to 2" );

Edited by Ryokem

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...