Chojiros Blog

June 06, 2006

XR Script - Pickpocketing...

This is a skill which can be used to steal money from other people!! (Literally) You have to be facing the person, and success depends on the players speed, level and a little randomness...I also added the exp script in here...
Note, this script does not currently work, hopefully it will with v1.5



'PICKPOCKETING!!

If LCase(Mid(GetPlayerStringCommand(Index), 1, 11)) = "/pickpocket" Then
If Len(GetPlayerStringCommand(Index)) < name =" Mid(GetPlayerStringCommand(Index)," index2 =" FindPlayer(Name)"> 0 Then
If GetPlayerMap(Index) <> GetPlayerMap(Index2) Then
Call PlayerMsg(Index, "You are not close enough to this player!!", 15)
ExitSub
End If

Select Case
GetPlayerDir(Index)
Case [ClassNum]
If GetPlayerX(Index2) <> GetPlayerX(Index) Then
Exit Sub
End If
If GetPlayerY(Index2) <> GetPlayerY(Index) - 1 Then
Call PlayerMsg(Index, "You have to get a little closer...", 15)
Exit Sub
End If
Case [ClassNum]
If GetPlayerX(Index2) <> GetPlayerX(Index) Then
Call PlayerMsg(Index, "You have to get a little closer...", 15)
Exit Sub
End If
If GetPlayerY(Index2) <> GetPlayerY(Index) + 1 ThenCall PlayerMsg(Index, "You have to get a little closer...", 15)
Exit Sub
End If
Case [ClassNum]
If GetPlayerX(Index2) <> GetPlayerX(Index) - 1
ThenCall PlayerMsg(Index, "You have to get a little closer...", 15)
Exit Sub
End If
If GetPlayerY(Index2) <> GetPlayerY(Index) Then
Call PlayerMsg(Index, "You have to get a little closer...", 15)
Exit Sub
End If
Case [ClassNum]
If GetPlayerX(Index2) <> GetPlayerX(Index) + 1 Then
Call PlayerMsg(Index, "You have to get a little closer...", 15)
Exit Sub
End If
If GetPlayerY(Index2) <> GetPlayerY(Index) Then
Call PlayerMsg(Index, "You have to get a little closer...", 15)
Exit Sub
End If
End Select

'These are success chances based on speed, change these at will, these will be the thiefs skill
T = Int(GetPlayerSpeed(Index) / 5)
T2 = Int(Rnd * GetPlayerLevel(Index)) + T

'And this will be the victims dodge chance
V = Int(GetPlayerSpeed(Index2) / 5)
V2 = Int(Rnd * GetPlayerLevel(Index2)) + VIf V2 > GetPlayerLevel(Index2) * 2 Then
V2 = GetPlayerLevel(Index2) * 2
If T2 > GetPlayerLevel(Index) * 2 Then
T2 = GetPlayerLevel(Index) * 2

'This will measure how much gold to take, change this to fit your game
G = Int(Rnd * 100) * Int(GetPlayerLevel(Index2) / 5)

'Just a few numeric triggers
S = slot, N = numberS = 10N = 10
'This finds the slot with the gold
DoS = S + 1
If GetPlayerInvItemNum(Index2, S) = 1 Then
N = 1
Loop Until N = 1 or S = 101

'If the player doesnt have gold, then you cant steal it!
If S <> 1 Then Call PlayerMsg(Index, "This player does not have any money to steal!!", 15)
Exit Sub
End If

'If the Victim is better than the thief...
If V2 > T2 Then
Call PlayerMsg(Index, "You have failed!! Don't get caught!!", 12)
Call PlayerMsg(Index2, GetPlayerName(Index) & " has just attempted to steal your money!!", 14)
Exit Sub
End If

'If it was a close one?
If T2 = V2 Then
Call PlayerMsg(Index, "Pickpocketing has failed. The player has not noticed!", 14)
Exit Sub
End If

'If the thief Succeeds!
If T2 > V2 Then
If HasItem(Index2, 10) Then
If GetPlayerInvItemValue(Index2, S) < G Then
G = GetPlayerInvItemValue(Index2, S) - 1
Call SetPlayerInvItemValue(Index2, S, GetPlayerInvItemValue(Index2, S) - G)
Call GiveItem(Index, 10, G)
Call TakeItem(Index2, 10, G)
Call PlayerMsg(Index, "Your skills have triumphmed!!", 11)
'------------------
Call SetPlayerEXP(Index, GetPlayerEXP(Index) + [ExpNum])
Call CheckPlayerLevelUp(Index)
'------------------
End If
End If
ElseCall PlayerMsg(Index, "There is nobody here...", 15)
Exit Sub
End If
ElseCall PlayerMsg(Index, "You cannot pickpocket!!", 14)
End If
End If

0 Comments:

Post a Comment

<< Home