Raised This Month: $ Target: $400
 0% 

Trying to fix these 2 persistent errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
thatdarnkid
BANNED
Join Date: Nov 2010
Old 01-14-2011 , 19:44   Trying to fix these 2 persistent errors
Reply With Quote #1

So I'm working on my rebuild/error-free (hopefully) version of noodleboy347's Premium Mod v1.14 and I keep running into these 2 errors:

Code:
25:44: [SM] Native "GetEntProp" reported: Entity -1 (-1) is invalid
L 01/14/2011 - 18:25:44: [SM] Displaying call stack trace for plugin "premium.smx":
L 01/14/2011 - 18:25:44: [SM]   [0]  Line 692, C:\Users\User\Desktop\TF2 Stuff\Compiler\scripting\premium.sp::Premium()
L 01/14/2011 - 18:25:44: [SM]   [1]  Line 204, C:\Users\User\Desktop\TF2 Stuff\Compiler\scripting\premium.sp::Player_Spawn()
Here's the entirety of the plugin: http://pastebin.com/HXAuHKui

I've been talking to Toazron over Steam for the past...ohh....2 weeks or so, and he's really helped me out, not only with some things related to this plugin, but also with things like setting up a menu with his basic donator interface.

Now, here's the thing. I appreciate you guys posting your little tidbits of help here and there, but when it comes to coding.....I doubt I could even be called a "beginner". So I would greatly appreciate it if someone could look over the plugin, and help me out big time by either:

- Posting the fixed code so that I can copy/paste it into the plugin
or
- Copy/pasting the above pastebin contents into a new pastebin, but with the code that's causing those 2 errors fixed.

Major MAJOR credit will be given once I make sure the plugin is 100% error free, and upload it to the New Plugins section.

Last edited by thatdarnkid; 01-18-2011 at 17:52. Reason: Changing the wording of the post.
thatdarnkid is offline
dirtyminuth
Senior Member
Join Date: Sep 2009
Old 01-14-2011 , 20:26   Re: Trying to fix these 2 persistent errors
Reply With Quote #2

It would help if you highlighted the stack trace function lines.

Regardless, I'd bet that the client has an invalid slot 0 weapon and the following line is executed:
PHP Code:
SetEntProp(GetPlayerWeaponSlot(client0), Prop_Send"m_iClip1"GetEntProp(GetPlayerWeaponSlot(client0), Prop_Send"m_iClip1") + cClip); 
__________________
dirtyminuth is offline
thatdarnkid
BANNED
Join Date: Nov 2010
Old 01-14-2011 , 20:37   Re: Trying to fix these 2 persistent errors
Reply With Quote #3

Quote:
Originally Posted by dirtyminuth View Post
It would help if you highlighted the stack trace function lines.

Regardless, I'd bet that the client has an invalid slot 0 weapon and the following line is executed:
PHP Code:
SetEntProp(GetPlayerWeaponSlot(client0), Prop_Send"m_iClip1"GetEntProp(GetPlayerWeaponSlot(client0), Prop_Send"m_iClip1") + cClip); 
Hmm...what exactly would an invalid slot 0 weapon be? I'm not exactly sure what that means, but it intrigues me...

EDIT: I just changed my original post. I changed the code tags to php tags.
thatdarnkid is offline
dirtyminuth
Senior Member
Join Date: Sep 2009
Old 01-14-2011 , 21:02   Re: Trying to fix these 2 persistent errors
Reply With Quote #4

Quote:
Originally Posted by thatdarnkid View Post
Hmm...what exactly would an invalid slot 0 weapon be? I'm not exactly sure what that means, but it intrigues me...

EDIT: I just changed my original post. I changed the code tags to php tags.
Well, from the code I quoted earlier, you call:
PHP Code:
GetEntProp(GetPlayerWeaponSlot(client0), Prop_Send"m_iClip1"
Inside that, you call:
PHP Code:
GetPlayerWeaponSlot(client0
If GetPlayerWeaponSlot returns -1, SM will throw an error like you're experiencing.
__________________
dirtyminuth is offline
thatdarnkid
BANNED
Join Date: Nov 2010
Old 01-14-2011 , 21:16   Re: Trying to fix these 2 persistent errors
Reply With Quote #5

Quote:
Originally Posted by dirtyminuth View Post
Well, from the code I quoted earlier, you call:
PHP Code:
GetEntProp(GetPlayerWeaponSlot(client0), Prop_Send"m_iClip1"
Inside that, you call:
PHP Code:
GetPlayerWeaponSlot(client0
If GetPlayerWeaponSlot returns -1, SM will throw an error like you're experiencing.
OHH. See, little gears inside my head are starting to turn and I'm starting to understand this stuff.

But what I don't get....is what item would count as -1...

Slot 0 is primary, slot 1 is secondary and slot 2 is melee, correct? What could be making SM throw that error?....
thatdarnkid is offline
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 01-14-2011 , 21:38   Re: Trying to fix these 2 persistent errors
Reply With Quote #6

If the player doesn't carry a primary/secondary or knife, it returns -1 for that weaponindex.

PHP Code:
GetUserFlagBits(client) && PREMIUMFLAG 
should be
PHP Code:
GetUserFlagBits(client) & PREMIUMFLAG 
it's the bitwise AND.
__________________
Peace-Maker is offline
dirtyminuth
Senior Member
Join Date: Sep 2009
Old 01-14-2011 , 21:40   Re: Trying to fix these 2 persistent errors
Reply With Quote #7

Quote:
Originally Posted by thatdarnkid View Post
OHH. See, little gears inside my head are starting to turn and I'm starting to understand this stuff.

But what I don't get....is what item would count as -1...

GetPlayerWeaponSlot returns an index to an entity. That entity is the weapon held by said client in said slot. If the client, for some reason, does not have a weapon in that slot, GetPlayerWeaponSlot will return -1.


Look at
SetGrenadeAmmo(client, ammo, index, slot) in your first post. Notice the use of IsValidEntity. You need to implement something similar in other parts of your code (e.g. the code we've been discussing).
__________________
dirtyminuth is offline
thatdarnkid
BANNED
Join Date: Nov 2010
Old 01-15-2011 , 00:41   Re: Trying to fix these 2 persistent errors
Reply With Quote #8

Quote:
Originally Posted by Peace-Maker View Post
If the player doesn't carry a primary/secondary or knife, it returns -1 for that weaponindex.

PHP Code:
GetUserFlagBits(client) && PREMIUMFLAG 
should be
PHP Code:
GetUserFlagBits(client) & PREMIUMFLAG 
it's the bitwise AND.
Alrighty. That's #1 on my list of things to do to the coding.


Quote:
Originally Posted by dirtyminuth View Post

GetPlayerWeaponSlot returns an index to an entity. That entity is the weapon held by said client in said slot. If the client, for some reason, does not have a weapon in that slot, GetPlayerWeaponSlot will return -1.


Look at
SetGrenadeAmmo(client, ammo, index, slot) in your first post. Notice the use of IsValidEntity. You need to implement something similar in other parts of your code (e.g. the code we've been discussing).
Hmm....After reading this post a few times, the only thing my tired brain can pull out of it is "Change IsValidEntity to IsClientInGame in the SetGrenadeAmmo(client, ammo, index, slot)"

Not sure if that was the implication =\ But I'll pick up wherever this leaves off tomorrow. I'm in need of alot of sleep.
thatdarnkid is offline
dirtyminuth
Senior Member
Join Date: Sep 2009
Old 01-15-2011 , 00:46   Re: Trying to fix these 2 persistent errors
Reply With Quote #9

Quote:
Originally Posted by thatdarnkid View Post
Hmm....After reading this post a few times, the only thing my tired brain can pull out of it is "Change IsValidEntity to IsClientInGame in the SetGrenadeAmmo(client, ammo, index, slot)"

Not sure if that was the implication =\ But I'll pick up wherever this leaves off tomorrow. I'm in need of alot of sleep.
No. SetGrenadeAmmo is correct. The single line of code I initially quoted is wrong. You need to add an IsValidEntity check to the return value of GetPlayerWeaponSlot in this line.

Man, helping some people is like herding cats.
__________________
dirtyminuth is offline
thatdarnkid
BANNED
Join Date: Nov 2010
Old 01-15-2011 , 01:54   Re: Trying to fix these 2 persistent errors
Reply With Quote #10

Quote:
Originally Posted by dirtyminuth View Post
No. SetGrenadeAmmo is correct. The single line of code I initially quoted is wrong. You need to add an IsValidEntity check to the return value of GetPlayerWeaponSlot in this line.

Man, helping some people is like herding cats.
Lol

Gimme a break. I'm tired, I should be asleep right now, but I'm not. Plus, keep in mind, I've never done this coding before. I'm basically just going through the code, reading everything and seeing what my brain can translate for me.

Ok, after reading....and re-reading...and re-re-reading all your posts, my brain finally decided to stop being stupid and I know the line you're talking about:
PHP Code:
SetEntProp(GetPlayerWeaponSlot(client0), Prop_Send"m_iClip1"GetEntProp(GetPlayerWeaponSlot(client0), Prop_Send"m_iClip1") + cClip); 
^-That much is clear to me. Now to rack my brains trying to figure out where to toss in the IsValidEntity()....

Last edited by thatdarnkid; 01-15-2011 at 02:00.
thatdarnkid is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:52.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode