![]() |
hasweapon() not working correctly?
Alright, yesterday I ran into a problem. I learned the hard way that there's a limit to how many weapons a player has. Since my server will have a lot of classes (in the rpg sense) it will also have a lot of skills. These skills will need to be stored as weapons. So I decided that I will have a system that adds weapons if they exist in the player's skill list (stored in a variable) and delete the weapons if they are not listed in the skills variable. Right now I'm only working on the former part (adding the weaps) as I'm sure I can figure out the latter part on my own for the most part.
Anyways, the problem here is that hasweapon() always returns false, I've returned to a previous thread that I posted and tried the "player.hasWeapon()" that was posted there, but since hasWeapon is not the same as hasweapon, it didn't work either. (on a side note, i've also tried player.hasweapon() but that's apparently not a valid form of the command) Here's the script: PHP Code:
Once this is working, would I use findweapon("weapon name").destroy(); on the clientside to delete weapons from the player? Just afraid of the weapon being deleted from the npcserver like it did last time. I called this.destroy() in a weapon script before to delete it from the player. Just want to make sure that it doesn't behave unexpectedly. |
why not remove it serverside with removeweapon()
|
destroy() will only delete the weapon NPC when used on the serverside. As stated, though, you should use removeWeapon() to remove a weapon (duh) from the player.
|
Alright. I wasn't aware of removeWeapon();
what about my hasweapon problem though? Any ideas? |
You could use a custom function for it:
PHP Code:
|
Yeah hasweapon definitely seems to be depreciated now both with and without "player.", I think you have to use:
PHP Code:
|
Hm. I went with mike's suggestion for now. It seems more secure and this is one of the few weapons that checks to see if a player has a weapon. It appears to be working at the moment. Thanks for the help!
|
to clarify what Crow and Thor means; hasWeapon is GS1 and does not exist in GS2.
however, you shouldn't have to loop thought the player's weapons to find if you have a weapon or not. findWeapon() should do the trick. findWeapon(str weaponname) - returns str (object?) if you have the weapon, or 0 if you don't have it. with this, you could make a hasWeapon(weap) function by checking if findWeapon() is equal to 0, if that is so, return false, if not, return true. this works on both client and serverside. e; no pre-scripted for you ^^, should be simple enuf with my "description" |
Quote:
|
Quote:
Quote:
|
There's also:
temp.hasWeapon = findweapon("weapon") in player.weapons; |
Quote:
not /scripthelp hasWeapon (caps difference) |
Quote:
Quote:
...what? there's no case sensitivity on scripthelp btw. |
Quote:
Script help for 'hasweapon': hasweapon(str) - returns object TServerPlayer hasweapon(str) - returns object |
hasweapon was removed
findweapon("weapon") returns boolean (true / false) |
All times are GMT +2. The time now is 02:14 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.