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

Red vs Blue Script


greenkid
 Share

Recommended Posts

http://www.touchofdeathforums.com/smf/index.php/topic,49497.0.html

As for scripting:
http://www.touchofdeathforums.com/smf/index.php/topic,48978.0.html
http://www.touchofdeathforums.com/smf/index.php/board,70.0.html

You might want to request a full script, although a lot of details should be given or you can use my pointers once you know a bit of Sadscript.

To get and set the team, you'll have to write some functions:
```
Function GetPlayerTeam(Index)
If IsConnected(Index) = False or IsPlaying(Index) = False Then
GetPlayerTeam = 0

Exit Function
End If

If GetVar("Accounts\" & GetPlayerLogin(Index) & "\Char" & GetPlayerCharNum(Index) & ".ini", "Account", "Team") = vbNullString
GetPlayerTeam = 0

Exit Function
End If

GetPlayerTeam = CInt(GetVar("Accounts\" & GetPlayerLogin(Index) & "\Char" & GetPlayerCharNum(Index) & ".ini", "Account", "Team"))
End Function

Function SetPlayerTeam(Index, Team)
If IsConnected(Index) = False or IsPlaying(Index) = False Then
SetPlayerTeam = False

Exit Function
End If

Call PuttVar("Accounts\" & GetPlayerLogin(Index) & "\Char" & GetPlayerCharNum(Index) & ".ini", "Account", "Team", CStr(Team))

SetPlayerTeam = True
End Function
```
Preventing team members from attacking each other is quite simple, you just check if the target is from the same team as the attacker in OnAttack:
```
Sub OnAttack(Index)
If GetPlayerTeam(Index) = GetPlayerTeam(GetPlayerTarget(Index)) And GetPlayerTeam(Index) <> 0 Then
Call BattleMsg(Index, "You cannot attack a team member!", BRIGHTRED, 1)

Exit Sub
End If
```
Getting yourself in a team isn't really hard, it's just using SetPlayerTeam:
```
Call SetPlayerTeam(Index, 1) ' Get into team 1.
```
Or if you want to validate your setting:
```
If SetPlayerTeam(Index, 1) = False
' It failed...
End If
```
The problem is mainly that there are various ways, you can set it the first time somebody joins your game using a custom menu, but you can also just get a NPC to set it for you. There are various ways to do it, but the key is using SetPlayerTeam.

You can also implement points and kills, which is just rewriting GetPlayerTeam and SetPlayerTeam.

Regards,
  Godlord.
Link to comment
Share on other sites

Thank you so much! Although, being the young noob that I am, is there any specific order I have to put it into the main.txt file?

Thanks!

EDIT- I tryed using a spell, but then I realized you could just convert someone from the other team without there consent… How could I make it so that when you start out you just choose red team or blue team, and then you go on your little way. My game is just using like dynmic classes I think the term is, where your class depends on the armor your wearing. Thanks again!
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...