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

Knife Models [XP System & Skills Support]


Post New Thread Reply   
 
Thread Tools Display Modes
highcoder
Member
Join Date: Jun 2018
Old 06-05-2018 , 08:22   Re: Knife Models
Reply With Quote #61

Quote:
Originally Posted by OciXCrom View Post
Try moving the default knife on top. Are you using the latest version of the plugin?

// Edit: nevermind, I saw what the problem is. Fixed. Download the new version (v2.1.1).
Thanks for your reply and update. I will try the plugin in the day.
highcoder is offline
highcoder
Member
Join Date: Jun 2018
Old 06-05-2018 , 15:12   Re: Knife Models
Reply With Quote #62

Quote:
Originally Posted by OciXCrom View Post
Try moving the default knife on top. Are you using the latest version of the plugin?

// Edit: nevermind, I saw what the problem is. Fixed. Download the new version (v2.1.1).
Thanks for your reply and update again. I tried the plugin and not see a problem with the flag. The first written knife to KnifeModels.ini is the default knife. Is this a problem? Because in the source file shown the default knife directory.
highcoder is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-05-2018 , 15:40   Re: Knife Models
Reply With Quote #63

It's not a problem. I would actually recommend you to leave the first knife to be the default one.
__________________

Last edited by OciXCrom; 06-05-2018 at 15:40.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
highcoder
Member
Join Date: Jun 2018
Old 06-05-2018 , 15:55   Re: Knife Models
Reply With Quote #64

Quote:
Originally Posted by OciXCrom View Post
It's not a problem. I would actually recommend you to leave the first knife to be the default one.
There is no need to change the default knife directory in the source file. Is not it?
highcoder is offline
warps013
Junior Member
Join Date: May 2018
Old 06-05-2018 , 16:24   Re: Knife Models
Reply With Quote #65

Hi OciXcrom, sweet coding there, I really liked it! I was hoping... is there a way to replace guns models to player models? I know it would be different since chooseteam, but I would like to choose player models from a menu away from choosteam
warps013 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-05-2018 , 18:12   Re: Knife Models
Reply With Quote #66

Quote:
Originally Posted by highcoder View Post
There is no need to change the default knife directory in the source file. Is not it?
Don't change anything in the .sma file.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-05-2018 , 18:14   Re: Knife Models
Reply With Quote #67

Quote:
Originally Posted by warps013 View Post
Hi OciXcrom, sweet coding there, I really liked it! I was hoping... is there a way to replace guns models to player models? I know it would be different since chooseteam, but I would like to choose player models from a menu away from choosteam
Thanks. There's probably a plugin like that made already. You can search for it. I don't feel like doing it.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
highcoder
Member
Join Date: Jun 2018
Old 06-06-2018 , 02:18   Re: Knife Models
Reply With Quote #68

Quote:
Originally Posted by OciXCrom View Post
Don't change anything in the .sma file.
Okay, thanks for your reply and update. Have a nice day!
highcoder is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-10-2018 , 09:56   Re: Knife Models
Reply With Quote #69

1.
PHP Code:
switch(detect_knife_sound(szSample))
    {
        case 
SOUND_DEPLOY: if(g_eKnife[id][DEPLOY_SOUND][0]) { play_knife_sound(idg_eKnife[id][DEPLOY_SOUND][0]); return FMRES_SUPERCEDE; }
        case 
SOUND_HIT: if(g_eKnife[id][HIT_SOUND][0]) { play_knife_sound(idg_eKnife[id][HIT_SOUND][0]); return FMRES_SUPERCEDE; }
        case 
SOUND_HITWALL: if(g_eKnife[id][HITWALL_SOUND][0]) { play_knife_sound(idg_eKnife[id][HITWALL_SOUND][0]); return FMRES_SUPERCEDE; }
        case 
SOUND_SLASH: if(g_eKnife[id][SLASH_SOUND][0]) { play_knife_sound(idg_eKnife[id][SLASH_SOUND][0]); return FMRES_SUPERCEDE; }
        case 
SOUND_STAB: if(g_eKnife[id][STAB_SOUND][0]) { play_knife_sound(idg_eKnife[id][STAB_SOUND][0]); return FMRES_SUPERCEDE; }
    } 
This is pretty bad for readability. Way too many things on one line. IMO writting code in one line is ok only when you have one single instruction, like:
PHP Code:
if(!something) return 
2.Consider using ItemDeploy instead of CurWeapon.
3.
PHP Code:
else if(equal(szKey"DEPLOY_SOUND"))
{
    
eKnife[HAS_CUSTOM_SOUND] = true
    copy
(eKnife[DEPLOY_SOUND], charsmax(eKnife[DEPLOY_SOUND]), szValue)
    
precache_sound(szValue)
}
else if(
equal(szKey"HIT_SOUND"))
{
    
eKnife[HAS_CUSTOM_SOUND] = true
    copy
(eKnife[HIT_SOUND], charsmax(eKnife[HIT_SOUND]), szValue)
    
precache_sound(szValue)
}
else if(
equal(szKey"HITWALL_SOUND"))
{
    
eKnife[HAS_CUSTOM_SOUND] = true
    copy
(eKnife[HITWALL_SOUND], charsmax(eKnife[HITWALL_SOUND]), szValue)
    
precache_sound(szValue)
}
else if(
equal(szKey"SLASH_SOUND"))
{
    
eKnife[HAS_CUSTOM_SOUND] = true
    copy
(eKnife[SLASH_SOUND], charsmax(eKnife[SLASH_SOUND]), szValue)
    
precache_sound(szValue)
}
else if(
equal(szKey"STAB_SOUND"))
{
    
eKnife[HAS_CUSTOM_SOUND] = true
    copy
(eKnife[STAB_SOUND], charsmax(eKnife[STAB_SOUND]), szValue)
    
precache_sound(szValue)

could be shortened to something like this:
PHP Code:
else 
                    {
                        
eKnife[HAS_CUSTOM_SOUND] = true
                        precache_sound
(szValue)
                        
                        if(
equal(szKey"DEPLOY_SOUND"))
                        {
                            
copy(eKnife[DEPLOY_SOUND], charsmax(eKnife[DEPLOY_SOUND]), szValue)
                        }
                        else if(
equal(szKey"HIT_SOUND"))
                        {
                            
copy(eKnife[HIT_SOUND], charsmax(eKnife[HIT_SOUND]), szValue)
                        }
                        else if(
equal(szKey"HITWALL_SOUND"))
                        {
                            
copy(eKnife[HITWALL_SOUND], charsmax(eKnife[HITWALL_SOUND]), szValue)
                        }
                        else if(
equal(szKey"SLASH_SOUND"))
                        {
                            
copy(eKnife[SLASH_SOUND], charsmax(eKnife[SLASH_SOUND]), szValue)
                        }
                        else if(
equal(szKey"STAB_SOUND"))
                        {
                            
copy(eKnife[STAB_SOUND], charsmax(eKnife[STAB_SOUND]), szValue)
                        }
                    }
                } 
to avoid duplicated code.
(could also use a switch and check for specific characters instead of using if and equal, but not very important)

Be consistent with naming conventions: you have things like play_knife_sound, detect_knife_sound and then things like ColorChat, PushKnife, etc. Use one style.
__________________

Last edited by HamletEagle; 06-10-2018 at 09:58.
HamletEagle is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 06-11-2018 , 09:21   Re: Knife Models
Reply With Quote #70

Quote:
Originally Posted by HamletEagle View Post
...
1. The code would look quite duplicated if it's in multiple lines. I'd rather have it like this. I added some indendation to make it more readable.

2. Done.

3. Not exactly like that, because it doesn't need to precache a sound every time. I changed it however so it's no longer duplicated.

PHP Code:
static const szModelArg[] = "_MODEL"
static const szSoundArg[] = "_SOUND"

if(contain(szKeyszModelArg))
    
precache_model(szValue)
else if(
contain(szKeyszSoundArg))
{
    
eKnife[HAS_CUSTOM_SOUND] = true
    precache_sound
(szValue)

4. Done.
__________________
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 05:34.


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