SphereCommunity
Add to the NEXT Spot - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Requests (/Forum-Script-Requests)
+--- Thread: Add to the NEXT Spot (/Thread-Add-to-the-NEXT-Spot)

Pages: 1 2


Add to the NEXT Spot - x77x - 01-31-2015 05:10 AM

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


RE: Add to the NEXT Spot - Extreme - 01-31-2015 05:55 AM

If Endif
For Endfor


RE: Add to the NEXT Spot - x77x - 01-31-2015 06:34 AM

english please?


top part works, bottom does not

always overwrites to GSLAIN0


RE: Add to the NEXT Spot - azmanomer - 01-31-2015 08:58 AM

[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


RE: Add to the NEXT Spot - x77x - 01-31-2015 12:10 PM

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


RE: Add to the NEXT Spot - azmanomer - 01-31-2015 01:31 PM

try to use elseif


RE: Add to the NEXT Spot - x77x - 01-31-2015 01:44 PM

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



RE: Add to the NEXT Spot - Ben - 01-31-2015 11:51 PM

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


RE: Add to the NEXT Spot - x77x - 02-01-2015 02:44 AM

ISEMPTY!!!!???

nice...

BEN IS MY HERO... again...

thank you


RE: Add to the NEXT Spot - Coruja - 02-02-2015 02:42 PM

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