Raised This Month: $ Target: $400
 0% 

Help regarding "CurWeapon"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 09-27-2015 , 05:56   Help regarding "CurWeapon"
Reply With Quote #1

Biohazard mode have this function:
PHP Code:
register_event("CurWeapon""event_curweapon""be""1=1"
PHP Code:
public event_curweapon(id)
{
    if(!
is_user_alive(id))
        return 
PLUGIN_CONTINUE
    
    
static weapon
    weapon 
read_data(2)

    static 
ammotype
    ammotype 
get_pcvar_num(cvar_ammo)
    
    if(!
ammotype || (AMMOWP_NULL & (1<<weapon)))
        return 
PLUGIN_CONTINUE

    
static maxammo
    
switch(ammotype)
    {
        case 
1maxammo g_weapon_ammo[weapon][MAX_AMMO]
        case 
2maxammo g_weapon_ammo[weapon][MAX_CLIP]
    }

    if(!
maxammo)
        return 
PLUGIN_CONTINUE
    
    
switch(ammotype)
    {
        case 
1:
        {
            static 
ammo
            ammo 
cs_get_user_bpammo(idweapon)
            
            if(
ammo 1
                
cs_set_user_bpammo(idweaponmaxammo)
        }
        case 
2:
        {
            static 
clipclip read_data(3)
            if(
clip 1)
            {
                static 
weaponname[32]
                
get_weaponname(weaponweaponname31)
                
                static 
ent 
                ent 
find_ent_by_owner(-1weaponnameid)
                
                
cs_set_weapon_ammo(entmaxammo)
            }
        }
    }    
    return 
PLUGIN_CONTINUE

The purpose of this is to adjust whether the players have unlimited ammo,or unlimited clip.
My question is:Could this be implemented without the use of Curweapon?
Krtola is offline
Send a message via Skype™ to Krtola
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-27-2015 , 09:25   Re: Help regarding "CurWeapon"
Reply With Quote #2

Yes, most things can be done multiple ways. Why do you want to not use the CurWeapon event?
__________________
Bugsy is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 09-27-2015 , 11:37   Re: Help regarding "CurWeapon"
Reply With Quote #3

I read everywhere that the function CurWeapon call very often and that can cause lag in game.
So I decided to changde/delete CurWeapon in every plugin.
About this topic : many plugin I have reviewed on this forum but everywhere is used CurWeapon.
Give me an example for this problem,how can I realize this please?
Krtola is offline
Send a message via Skype™ to Krtola
Depresie
Veteran Member
Join Date: Nov 2013
Old 09-28-2015 , 06:31   Re: Help regarding "CurWeapon"
Reply With Quote #4

Well, you could use Ham Primary Attack i think, but it will be called almost as often as CurWeapon does...
I don't think the author of Biohazzard used it in that case because it was inefficient...
Depresie is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 09-28-2015 , 06:40   Re: Help regarding "CurWeapon"
Reply With Quote #5

Ham Primary Attack=bad idea
I have in mind that this function does the occasion of each reload(every time when player reload weapon),but do not know how I can do that.
Krtola is offline
Send a message via Skype™ to Krtola
Depresie
Veteran Member
Join Date: Nov 2013
Old 09-28-2015 , 16:24   Re: Help regarding "CurWeapon"
Reply With Quote #6

There is Ham_Weapon_Reload, and you can check the weapon's bullets there, but i think you will encounter bugs that way...
Stick to CurWeapon, i use it in over 10 plugins and i have 20-30% cpu usage on a heavy modified ZP 5.0 version...

You are wasting time trying to optimize that code... Biohazzard has 2000 lines of code.. i got 10k only in nade modes plugin...

Last edited by Depresie; 09-28-2015 at 16:26.
Depresie is offline
z0mbiland
Senior Member
Join Date: Jan 2013
Old 09-29-2015 , 15:52   Re: Help regarding "CurWeapon"
Reply With Quote #7

you don't have a good host server or what? i play on your server and i have allmost full fps / no lagg; some players have a bad internet connection and they are moving in "teleporting mode" ))); and yes this depends on a good configuration off plugins; about eating cpu/net packets/net bandwidth space - if you have a low bandwidth this may cause lag to players/ 15 players - 15 slots - more bandwidth and fast data packet sender to client side; some net packets drop it and that information never come to player = this make the screen freeze for a ms/short time; these errors can affect cpu and make it highter; are few zombie servers full of plugins installed and well customized - they don't have any problems with lag or fps;
when you write in console "developer 1" you will see you have an repeating error from a weapon, this flood the backgroung of the client console and eat some of his fps!
z0mbiland is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 10-02-2015 , 11:41   Re: Help regarding "CurWeapon"
Reply With Quote #8

curweapon is called when the hud info regarding wep is changed
that means it will be called for every shot you take, every reload and when you switch weps

since your code is about bullets, there is no better function for that
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
Reply


Thread Tools
Display Modes

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 22:13.


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