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

Script problem


Akselj
 Share

Recommended Posts

I have an problem with an script I wrote; I want it to add an value if player is 50+ add 50 if level is 100 then 50 for lvl 50 and 50 for lvl 100 will be added and so on. This script is not complete, I just wonder why the putvar command on ifgetplayerlvl does not work.

```
Sub OnPVPDeath(Attacker, Victim)
Call GiveCurrency(Attacker, 4, & GetVar("bounty.ini",GetPlayerName(Victim), "Bounty"))
Call GlobalMsg(GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker), BRIGHTRED)
Call PutVar("bounty.ini",GetPlayerName(Victim), "Bounty", "0")
If GetPlayerLevel(Victim) >1999 then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", +"500"
End If
If GetPlayerLevel(Victim) >1499 then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", +"500"
End If
If GetPlayerLevel(Victim) >999 then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", +"250"
End If
If GetPlayerLevel(Victim) >749 then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", +"250"
End If
If GetPlayerLevel(Victim) >499 then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", +"250"
End If
If GetPlayerLevel(Victim) >249 then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", +"150"
End If
If GetPlayerLevel(Victim) >99 then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", +"50"
End If
If GetPlayerLevel(Victim) >49 then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", +"50"
End If

End Sub

```
Any help would be appreciated.

Thanks,
AkselJ
Link to comment
Share on other sites

because the putvar command you're using makes absolutely no sense.
This is how I would do it. Keep in mind idk if you want it to say +500 or you want to add 500…
```
Dim a
a=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & a + 50)

```or something like that. basicallly you can't have the + before the "50" and I'm not 100% sure if youc an just put GetPlayerName(Attacker) straight in there without a "" &. I do the "" & just to be sure.
Link to comment
Share on other sites

K thanx Ghost. This is one of my first scripts, and I really didn't understand how dim's work. Never thought I would use it. But you have proved me wrong… :P
EDIT: Just tested it, still nothing comes into bounty.ini... Oh and I want it to add bounty, does that work if theres nothing there at all? Here's what my script looks like now: (I changed a to bounty)

```
Sub OnPVPDeath(Attacker, Victim)
Call GiveCurrency(Attacker, 4, & GetVar("bounty.ini",GetPlayerName(Victim), "Bounty"))
Call GlobalMsg(GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker), BRIGHTRED)
Call PutVar("bounty.ini",GetPlayerName(Victim), "Bounty", "0")
If GetPlayerLevel(Victim) >1999 then
Dim bounty
bounty=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 500)
End If
If GetPlayerLevel(Victim) >1499 then
Dim bounty
bounty=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 500)
End If
If GetPlayerLevel(Victim) >999 then
Dim bounty
bounty=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 500)
End If
If GetPlayerLevel(Victim) >749 then
Dim bounty
bounty=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 250)
End If
If GetPlayerLevel(Victim) >499 then
Dim bounty
bounty=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 250)
End If
If GetPlayerLevel(Victim) >249 then
Dim bounty
bounty=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 150)
End If
If GetPlayerLevel(Victim) >99 then
Dim bounty
bounty=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 50)
End If
If GetPlayerLevel(Victim) >49 then
Dim bounty
bounty=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 50)
End If
Call GobalMsg(GetPlayerName(attacker) & " has" &Getvar("bounty.ini",GetPlayerName(attacker),"Bounty") & " bounty"
End Sub

```
Link to comment
Share on other sites

Okay.. Still doesen't work  :sad:
Now my script is like this: (aslo removed bounty=, didn't work then either)

```
Sub OnPVPDeath(Attacker, Victim)
Dim bounty
bounty=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
Call GiveCurrency(Attacker, 4, & GetVar("bounty.ini",GetPlayerName(Victim), "Bounty"))
Call GlobalMsg(GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker), BRIGHTRED)
Call PutVar("bounty.ini",GetPlayerName(Victim), "Bounty", "0")
If GetPlayerLevel(Victim) >1999 then
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 500)
End If
If GetPlayerLevel(Victim) >1499 then
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 500)
End If
If GetPlayerLevel(Victim) >999 then
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 500)
End If
If GetPlayerLevel(Victim) >749 then
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 250)
End If
If GetPlayerLevel(Victim) >499 then
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 250)
End If
If GetPlayerLevel(Victim) >249 then
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 150)
End If
If GetPlayerLevel(Victim) >99 then
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 50)
End If
If GetPlayerLevel(Victim) >49 then
Call PutVar("bounty.ini",""&GetPlayerName(Attacker),"Bounty","" & bounty + 50)
End If
Call GlobalMsg(GetPlayerName(attacker) & " has" &Getvar("bounty.ini",GetPlayerName(attacker),"Bounty") & " bounty"
End Sub

```
Sometimes I wonder why I had to make my own script… :P
Link to comment
Share on other sites

Script updated: (Godlord gave me an new PutVar command, but didn't have more time)

```
Sub OnPVPDeath(Attacker, Victim)
Dim bounty
bounty=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
Call GiveCurrency(Attacker, 4, & GetVar("bounty.ini",GetPlayerName(Victim), "Bounty"))
Call GlobalMsg(GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker), BRIGHTRED)
Call PutVar("bounty.ini",GetPlayerName(Victim), "Bounty", "0")
If GetPlayerLevel(Victim) >1999 then
Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty)) + 5000))
End If
If GetPlayerLevel(Victim) >1499 then
Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty)) + 5000))
End If
If GetPlayerLevel(Victim) >999 then
Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty)) + 5000))
End If
If GetPlayerLevel(Victim) >749 then
Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty)) + 2500))
End If
If GetPlayerLevel(Victim) >499 then
Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty)) + 2500))
End If
If GetPlayerLevel(Victim) >249 then
Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty)) + 1500))
End If
If GetPlayerLevel(Victim) >99 then
Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty)) + 500))
End If
If GetPlayerLevel(Victim) >49 then
Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty)) + 500))
End If
Call GlobalMsg(GetPlayerName(attacker) & " has" &Getvar("bounty.ini",GetPlayerName(attacker),"Bounty") & " bounty"
End Sub

```
Still does not work… I'll try removing Call GiveCurrency.
EDIT: Nope, does not work now either...
Link to comment
Share on other sites

I removed all of the syntax errors, try it now:
```
Sub OnPVPDeath(Attacker, Victim)
  Dim bounty
  bounty=GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
  Call GiveCurrency(Attacker, 4, GetVar("bounty.ini",GetPlayerName(Victim), "Bounty"))
  Call GlobalMsg(GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker), BRIGHTRED)
  Call PutVar("bounty.ini",GetPlayerName(Victim), "Bounty", "0")
  If GetPlayerLevel(Victim) >1999 Then
      Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty")) + 5000))
  End If
  If GetPlayerLevel(Victim) >1499 Then
      Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty")) + 5000))
  End If
  If GetPlayerLevel(Victim) >999 Then
      Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty")) + 5000))
  End If
  If GetPlayerLevel(Victim) >749 Then
      Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty")) + 2500))
  End If
  If GetPlayerLevel(Victim) >499 Then
      Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty")) + 2500))
  End If
  If GetPlayerLevel(Victim) >249 Then
      Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty")) + 1500))
  End If
  If GetPlayerLevel(Victim) >99 Then
      Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty")) + 500))
  End If
  If GetPlayerLevel(Victim) >49 Then
      Call PutVar("bounty.ini", GetPlayerName(Attacker), "Bounty", CStr(CInt(GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty")) + 500))
  End If
  Call GlobalMsg(GetPlayerName(attacker) & " has" &Getvar("bounty.ini",GetPlayerName(attacker),"Bounty") & " bounty")
End Sub
```
Link to comment
Share on other sites

How about this?

```
Sub OnPVPDeath(Attacker, Victim)
Call GiveCurrency(Attacker, 4, CInt(GetVar("bounty.ini",GetPlayerName(Victim), "Bounty")))
Call GlobalMsg(GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker), BRIGHTRED)
Call PutVar("bounty.ini", GetPlayerName(Victim), "Bounty", "0")
bounty = GetVar("bounty.ini", GetPlayerName(Attacker), "Bounty")

If GetPlayerLevel(Victim) > 1999 Then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", bounty + 500)
Exit Sub
End If
If GetPlayerLevel(Victim) > 1499 Then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", bounty + 500)
Exit Sub
End If
If GetPlayerLevel(Victim) > 999 Then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", bounty + 250)
Exit Sub
End If
If GetPlayerLevel(Victim) > 749 Then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", bounty + 250)
Exit Sub
End If
If GetPlayerLevel(Victim) > 499 Then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", bounty + 250)
Exit Sub
End If
If GetPlayerLevel(Victim) > 249 Then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", bounty + 150)
Exit Sub
End If
If GetPlayerLevel(Victim) > 99 Then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", bounty + 50)
Exit Sub
End If
If GetPlayerLevel(Victim) > 49 Then
Call PutVar("bounty.ini",GetPlayerName(Attacker), "Bounty", bounty + 50)
Exit Sub
End If

End Sub
```
Link to comment
Share on other sites

You didn't look at the other posts, did you Balliztik? Two reasons I figured that out; 1: You edited the script from my first post, updated lots of times. 2: I explained in one of the replies that I wanted the script to go through all ifs, so I guess the sub should not be exited then? I might be wrong, of course, but that is how I understand the command Exit Sub works. So you should look at the replies. But thanks anyway. I'm sure one of you Uber-scriptors will find out  ;)
Link to comment
Share on other sites

```
Sub OnPVPDeath(Attacker, Victim)

Dim bounty
Dim reward
bounty = GetVar("bounty.ini","" & GetPlayerName(Attacker),"Bounty")
reward = GetVar("bounty.ini","" & GetPlayerName(Victim),"Bounty")
Call GiveCurreny(Attacker,4,reward)
Call GlobalMsg("" & GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker),12)
Call PutVar("bounty.ini","" & GetPlayerName(Victim), "Bounty", "0")

'''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''
Dim vlvl
Dim attbounty
vlvl=GetPlayerLevel(Victim)
attbounty=GetVar("bounty.ini", "" & GetPlayerName(Attacker),"Bounty")

If vlvl>1999 Then
newbounty=newbounty+5000
End If
If vlvl>1499 Then
newbounty=newbounty+5000
End If
If vlvl>999 Then
newbounty=newbounty+5000
End If
If Vlvl>749 Then
newbounty=newbounty+2500
End If
If vlvl>499 Then
newbounty=newbounty+2500
End If
If vlvl>249 Then
newbounty=newbounty+1500
End If
If vlvl>99 Then
newbounty=newbounty+500
End If
If vlvl>49 Then
newbounty=newbounty+500
End If

Call PutVar("bounty.ini", "" & GetPlayerName(Attacker),"Bounty", "" & newbounty)
Call GlobalMsg("" & GetPlayerName(Attacker) & " has" & newbounty & " bounty.",12)

End Sub
```
Try that. If it doesn't work, I'm 99% sure that the problem lies outside of that sub.
Btw I did notice that the GlobaMsg just before the end sub didn't have a color after the text…not sure if that was it or not.
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...