SphereCommunity

Full Version: Add to the NEXT Spot
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
how can i add to the NEXT open spot?

GSLAIN01 - GSLAIN250


Code:
[EVENTS e_cao_cao]
on=@deathcorpse
ref1=<attacker.max>//who ever did most damage
for x 1 250
IF (STRCMPI("<ref1.tag.gslain<LOCAL.X>>","Cao Cao")==0)
ref1.sysmessage @0482 You have already defeated General Cao Cao...
else
if <ref1.isplayer>//if max damage doner is player.
ref1.tag.gslain<dlocal._for> Cao Cao
ref1.sysmessage @0481 Congratulations! You have defeated General Cao Cao!
ENDFOR
endif


it keeps adding to GSLAIN0


thx
If Endif
For Endfor
english please?


top part works, bottom does not

always overwrites to GSLAIN0
[EVENTS e_cao_cao]
on=@deathcorpse
ref1=<attacker.max>//who ever did most damage
for x 1 250
IF (STRCMPI("<ref1.tag.gslain<LOCAL.X>>","Cao Cao")==0)
ref1.sysmessage @0482 You have already defeated General Cao Cao...
else
if <ref1.isplayer>//if max damage doner is player.
ref1.tag.gslain<dlocal._for> Cao Cao
ref1.sysmessage @0481 Congratulations! You have defeated General Cao Cao!
endif
ENDFOR -----------------> close if before for
i did that already and its the same...

still saves to gslain0

if glsain01
and gslain02 are taken, put it at gslain03
ect...

get what im saying?


Code:
[EVENTS e_cao_cao]
on=@deathcorpse
ref1=<attacker.max>//who ever did most damage
for x 1 250
IF (STRCMPI("<ref1.tag.gslain<LOCAL.X>>","Cao Cao")==0)
ref1.sysmessage @0482 You have already defeated General Cao Cao...
else
IF <ref1.isplayer>//if max damage doner is player.
ref1.tag.gslain<dLOCAL.X> Cao Cao//<dlocal._for>
ref1.sysmessage @0481 Congratulations! You have defeated General Cao Cao!
endif
ENDFOR

i tried this and it keeps saving to GSLAIN1

i want to to find the next empty one
try to use elseif
nope...

this added it 250 times =/

Code:
[EVENTS e_cao_cao]
on=@deathcorpse
ref1=<attacker.max>//who ever did most damage
for x 1 250
IF (STRCMPI("<ref1.tag.gslain<LOCAL.X>>","Cao Cao")==0)
ref1.sysmessage @0482 You have already defeated General Cao Cao...
elseif <ref1.isplayer>//if max damage doner is player.
ref1.tag.gslain<dLOCAL.X> Cao Cao//<dlocal._for>
ref1.sysmessage @0481 Congratulations! You have defeated General Cao Cao!
endif
ENDFOR
what a mess... try this.

[EVENTS e_cao_cao]
on=@deathcorpse
ref1=<attacker.max>
for x 1 250
IF (STRCMP("<ref1.tag.gslain<dLOCAL.X>>","Cao Cao")==0)
ref1.sysmessage @0482 You have already defeated General Cao Cao...
return 1
elseif (<ref1.isplayer> && <ISEMPTY <ref1.tag.gslain<dLOCAL.X>>>)
ref1.tag.gslain<dLOCAL.X> Cao Cao
ref1.sysmessage @0481 Congratulations! You have defeated General Cao Cao!
return 1
endif
ENDFOR
ISEMPTY!!!!???

nice...

BEN IS MY HERO... again...

thank you
you must use "return 0/1" to stop the loop, otherwise it will continue looping until 250 and will set 250 tags Tongue
and also use the right return 0/1, because on @DeathCorpse the return 1 will prevent the corpse creation, and return 0 will allow the corpse creation

and LOCAL.X (hex) is not the same as dLOCAL.X (dec)
tag.gslain<LOCAL.X> = tag.gslain01
tag.gslain<dLOCAL.X> = tag.gslain1

so if you set the value on tag.gslain1, you wont find the tag value if you search it on tag.gslain01

Ben already post a working example with these things fixed

PS: just a code optimization tip, avoid make checks inside loops which doesn't really need to be inside the loop. If you check the <REF1.ISPLAYER> value inside the loop, sphere will try to get the <REF1.ISPLAYER> result 1x ~ 250x, but you just need check it 1x and not 250x. So you can check it just a single time before start the loop

Code:
[EVENTS e_cao_cao]
ON=@DeathCorpse
REF1=<ATTACKER.MAX>  //who ever did most damage
IF (<REF1.ISPLAYER>)
  FOR x 1 250
    IF (STRCMPI("<REF1.TAG.gslain<dLOCAL.X>>","Cao Cao")==0)
      REF1.SYSMESSAGE @0482 You have already defeated General Cao Cao...
      return 1  //prevent corpse creation
    ELIF (<ISEMPTY <REF1.TAG.gslain<dLOCAL.X>>>)
      REF1.TAG.gslain<dLOCAL.X>=Cao Cao
      REF1.SYSMESSAGE @0481 Congratulations! You have defeated General Cao Cao!
      return 0  //allow corpse creation
    ENDIF
  ENDFOR
ENDIF
Pages: 1 2
Reference URL's