Raised This Month: $51 Target: $400
 12% 

Replacing Holster and Deploy


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 10-07-2014 , 14:48   Replacing Holster and Deploy
Reply With Quote #1

I have made this API (look in attachment). What it basicly does is gives user weapon(lol), if it is normal, then it just checks that weapons ammo on Holster(removes from player) and on Deploy(gives back). You might ask why, it is because I wan't ammo to be weapon specific not player, so each weapon has it's own ammo count. Also, there is a way to give other features with API - models, attack speed, reload time etc.
So, where is the problem? It is with that many RegisterHam calls (I think), because when I register them in plugin_init, server crashes on map change (server starts normally, after map change = crash). So I though about adding it to plugin_precache, it fixed it a bit. Now it doesn't crash on every mapchange, but randomly and gives this crash log: https://forums.alliedmods.net/showpo...31&postcount=6

So my question is, what to change, so there won't be so many RegisterHam? Can I determine in CurWeapon event if it was holstered or deployed?
Attached Files
File Type: sma Get Plugin or Get Source (cs_weapons_api.sma - 577 views - 16.7 KB)
File Type: inc cs_weapons_api.inc (2.4 KB, 164 views)
File Type: inc cs_weapons_api_stocks.inc (2.9 KB, 153 views)
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness

Last edited by GuskiS; 10-07-2014 at 15:50.
GuskiS is offline
Xalus
Veteran Member
Join Date: Dec 2009
Location: Belgium
Old 10-07-2014 , 15:01   Re: Replacing Holster and Deploy
Reply With Quote #2

Error: attachment not found.
__________________
Retired.
Xalus is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 10-07-2014 , 15:40   Re: Replacing Holster and Deploy
Reply With Quote #3

Ham doesn't crash because of too many RegiserHam calls and CurWeapon sucks. Fix your installation instead of searching for pointless workarounds.
__________________
In Flames we trust!
Nextra is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 10-07-2014 , 15:52   Re: Replacing Holster and Deploy
Reply With Quote #4

Quote:
Originally Posted by Xalus View Post
Error: attachment not found.
Hehe, forgot to add, thanks, added.

Quote:
Originally Posted by Nextra View Post
Ham doesn't crash because of too many RegiserHam calls and CurWeapon sucks. Fix your installation instead of searching for pointless workarounds.
Well, you can try. For me (and others) it was crashing if I put all those Holster/Deploy in plugin_init.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 10-07-2014 , 16:07   Re: Replacing Holster and Deploy
Reply With Quote #5

PHP Code:
#include <amxmodx>
#include <hamsandwich>

#pragma semicolon 1
#pragma ctrlchar '\'

new hprehpostdpredpost;

public 
plugin_init() {
    
register_plugin("Hamtest""0.0.1""Nextra");

    new 
wpnname[32];
    for(new 
wpn CSW_P228wpn <= CSW_P90; ++wpn) {
        if (
get_weaponname(wpnwpnnamecharsmax(wpnname))) {
            for (new 
0100000; ++i) {
                
RegisterHam(Ham_Item_Holsterwpnname"holster_pre_whynot");
                
RegisterHam(Ham_Item_Deploywpnname"deploy_pre_whynot");
                
RegisterHam(Ham_Item_Holsterwpnname"holster_post_whynot", .Post 1);
                
RegisterHam(Ham_Item_Deploywpnname"deploy_post_whynot", .Post 1);
            }
        }
    }

    
register_clcmd("hamtest""cmd_hamtest");
}

public 
holster_pre_whynot(const ent) {
    ++
hpre;
}

public 
deploy_pre_whynot(const ent) {
    ++
dpre;
}

public 
holster_post_whynot(const ent) {
    ++
hpost;
}

public 
deploy_post_whynot(const ent) {
    ++
dpost;
}

public 
cmd_hamtest(const client) {
    
client_print(clientprint_chat"hpre: %d hpost: %d dpre: %d dpost: %d"hprehpostdpredpost);
    
hpre hpost dpre dpost 0;

Doesn't crash.
__________________
In Flames we trust!

Last edited by Nextra; 10-07-2014 at 16:10.
Nextra is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 10-07-2014 , 16:15   Re: Replacing Holster and Deploy
Reply With Quote #6

Maybe you could test my plugin please? :/
Just put that cycle from plugin_precache to plugin_init.
Start server, join, change map = crash.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness

Last edited by GuskiS; 10-07-2014 at 16:16.
GuskiS is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 10-07-2014 , 16:26   Re: Replacing Holster and Deploy
Reply With Quote #7

It doesn't crash, and there's no reason it ever should. I have been running multiple plugins with similar or even more Ham usage for years, without any issues.
__________________
In Flames we trust!
Nextra is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 10-07-2014 , 16:35   Re: Replacing Holster and Deploy
Reply With Quote #8

Did you really test it?

EDIT: Just tested myself, it crashes.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness

Last edited by GuskiS; 10-07-2014 at 16:38.
GuskiS is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 10-07-2014 , 16:41   Re: Replacing Holster and Deploy
Reply With Quote #9

Yes I tested it. And I put a 0 to 100 for loop around it just to be sure.
__________________
In Flames we trust!
Nextra is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 10-07-2014 , 16:53   Re: Replacing Holster and Deploy
Reply With Quote #10

Well, that is just weird, cause I just installed new amxmodx, put default plugins and this one, and it still crashes.
Linux OS, newest HLDS, newest AMXX, Metamod v1.21p37.

Here is the crashing version.

Hmm, it seems that this crash happens when player decides to join.
Start server, player joins = works fines.
Server changes map, player joins = crash.
When I put it in plugin_precache - it works fine.
Attached Files
File Type: sma Get Plugin or Get Source (cs_weapons_api.sma - 656 views - 16.7 KB)
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS 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 18:21.


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