Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Some sadscripting functions?


marked
 Share

Recommended Posts

Ok, I am making some new commands (I will post them here), but I am kinda just starting, so would someone telling me a few functions? The ones I need are below:

Add Health
Kill all Npcs on map
Kill all Players on map
Kill everything on map
Suicide
Add MP
Add SP
Give Item

That was it! If anything can't be done, please tell me. Oh, and please if you post it, explain for me what to edit :) I'm kinda new to this scripting language.
Link to comment
Share on other sites

add hp,mp,sp

This is the HP
            Call SetPlayerHP(Index, GetPlayerHP(Index)+ Num)

This is the MP one.
            Call SetPlayerMP(Index, GetPlayerMP(Index)+ Num)

This one is for SP
            Call SetPlayerSP(Index, GetPlayerSP(Index)+ Num)
Link to comment
Share on other sites

All of them you are asking for, are subs, not functions.

Regardless though, virtually everything there can be done.

For adding health, I'd just use: Call SetPlayerHP(Index, HP)
For adding MP: Call SetPlayerMP(Index, MP)
For adding SP: Call SetPlayerSP(Index, SP)
For giving an item, you'll need http://www.touchofdeathforums.com/smf/index.php/topic,28174.0.html for the functions and subs
For suicide, paste this script at the bottom of your main.txt:
```
Sub KillPlayer(index)
damage = GetPlayerMaxHP(index) + 1
Call SetPlayerHP(index, GetPlayerHP(index) - damage)
If GetPlayerHP(index) <= 0 Then
Call OnDeath(index)
Call GlobalMsg(GetPlayerName(index) & " has died.", 4)
Call SetPlayerHP(index, GetPlayerMaxHP(index))
Call SetPlayerMP(index, GetPlayerMaxMP(index))
Call SetPlayerSP(index, GetPlayerMaxSP(index))
Call SendMP(index)
Call SendSP(index)
If GetPlayerExp(index) \ 10 > 0 Then
Call SetPlayerExp(index, GetPlayerExp(index) - GetPlayerExp(index) \ 10)
Call SendExp(index)
End If
End If
Call SendHP(index)
End Sub
```Then, to use it, just use Call KillPlayer(Index)
Killing all players on the map, I suppose you could do this.
Paste this at the bottom of your main.txt:
```
Sub KillPlayersMap(Index)
i = 1
Do While i <= Int(GetVar("data.ini", "MAX", "MAX_PLAYERS"))
If GetPlayerMap(i) = GetPlayerMap(index) Then
Call KillPlayer(i)
End If
i = i + 1
Loop
End Sub
```Then, just call it like so: Call KillPlayersMap(Index)
For killing all NPCs on the map, I'm not entirely sure, but this may work:
```
Sub KillNpcsMap(Index)
i = 1
Do While i <= 15
Call DamageNPC( Index, i, Int(GetMapNpcHP(GetPlayerMap(Index), i) + 1) )
i = i + 1
Loop
End Sub
```To call it, simply call Call KillNpcsMap(Index)

As for both, simply combine the two and get:
```
Sub KillAllMap(Index)
i = 1
Do While i <= Int(GetVar("data.ini", "MAX", "MAX_PLAYERS"))
If GetPlayerMap(i) = GetPlayerMap(index) Then
Call KillPlayer(i)
End If
i = i + 1
Loop
i = 1
Do While i <= 15
Call DamageNPC( Index, i, Int(GetMapNpcHP(GetPlayerMap(Index), i) + 1) )
i = i + 1
Loop
End Sub
```
For the record, I just wrote them up on-the-spot (excluding the KillPlayer one), but they should work (and credit goes to me; killPlayer goes to me and Ballie.

Warning - while you were typing 2 new replies have been posted. You may wish to review your post.
And now, I feel like crying  :cry:
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...