Raised This Month: $ Target: $400
 0% 

[Help] VIP/Gunmenu Plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LegacyCode
Member
Join Date: Apr 2017
Old 05-19-2017 , 11:54   [Help] VIP/Gunmenu Plugin
Reply With Quote #1

Hello,

so, I did this VIP/gunmenu plugin. I rewrote it a couple of times, too.
What I don't know is if I did anything wrong, where I can optimize it, if anything is real stupid...
Most of the times I just dive straight in without planning anything beforehand. Sometimes it works.
The server administrator told me the server crashed after like 20 rounds, but I'm not sure if it's because of this plugin. Is this too unspecific of a question? Let me know. Files attached.

Thanks for your help.

- LegacyCode
Attached Files
File Type: sma Get Plugin or Get Source (lpc_vip_privileges.sma - 548 views - 48.3 KB)
File Type: inc chatcolor.inc (4.9 KB, 125 views)
File Type: ini lpc_gunmenu.ini (1.4 KB, 43 views)

Last edited by LegacyCode; 05-23-2017 at 11:22.
LegacyCode is offline
RAW_192
Senior Member
Join Date: Feb 2017
Old 05-19-2017 , 15:18   Re: [Help] VIP/Gunmenu Plugin
Reply With Quote #2

If you paste the error logs too it would be useful
RAW_192 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-20-2017 , 03:22   Re: [Help] VIP/Gunmenu Plugin
Reply With Quote #3

Your question was fine. We can look at codes and give advice.
__________________

Last edited by HamletEagle; 05-20-2017 at 03:22.
HamletEagle is offline
LegacyCode
Member
Join Date: Apr 2017
Old 05-20-2017 , 10:13   Re: [Help] VIP/Gunmenu Plugin
Reply With Quote #4

Quote:
Originally Posted by HamletEagle View Post
Your question was fine. We can look at codes and give advice.
I wasn't sure, because it's not a "small" plugin either... then I'll reupload now.

Quote:
Originally Posted by RAW_192 View Post
If you paste the error logs too it would be useful
There are no error logs so far, because I don't have access to the server it's used on and the server administrator can't provide any logs.

As a side note: I see things I could've done better (and mistakes) everytime I look at the code again, but at this point I thought it might be better if someone experienced looks over it.

- LegacyCode

Last edited by LegacyCode; 05-23-2017 at 11:23.
LegacyCode is offline
LegacyCode
Member
Join Date: Apr 2017
Old 05-23-2017 , 15:30   Re: [Help] VIP/Gunmenu Plugin
Reply With Quote #5

Hello,

I finally got the error logs. Can someone tell me what I'm doing wrong?
I know what "Invalid array handle provided" means, but I don't know why it actually even occurs as I'm not able to reproduce this.

Code:
L 05/22/2017 - 05:13:51: [AMXX] Displaying debug trace (plugin "lpc_vip_privileges.amxx")
L 05/22/2017 - 05:13:51: [AMXX] Run time error 10: native error (native "abort")
L 05/22/2017 - 05:13:51: [AMXX]    [0] lpc_vip_privileges.sma::populate_menus (line 795)
L 05/22/2017 - 05:13:51: [AMXX]    [1] lpc_vip_privileges.sma::plugin_init (line 266)

L 05/22/2017 - 05:14:42: Invalid array handle provided (0)
L 05/22/2017 - 05:14:42: [AMXX] Displaying debug trace (plugin "lpc_vip_privileges.amxx")
L 05/22/2017 - 05:14:42: [AMXX] Run time error 10: native error (native "ArrayDestroy")
L 05/22/2017 - 05:14:42: [AMXX]    [0] lpc_vip_privileges.sma::plugin_end (line 281)

L 05/22/2017 - 05:15:08: Invalid array handle provided (0)
L 05/22/2017 - 05:15:08: [AMXX] Displaying debug trace (plugin "lpc_vip_privileges.amxx")
L 05/22/2017 - 05:15:08: [AMXX] Run time error 10: native error (native "ArraySize")
L 05/22/2017 - 05:15:08: [AMXX]    [0] lpc_vip_privileges.sma::user_show_mainmenu (line 1368)
L 05/22/2017 - 05:15:08: [AMXX]    [1] lpc_vip_privileges.sma::user_reset_mainmenu (line 1274)

L 05/22/2017 - 05:15:12: Invalid array handle provided (0)
L 05/22/2017 - 05:15:12: [AMXX] Displaying debug trace (plugin "lpc_vip_privileges.amxx")
L 05/22/2017 - 05:15:12: [AMXX] Run time error 10: native error (native "ArraySize")
L 05/22/2017 - 05:15:12: [AMXX]    [0] lpc_vip_privileges.sma::user_show_mainmenu (line 1368)
L 05/22/2017 - 05:15:12: [AMXX]    [1] lpc_vip_privileges.sma::user_reset_mainmenu (line 1254)

L 05/22/2017 - 05:15:14: Invalid array handle provided (0)
L 05/22/2017 - 05:15:14: [AMXX] Displaying debug trace (plugin "lpc_vip_privileges.amxx")
L 05/22/2017 - 05:15:14: [AMXX] Run time error 10: native error (native "ArraySize")
L 05/22/2017 - 05:15:14: [AMXX]    [0] lpc_vip_privileges.sma::user_show_mainmenu (line 1368)
L 05/22/2017 - 05:15:14: [AMXX]    [1] lpc_vip_privileges.sma::user_reset_mainmenu (line 1254)
L 05/22/2017 - 05:15:14: [AMXX]    [2] lpc_vip_privileges.sma::user_reset_mainmenu (line 1252)

L 05/22/2017 - 05:16:13: Invalid array handle provided (0)
L 05/22/2017 - 05:16:13: [AMXX] Displaying debug trace (plugin "lpc_vip_privileges.amxx")
L 05/22/2017 - 05:16:13: [AMXX] Run time error 10: native error (native "ArraySize")
L 05/22/2017 - 05:16:13: [AMXX]    [0] lpc_vip_privileges.sma::user_show_mainmenu (line 1368)
L 05/22/2017 - 05:16:13: [AMXX]    [1] lpc_vip_privileges.sma::event_player_spawn (line 336)
- LegacyCode

Last edited by LegacyCode; 05-23-2017 at 15:36.
LegacyCode is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-23-2017 , 18:22   Re: [Help] VIP/Gunmenu Plugin
Reply With Quote #6

It usually occurs when you try to use array functions before creating the array with ArrayCreate.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
LegacyCode
Member
Join Date: Apr 2017
Old 05-23-2017 , 19:05   Re: [Help] VIP/Gunmenu Plugin
Reply With Quote #7

Hello,

I use ArrayCreate in plugin_init() -> populate_menus(), where I also read the .ini file to populate the gunmenu with data.

Is that the wrong place to read the ini file? Also in the error log you can see it says something about "abort", which I used in this version I uploaded. Why is that wrong?
Is this maybe the cause why ArrayCreate is never called? ArrayCreate comes after this:

PHP Code:
    get_configsdirg_ConfigsDircharsmax(g_ConfigsDir) )
    
formatg_ConfigsDircharsmax(g_ConfigsDir), "%s/_LPC/lpc_gunmenu.ini"g_ConfigsDir )

    
g_FilePointer fopeng_ConfigsDir"r" )

    if ( !
g_FilePointer )
        
abortAMX_ERR_NATIVE"[LPC] Configuration File (%s) not found"g_ConfigsDir 
I took the abort() function from admincmd.sma but it seems I'm using it wrong... I want the plugin not to run at all without the ini file.

- LegacyCode

Last edited by LegacyCode; 05-23-2017 at 19:08.
LegacyCode is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-23-2017 , 19:33   Re: [Help] VIP/Gunmenu Plugin
Reply With Quote #8

When are you using ArrayDestroy()? (I'm on my phone and can't view the file - this is why it's better to upload the code rather than the file)

abort() is used to throw an error in the log files, so you're using it correctly. You need set_fail_state() on its place if you want to stop the plugin.
__________________

Last edited by OciXCrom; 05-23-2017 at 19:47.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
LegacyCode
Member
Join Date: Apr 2017
Old 05-23-2017 , 20:59   Re: [Help] VIP/Gunmenu Plugin
Reply With Quote #9

Quote:
Originally Posted by OciXCrom View Post
When are you using ArrayDestroy()? (I'm on my phone and can't view the file - this is why it's better to upload the code rather than the file)

abort() is used to throw an error in the log files, so you're using it correctly. You need set_fail_state() on its place if you want to stop the plugin.
ArrayDestroy() on plugin_end() for all arrays. I didn't want to upload 1700+ lines of code directly...
Cool, didn't know about set_fail_state(), will use that one. Thanks! Testing new version on server today and see if it crashes again.

- LegacyCode

Last edited by LegacyCode; 05-24-2017 at 04:00.
LegacyCode is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 05-24-2017 , 10:27   Re: [Help] VIP/Gunmenu Plugin
Reply With Quote #10

The rest of the errors may possibly be because you used abort(). Try again.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 21:59.


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