AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Unknow misterious stack error... (https://forums.alliedmods.net/showthread.php?t=244649)

Flick3rR 07-21-2014 15:04

Unknow misterious stack error...
 
Hey, guys... I have been wondering for lot of time about this, but I couldn't find the reason. The problem is one goddamn annoying stack error (run time error 3). The code:
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <fun>

#define PLUGIN "Admin Extras"
#define VERSION "1.0"
#define AUTHOR "Flicker"

#define ACCESS ADMIN_RCON

new g_msgMoneyg_hookMoneyMsg
new g_iNewUserMoney

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("DeathMsg""onDeathMsgEvent""a")
    
    
g_msgMoney get_user_msgid("Money")
}

public 
onDeathMsgEvent()
{
    new 
atk read_data(1)
    new 
hs read_data(3)
    
    
set_user_health(atkclamp(get_user_health(atk) + hs 30 150150))
    
    
set_user_armor(atkclamp(get_user_armor(atk) + hs 20 100200))
    
    
give_item(atk"weapon_hegrenade")
    
cs_set_user_bpammo(atkCSW_HEGRENADEhs 1)
    
    
    
g_iNewUserMoney clamp(cs_get_user_money(atk) + hs 500 300016000)
    
g_hookMoneyMsg register_message(g_msgMoney"onMoneyMessage")
}

public 
onMoneyMessage(msgidmsgdestid)
{
    
unregister_message(g_msgMoneyg_hookMoneyMsg)
    
set_pdata_int(id115g_iNewUserMoney5)
    
set_msg_arg_int(1ARG_LONGg_iNewUserMoney)


Really, no lines, nothing. Just
Code:

L 07/21/2014 - 22:01:24: Start of error session.
L 07/21/2014 - 22:01:24: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20140721.log")
L 07/21/2014 - 22:01:24: [AMXX] Displaying debug trace (plugin "AdminExtras.amxx")
L 07/21/2014 - 22:01:24: [AMXX] Run time error 3: stack error

and server dies..

klippy 07-21-2014 15:33

Re: Unknow misterious stack error...
 
Why are you setting player money in such way? Just use cs_set_user_money(), there is nothing wrong with it. All that "Money" message stuff is unnecessary. Not sure, but that may be causing crashes.
And you should use min() instead of clamp() in this situation, it is more suitable.

NikKOo31 07-21-2014 15:45

Re: Unknow misterious stack error...
 
I agree with KliPPy

Also, you are not checking if attacker is a valid player

Flick3rR 07-21-2014 16:27

Re: Unknow misterious stack error...
 
Well, firstly (of course) I tried with cs_set_user_money. But, the money HUD is f*ckin up and shows some random values?! And I kindly saw this (and stole it) from Exolent (Kill Money plugin). That's all.
Btw, it was about to remove the original giving of money on kill, that's why I used that way.
EDIT: Btw (again), this code is now overflowing me :D
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <fun>

#define PLUGIN "Admin Extras"
#define VERSION "1.0"
#define AUTHOR "Flicker"

#define ACCESS ADMIN_RCON

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("DeathMsg""onDeathMsgEvent""a")
}

public 
onDeathMsgEvent()
{
    new 
atk read_data(1)
    new 
hs read_data(3)
    
    if(!(
get_user_flags(atk) & ACCESS) || !is_user_connected(atk) || atk == read_data(2))
        return 
PLUGIN_HANDLED
    
    set_user_health
(atkclamp(get_user_health(atk) + hs 30 150150))
    
    
set_user_armor(atkclamp(get_user_armor(atk) + hs 20 100200))
    
    
give_item(atk"weapon_hegrenade")
    
cs_set_user_bpammo(atkCSW_HEGRENADEhs 1)
    
    
cs_set_user_money(atkclamp(cs_get_user_money(atk) + hs 500 300016000))
    
    return 
PLUGIN_CONTINUE




All times are GMT -4. The time now is 13:07.

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