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

I don't understand what is happening *sigh*


dragonlord52
 Share

Recommended Posts

Alright so I've almost given up on making this thing work. I'm making a weapon proficiency script and I have a MAJOR problem. For some reason when you buy something at a shop the item script doesn't work breaking attacking. Not only that but when you buy one item of the weapon type all the weapon types become broken at the same time! When you don't buy it and you find the first weapon they all become usable but then you can't have shops or else all the non found ones from that point on break. IDK how to even start fixing this problem and everything I'm doing is in SADscript so there wasn't any source edits…ever. The last problem is that the staff weapon type all say that the weapon is about to break! -1/-1 durability...that doesn't make sense since the weapon is indestructible then when you drop it you get an error and the game closes on you.

Please do not tell me to just use someone's script that does work as I cannot learn from mistakes by doing so.

Note that this was all fine BEFORE the script install. So here is the code, all help is GREATLY appreciated.

> '\\\\\\\\\\\\\\\\\\\\ WEAPON SKILL SCRIPT /////////////////////
> Sub WeaponSkill(Index)
> weapon = GetPlayerInvItemNum(Index, GetPlayerWeaponSlot(Index))
> weapon_type = GetVar("scripts\weapons.ini", "" & weapon & "", "weapon_type")
> weapon_exp = GetVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", weapon_type & "_exp")
> weapon_level = GetVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "" & weapon_type & "")
> next_level_exp = GetVar("scripts\weaponxp.ini", "EXPERIENCE", "" & weapon_level & "")
> weapon_exp = Int(weapon_exp) + 1
> If Int(weapon_exp) >= Int(next_level_exp) Then
> weapon_level = Int(weapon_level) + 1
> weapon_exp = Int(weapon_exp) - Int(next_level_exp)
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "" & weapon_type & "", "" & weapon_level & "")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", weapon_type & "_exp", "" & weapon_exp & "")
> Call PlayerMsg(Index, "Your skill in " & weapon_type & " has increased to level " & weapon_level & ".", 14)
> Else
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", weapon_type & "_exp", "" & weapon_exp & "")
> End If
> End Sub
> '///////////////// END WEAPON SKILL SCRIPT \\\\\\\\\\\\\\\\\\\\\

Attack Script

> ' Executes when a player presses the CONTROL key.
> Sub OnAttack(Index, Damage)
> Dim Target
>
> If Int(Damage) > 0 Then
> If Int(GetPlayerTarget(Index)) > 0 Then
> Target = GetPlayerTarget(Index)
> map = GetPlayerMap(Index)
> x = GetNpcX(map, Target)
> y = GetNpcY(map, Target)
> weapon = GetPlayerWeaponSlot(Index)
> If Int(weapon) > 0 Then
> weapon2 = GetPlayerInvItemNum(Index, GetPlayerWeaponSlot(Index))
> weapon_type = GetVar("scripts\weapons.ini", "" & weapon2 & "", "weapon_type")
> weapon_level = GetVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "" & weapon_type & "")
> damage2 = Rand(0, Int(weapon_level))
> Call DamagePlayer(Index, Target, Damage + damage2)
> Else
> Call DamagePlayer(Index, Target, Damage)
> End If
> Call SpellAnim(16, map, x, y)
> Else
> Target = GetPlayerTargetNPC(Index)
> map = GetPlayerMap(Index)
> x = GetNpcX(map, Target)
> y = GetNpcY(map, Target)
> level = GetPlayerLevel(Index)
> points = GetPlayerPOINTS(Index)
> 'Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "TEMP", "tmp_level", level)
> 'Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "TEMP", "tmp_points", points)
>
> weapon = GetPlayerWeaponSlot(Index)
> If Int(weapon) > 0 Then
> weapon2 = GetPlayerInvItemNum(Index, GetPlayerWeaponSlot(Index))
> weapon_type = GetVar("scripts\weapons.ini", "" & weapon2 & "", "weapon_type")
> weapon_level = GetVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "" & weapon_type & "")
> damage2 = Rand(0, Int(weapon_level))
> Call DamageNPC(Index, Target, Damage + damage2)
> Else
> Call DamageNPC(Index, Target, Damage)
> End If
> Call SpellAnim(16, map, x, y)
> Call WeaponSkill(Index)
> End If
> End If
> End Sub
>
> Sub OnArrowHit(Index, Damage)
> Dim Target
>
> If Int(Damage) > 0 Then
> If Int(GetPlayerTarget(Index)) > 0 Then
> Target = GetPlayerTarget(Index)
> weapon = GetPlayerWeaponSlot(Index)
> If Int(weapon) > 0 Then
> weapon2 = GetPlayerInvItemNum(Index, GetPlayerWeaponSlot(Index))
> weapon_type = GetVar("scripts\weapons.ini", "" & weapon2 & "", "weapon_type")
> weapon_level = GetVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "" & weapon_type & "")
> damage2 = Rand(0, Int(weapon_level))
> Call DamagePlayer(Index, Target, Damage + damage2)
> Else
> Call DamagePlayer(Index, Target, Damage)
> End If
> Else
> Target = GetPlayerTargetNPC(Index)
> weapon = GetPlayerWeaponSlot(Index)
> If Int(weapon) > 0 Then
> weapon2 = GetPlayerInvItemNum(Index, GetPlayerWeaponSlot(Index))
> weapon_type = GetVar("scripts\weapons.ini", "" & weapon2 & "", "weapon_type")
> weapon_level = GetVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "" & weapon_type & "")
> damage2 = Rand(0, Int(weapon_level))
> Call DamageNPC(Index, Target, Damage + damage2)
> Else
> Call DamageNPC(Index, Target, Damage)
> End If
> Call WeaponSkill(Index)
> End If
> End If
> End Sub

NewChar script

> ' Executes when a new character is created.
> Sub OnNewChar(Index, CharNum)
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "sword" "1")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "sword_exp" "0")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "2hsword" "1")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "2hsword_exp" "0")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "mace" "1")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "mace_exp" "0")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "staff" "1")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "staff_exp" "0")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "dagger" "1")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "dagger_exp" "0")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "throwing" "1")
> Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "throwing_exp" "0")
> End Sub

The character file

> [WEAPONS]
> sword=3
> sword_exp=0
> 2hsword=3
> 2hsword_exp=0
> mace=3
> mace_exp=0
> staff=3
> staff_exp=0
> dagger=3
> dagger_exp=0
> throwing=3
> throwing_exp=0

Weapons File

> '[1] = weapon slot (ex. 12:  Small Sword means you put [12])
> [1]
> weapon_name=Sword
> weapon_type=sword
> [4]
> weapon_name=God Sword
> weapon_type=sword
> [6]
> weapon_name=Clerics Rod
> weapon_type=mace
> [7]
> weapon_name=Wizards Staff
> weapon_type=staff
> [16]
> weapon_name=Small Sword
> weapon_type=sword
> [27]
> weapon_name=Two Handed Sword
> weapon_type=2hsword
> [32]
> weapon_name=Survival Knife
> weapon_type=dagger
> [37]
> weapon_name=Heavy Two Handed Sword
> weapon_type=2hsword
> [41]
> weapon_name=Knights Sword
> weapon_type=sword
> [43]
> weapon_name=Heavy Blessed Rod
> weapon_type=mace
> [45]
> weapon_name=Jagged Survival Knife
> weapon_type=dagger
> [48]
> weapon_name=Heavy Staff
> weapon_type=staff
> [66]
> weapon_name=New Cleric Weapon
> weapon_type=mace
> [69]
> weapon_name=Ninja Star
> weapon_type=throwing
> [70]
> weapon_name=Wooden Sword
> weapon_type=sword
> [71]
> weapon_name=Hard Wooden Staff
> weapon_type=staff
> [72]
> weapon_name=Flimsy Rod
> weapon_type=staff
> [73]
> weapon_name=Twig
> weapon_type=dagger
> [73]
> weapon_name=Wooden Kunai
> weapon_type=throwing
> [80]
> weapon_name=Shuriken
> weapon_type=thowing

And finally the exp file

> [EXPERIENCE]
> 1=5
> 2=7
Link to comment
Share on other sites

Well, first off, you forgot some commas in Sub OnNewChar:
```
Sub OnNewChar(Index, CharNum)
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "sword", "1")
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "sword_exp", "0")
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "2hsword", "1")
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "2hsword_exp", "0")
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "mace", "1")
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "mace_exp", "0")
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "staff", "1")
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "staff_exp", "0")
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "dagger", "1")
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "dagger_exp", "0")
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "throwing", "1")
  Call PutVar("scripts\charextras\" & GetPlayerName(Index) & ".ini", "WEAPONS", "throwing_exp", "0")
End Sub
```I doubt that was the only problem, though.  When I'm not quite so busy, I'll try to dive deeper into fixing this.
Link to comment
Share on other sites

Anybody have any idea what is up with the -1/-1 durability thing? It's preventing players from using certain weapons. I have the "staff" set as a two-handed weapon with no power ups (tut thingy) and as indestructible. The weird thing is that the two-handed sword works just fine?

All help is appreciated.
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...