Raised This Month: $ Target: $400
 0% 

error 10 (cs_get_user_armor)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ardonicek
Senior Member
Join Date: Feb 2013
Location: My home
Old 08-26-2013 , 06:49   error 10 (cs_get_user_armor)
Reply With Quote #1

This crashes server after spamming console with error 10 on cs_get_user_armor

Fix please?


PHP Code:
    if(Level[id] == 69
    { 
        new 
CsArmorType:armortype;
        if (
cs_get_user_armor(idarmortype) <= 100)
    {
        new 
CsArmorType:armortype;
        
cs_set_user_armor(idcs_get_user_armor(idarmortype) + 30armortype);
    }
    
set_user_rendering(idkRenderFxNone000kRenderTransAlpha185)
    
set_user_gravity(id0.7)
    
cs_set_user_money(id, (cs_get_user_money(id) + 1000))
    
cs_set_user_nvg(id1)
    
give_item(id"weapon_hegrenade")
    
give_item(id"weapon_flashbang")

__________________
Latest plugin: dHUD Round | Timeleft
Ardonicek is offline
Send a message via ICQ to Ardonicek Send a message via Skype™ to Ardonicek
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 08-26-2013 , 10:18   Re: error 10 (cs_get_user_armor)
Reply With Quote #2

Give us the complete error message
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 08-26-2013 , 10:22   Re: error 10 (cs_get_user_armor)
Reply With Quote #3

I guess that you forgot to check is user alive? It's only guess because I don't know what kind of really are.
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 08-26-2013 , 10:37   Re: error 10 (cs_get_user_armor)
Reply With Quote #4

Quote:
Originally Posted by ~Ice*shOt View Post
I guess that you forgot to check is user alive? It's only guess because I don't know what kind of really are.
Remember: is_user_alive enforcing a is_user_connected, so you do not need to check is_user_connected it is only is_user_alive



Post full code to better resolution, but you need like this

if(Level[id] == 69)

change to

if((Level[id] == 69) && is_user_alive(id))
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 08-26-2013 at 10:38.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 08-26-2013 , 11:32   Re: error 10 (cs_get_user_armor)
Reply With Quote #5

i'm guessing the error comes from trying to set armor +30 with CS_ARMOR_NONE type

edit: or not

Last edited by jimaway; 08-26-2013 at 11:33.
jimaway is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-26-2013 , 16:35   Re: error 10 (cs_get_user_armor)
Reply With Quote #6

Quote:
Originally Posted by ^SmileY View Post
Remember: is_user_alive enforcing a is_user_connected, so you do not need to check is_user_connected it is only is_user_alive



Post full code to better resolution, but you need like this

if(Level[id] == 69)

change to

if((Level[id] == 69) && is_user_alive(id))
Since Level[id] is checked before is_user_alive() you may get an index out of bounds error on Level[].
They should be switched for best result.
__________________
Black Rose is offline
Ardonicek
Senior Member
Join Date: Feb 2013
Location: My home
Old 08-26-2013 , 16:54   Re: error 10 (cs_get_user_armor)
Reply With Quote #7

Quote:
Originally Posted by Black Rose View Post
Since Level[id] is checked before is_user_alive() you may get an index out of bounds error on Level[].
They should be switched for best result.

So it should be like this?

PHP Code:
if((is_user_alive(id) && (Level[id] == 69)) 
__________________
Latest plugin: dHUD Round | Timeleft
Ardonicek is offline
Send a message via ICQ to Ardonicek Send a message via Skype™ to Ardonicek
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 08-26-2013 , 17:07   Re: error 10 (cs_get_user_armor)
Reply With Quote #8

It depends how the complete function looks. For this small script either way is fine...

Code:
if ( ! is_user_alive(id) )     return; if ( Level[id] == 69 ) {     // ...

Code:
if ( is_user_alive(id) && Level[id] == 69 ) {     // ...
__________________

Last edited by Black Rose; 08-26-2013 at 17:10.
Black Rose is offline
Ardonicek
Senior Member
Join Date: Feb 2013
Location: My home
Old 08-27-2013 , 02:03   Re: error 10 (cs_get_user_armor)
Reply With Quote #9

No more console errors, i think it works, thanks.
__________________
Latest plugin: dHUD Round | Timeleft
Ardonicek is offline
Send a message via ICQ to Ardonicek Send a message via Skype™ to Ardonicek
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 08-27-2013 , 07:23   Re: error 10 (cs_get_user_armor)
Reply With Quote #10

Quote:
Originally Posted by Black Rose View Post
It depends how the complete function looks. For this small script either way is fine...

Code:
if ( ! is_user_alive(id) )     return; if ( Level[id] == 69 ) {     // ...

Code:
if ( is_user_alive(id) && Level[id] == 69 ) {     // ...

When you use a IF statement correctly you do not need an return in your code...
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 18:52.


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