SphereCommunity
Need help in general Scripting - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: Need help in general Scripting (/Thread-Need-help-in-general-Scripting)

Pages: 1 2 3 4 5 6


RE: Need help in general Scripting - XuN - 05-03-2016 01:09 AM

src.newitem sets as ACT the item created, the same goes for src.makeitem ... the crafted item becomes act, you can use REFx to store UIDs and work with them to avoid this and some other conflicts, eg:

Code:
SERV.NEWITEM <TAG.ID>
REF1=<NEW>
if ( (<REF1.TYPE> == t_potion) && (<SRC.RESTEST i_bottle_empty> == 0) )
SRC.SYSMESSAGE You have no bottles for your potion.
elseif (<SRC.RESTEST <REF1.RESOURCES>> == 0 )
SRC.SYSMESSAGE You need <REF1.RESMAKE> to produce <REF1.NAME>.
elseif ( !<SRC.CANMAKE <REF1.BASEID>> )
SRC.SYSMESSAGE You haven't got the faintest idea on how to produce <REF1..NAME>.
else
SRC.SYSMESSAGE You start producing <REF1.NAME>.
SRC.MAKEITEM = <TAG.ID>
SRC.TAG.MAKEITEM.LEVEL = <TAG.SKILL>
endif
REF1.REMOVE
return 1



RE: Need help in general Scripting - Fronz - 05-03-2016 01:40 AM

You Sir are a Lifesaver.

It works flawlessly.

I can't thank you enough. I'm going to read and learn more about that!

Many Many Thanks,
Fronz


RE: Need help in general Scripting - Fronz - 05-04-2016 10:04 AM

Is it something wrong with this script? Every things works fine as it should. But some mobs don't attack me. Like I can attack them but they won't attack me.

[REGIONTYPE r_newbiedungeon]
ON=@ENTER
SRC.EVENTS=+e_dungeonnewbie
SRC.EVENTS=+e_dungeonnewbie2
ON=@EXIT
SRC.EVENTS=-e_dungeonnewbie
SRC.EVENTS=-e_dungeonnewbie2

[EVENTS e_dungeonnewbie]
On=@hittry
if (<src.isplayer>)
sysmessage You can't attack other players in this dungeon.
return 1
endif

[EVENTS e_dungeonnewbie2]
ON=@SpellEffect
if ( <ISPLAYER> && <SRC.ISPLAYER> )
f_spell_is_aggressive <ARGN>
IF (<VAR0.f_spell_is_aggressive> = 1)
SRC.SYSMESSAGE You cannot harm players in this dungeon.
RETURN 1
ENDIF
ENDIF

ON=@SpellCast
If ( <Argn> == 33 )
src.message " You can't use that spell in this dungeon"
return 1
Endif
If ( <Argn> == 40 )
src.message " You can't use that spell in this dungeon"
return 1
Endif
If ( <Argn> == 58 )
src.message " You can't use that spell in this dungeon"
return 1
Endif
If ( <Argn> == 60 )
src.message " You can't use that spell in this dungeon"
return 1
Endif
If ( <Argn> == 61 )
src.message " You can't use that spell in this dungeon"
return 1
Endif
If ( <Argn> == 62 )
src.message " You can't use that spell in this dungeon"
return 1
Endif
If ( <Argn> == 63 )
src.message " You can't use that spell in this dungeon"
return 1
Endif
If ( <Argn> == 64 )
src.message " You can't use that spell in this dungeon"
return 1
endif



[FUNCTION f_spell_is_aggressive]
VAR.f_spell_is_aggressive = 1
VAR.is_dispel = 0
if ( 0 )
elseif ( <argn> == 1 ) // clumsy
elseif ( <argn> == 3 ) // feeblemind
elseif ( <argn> == 5 ) // magic arrow
elseif ( <argn> == 8 ) // weaken
elseif ( <argn> == 12 ) // harm
elseif ( <argn> == 18 ) // fireball
elseif ( <argn> == 20 ) // poison
elseif ( <argn> == 27 ) // curse
elseif ( <argn> == 28 ) // - Fire Field
elseif ( <argn> == 30 ) // lightning
elseif ( <argn> == 31 ) // mana drain
elseif ( <argn> == 33 ) // - Blade of Spirits
elseif ( <argn> == 37 ) // mind blast
elseif ( <argn> == 38 ) // paralyze
elseif ( <argn> == 39 ) // - Poison Field
elseif ( <argn> == 40 ) // - Summon Creature
elseif ( <argn> == 41 ) // dispel
VAR.is_dispel = 1
elseif ( <argn> == 42 ) // energy bolt
elseif ( <argn> == 43 ) // explosion
elseif ( <argn> == 46 ) // mass curse
elseif ( <argn> == 47 ) // paralyze field
elseif ( <argn> == 49 ) // chain lightning
elseif ( <argn> == 51 ) // flamestrike
elseif ( <argn> == 53 ) // mana vampire
elseif ( <argn> == 54 ) // mass dispel
VAR.is_dispel = 1
elseif ( <argn> == 55 ) // meteor swarm
elseif ( <argn> == 57 ) // - Earthquake
elseif ( <argn> == 58 ) // - Energy Vortex
elseif ( <argn> == 60 ) // - Air Elemental
elseif ( <argn> == 61 ) // - Summon Daemon
elseif ( <argn> == 62 ) // - Earth Elemental
elseif ( <argn> == 63 ) // - Fire Elemental
elseif ( <argn> == 64 ) // - Water Elemental
else
VAR.f_spell_is_aggressive = 0
endif


I'm pretty sure it's something I did with the event in Bold.

Sorry for bothering once again,
Fronz


RE: Need help in general Scripting - Criminal - 05-04-2016 04:12 PM

[EVENTS e_dungeonnewbie2]
ON=@SpellEffect
if ( <ISPLAYER> && <SRC.ISPLAYER> )
if (<serv.spell.<argn1>.flags>&spellflag_harm)
SRC.SYSMESSAGE You cannot harm players in this dungeon.
RETURN 1
ENDIF
ENDIF


RE: Need help in general Scripting - XuN - 05-04-2016 04:29 PM

Use what criminal wrote, it is all that you need.


However i'm going to explain you some things you had wrong on your code in case you can make use of it on the future:
IF (<VAR0.f_spell_is_aggressive> = 1) //WRONG: One = means 'set', in this case you are setting that VAR to 1 everytime so you are forcing Sphere to automatically pass this check always.
IF (<VAR0.f_spell_is_aggressive> == 1) // Double = means compare, this is what you must use when comparing values.

NOTE: Functions can return values, there is no need to store anything on VARs to check them later:

Code:
[FUNCTION f_test]
if (<serv.spell.<argn1>.flags>&spellflag_harm)
return 1
endif
return 0

ON=@SpellEffect
if (<f_test <argn1>> == 1) // So you don't need to set a VAR and check for it later, you can do it all at once.
SRC.SYSMESSAGE You cannot harm players in this dungeon.
return 1
endif



RE: Need help in general Scripting - Fronz - 05-10-2016 01:05 PM

Many Many thanks guys! Worked as always!

Got a new question, this seems basic but I'm stuck.
I want to open a Dialog using a function like .test . But I want that Dialog to close and open a new one when typing .test again.

Like I type .test opens a dialog and I don't close it. Then I type .test again and closes the previous dialog and opens a new one.

[FUNCTION TEST]
SRC.DIALOG d_TEST
RETURN 1

[DIALOG d_TEST]
0,0
PAGE 0
NODISPOSE
gumppic 160 65...

Silly me,
Fronz


RE: Need help in general Scripting - Criminal - 05-10-2016 09:53 PM

[function test]
sdialog d_test

[dialog d_Test]
0,0
closedialog d_test 0 (not sure if closedialog or dialogclose i dont remember xd
...


RE: Need help in general Scripting - Fronz - 05-16-2016 10:25 AM

Guys thank you for everything! All your help was very much needed. I'm going to open the shard very hopefully this week, all errors are gone and all new scripts have been added. Can't thank you guys enough.

For one very final question regarding to a VPS.

I read all what you guys said about Dual Cores, RAM and CPU. But none of you talked about bandwidth, is it not that relevant?


I found a cheap server with these Specs:

2 vCPU - Intel Xeon E5 V3

2gb Ram

40GB SSD

40GB Hard Disk

10TB/m bandwidth = 167mb/s

100mb/s Port Speed


Is it good? How much players can it handle without much hassle? Can it run 50 players? Can it run 100 players?

I'm settling for this VPS if you guys say otherwise.

Tyvm,
Fronz


RE: Need help in general Scripting - Kanibal - 05-16-2016 10:51 AM

(05-16-2016 10:25 AM)Fronz Wrote:  100mb/s Port Speed

Is it good? How much players can it handle without much hassle? Can it run 50 players? Can it run 100 players?

Your server can handle more than 1000 players. Woot


RE: Need help in general Scripting - Fronz - 05-17-2016 02:34 AM

Well I'm settled then xD

Thanks man,
Fronz