Raised This Month: $ Target: $400
 0% 

[HELP] Simplify Code (Weapon's Models)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
extream87
Senior Member
Join Date: Aug 2011
Old 03-17-2014 , 11:07   [HELP] Simplify Code (Weapon's Models)
Reply With Quote #1

How can i simplify the checkModel1(id) & checkModel2(id) cause i need to create one for each weapon.
Code:
public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_event("WeapPickup","checkModel1","b","1=19")     register_event("WeapPickup","checkModel2","b","1=19") } public checkModel1(id) {     if ( !g_HasuspP[id] )         return PLUGIN_HANDLED         new szWeapID = read_data(2)         if ( szWeapID == CSW_USP && g_HasuspP[id] == true)     {         set_pev(id, pev_viewmodel2, purple_usp_vmodel)         set_pev(id, pev_weaponmodel2, purple_usp_wmodel)     }     return PLUGIN_HANDLED } public checkModel2(id) {     if ( !g_HasuspFL[id] )         return PLUGIN_HANDLED         new szWeapID = read_data(2)         if ( szWeapID == CSW_USP && g_HasuspFL[id] == true)     {         set_pev(id, pev_viewmodel2, f0restleaves_usp_vmodel)         set_pev(id, pev_weaponmodel2, f0restleaves_usp_wmodel)     }     return PLUGIN_HANDLED }

This is correct?

Code:
public checkModel(id) {     if ( !g_HasuspFL[id] )         return PLUGIN_HANDLED     if ( !g_HasuspP[id] )         return PLUGIN_HANDLED     new szWeapID = read_data(2)         if ( szWeapID == CSW_USP && g_HasuspP[id] == true)     {         set_pev(id, pev_viewmodel2, purple_usp_vmodel)         set_pev(id, pev_weaponmodel2, purple_usp_wmodel)     }        else if ( szWeapID == CSW_USP && g_HasuspFL[id] == true)     {         set_pev(id, pev_viewmodel2, f0restleaves_usp_vmodel)         set_pev(id, pev_weaponmodel2, f0restleaves_usp_wmodel)     }     return PLUGIN_HANDLED }

Last edited by extream87; 03-17-2014 at 11:49.
extream87 is offline
Kiske
Veteran Member
Join Date: May 2009
Old 03-17-2014 , 15:26   Re: [HELP] Simplify Code (Weapon's Models)
Reply With Quote #2

PHP Code:
    if ( !g_HasuspFL[id] ) 
        return 
PLUGIN_HANDLED

    
if ( !g_HasuspP[id] )
        return 
PLUGIN_HANDLED 
->

PHP Code:
    if ( !g_HasuspFL[id] && !g_HasuspP[id] ) 
        return 
PLUGIN_HANDLED 
__________________

Kiske is offline
Send a message via Skype™ to Kiske
Old 03-17-2014, 15:35
fysiks
This message has been deleted by fysiks. Reason: nvm, read it wrong.
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 06:03.


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