Raised This Month: $ Target: $400
 0% 

is this method correct?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-02-2013 , 23:29   is this method correct?
Reply With Quote #1

is this method correct in detecting if weapon is in certain group then makeing sure to strip receiver of that weapon group before getting new weapon?

Code:
if( equal( type, "guns" ) )     {           new szWeaponNameD[ 32 ], iWeaponD = get_user_weapon( id );         get_weaponname( iWeaponD, szWeaponNameD, 31);                 for( new i = 0; i < sizeof Primary && i < sizeof Secondary && i < sizeof Grenade; i++ )         {             if( equal( szWeaponNameD, Grenade[ i ] ) )             {                 ham_strip_weapon( id, szWeaponNameD );                 ham_strip_weapon( g_iDonationTarget, Grenade[ i ] );                 ham_give_weapon( g_iDonationTarget, szWeaponNameD );             }                         else if( equal( szWeaponNameD, Secondary[ i ] ) )             {                 ham_strip_weapon( id, szWeaponNameD );                 ham_strip_weapon( g_iDonationTarget, Secondary[ i ] );                 ham_give_weapon( g_iDonationTarget, szWeaponNameD );             }                         else if( equal( szWeaponNameD, Primary[ i ] ) )             {                 ham_strip_weapon( id, szWeaponNameD );                 ham_strip_weapon( g_iDonationTarget, Primary[ i ] );                 ham_give_weapon( g_iDonationTarget, szWeaponNameD );             }         }                 Color( 0, "%s !t%s!n Donated !g%s!n To !t%s!n", PREFIX, dName, szWeaponNameD, rName );         show_dhudmessage( g_iDonationTarget, "[ Donation Revieved ]^n^n Weapon: %s^n^nFrom %s", szWeaponNameD, dName );     }
__________________
Blizzard_87 is offline
guipatinador
SourceMod Donner Party
Join Date: Oct 2009
Location: Poortugal
Old 05-03-2013 , 03:21   Re: is this method correct?
Reply With Quote #2

PHP Code:
// only weapon index or its name can be passed, if neither is passed then the current gun will be transferred
stock bool:fm_transfer_user_gun(index1index2wid 0, const wname[] = ""
fakemeta_util.inc

Last edited by guipatinador; 05-03-2013 at 03:21.
guipatinador is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-03-2013 , 05:13   Re: is this method correct?
Reply With Quote #3

Quote:
Originally Posted by guipatinador View Post
PHP Code:
// only weapon index or its name can be passed, if neither is passed then the current gun will be transferred
stock bool:fm_transfer_user_gun(index1index2wid 0, const wname[] = ""
fakemeta_util.inc
this doesnt work with Grenades....
__________________
Blizzard_87 is offline
Strick3n
Member
Join Date: Apr 2013
Old 05-03-2013 , 07:26   Re: is this method correct?
Reply With Quote #4

no that's incorrect, you should use one loop for each check.
Strick3n is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-03-2013 , 09:29   Re: is this method correct?
Reply With Quote #5

-POST UPDATED-

Try this now, should work for all weapons including shield and C4.
Code:
#define MAX_WEAPON_SLOTS    6 #define OFFSET_PLAYER       5 #define OFFSET_WEAPON       4 #define OFFSET_SHIELD       24 #define m_iClip         51 #define m_fHasPrimary       116 #define m_pActiveItem       373 #define m_iUserPrefs        510 new const m_rgpPlayerItems[ MAX_WEAPON_SLOTS ] = { 367, 368, ... };

Code:
bool:transfer_user_current_weapon( const iOwner, const iTarget ) {     new iActiveItem = get_pdata_cbase( iOwner, m_pActiveItem, OFFSET_PLAYER );     new iClip = get_pdata_int( iActiveItem, m_iClip, OFFSET_WEAPON );         new szWeapon[ 32 ];         if( get_pdata_int( iOwner, m_iUserPrefs, OFFSET_PLAYER ) & ( 1<<OFFSET_SHIELD ) )     {         strip_user_weapon( iTarget, 1 );         set_pdata_int( iTarget, m_fHasPrimary, 0, OFFSET_PLAYER );         give_item( iTarget, "weapon_shield" );         deploy_next_best( iTarget );                 set_pdata_int( iOwner, m_iUserPrefs, get_pdata_int( iOwner, m_iUserPrefs, OFFSET_PLAYER ) & ~( 1<<OFFSET_SHIELD ), OFFSET_PLAYER );                 new iBest = deploy_next_best( iOwner );                 pev( iBest, pev_classname, szWeapon, charsmax( szWeapon ) );         replace( szWeapon, charsmax( szWeapon ), "weapon_", "" );         format( szWeapon, charsmax( szWeapon ), "models/v_%s.mdl", szWeapon );         set_pev( iOwner, pev_viewmodel2, szWeapon );                 return true;     }         pev( iActiveItem, pev_classname, szWeapon, charsmax( szWeapon ) );         new iWeapon = get_weaponid( szWeapon );         new iSlot;         if( contain( szWeapon, "flash" ) == -1 && contain( szWeapon, "nade" ) == -1 )     {         if( iWeapon == CSW_C4  )         {             if( user_has_weapon( iTarget, CSW_C4 ) )                 return false;                         give_item( iTarget, "weapon_c4" );             deploy_next_best( iTarget );                         strip_user_weapon( iOwner, 5 );             deploy_next_best( iOwner );                         return true;         }                 if( iClip < 0 )             return false;                 new iAmmo = cs_get_user_bpammo( iOwner, iWeapon );                 for( new i = 1 ; i < MAX_WEAPON_SLOTS ; i ++ )         {             if( iActiveItem == get_pdata_cbase( iOwner, m_rgpPlayerItems[ i ], OFFSET_PLAYER ) )             {                 iSlot = i;                 break;             }         }                 if( get_pdata_cbase( iTarget, m_rgpPlayerItems[ iSlot ], OFFSET_PLAYER ) > 0 )             strip_user_weapon( iTarget, iSlot );             get_weaponname( iWeapon, szWeapon, charsmax( szWeapon ) );             cs_set_weapon_ammo( give_item( iTarget, szWeapon ), iClip );         cs_set_user_bpammo( iTarget, iWeapon, iAmmo );                 cs_set_user_bpammo( iOwner, iWeapon, 0 );         strip_user_weapon( iOwner, iSlot );     }     else     {           switch( iWeapon )         {             case CSW_SMOKEGRENADE, CSW_HEGRENADE:                 if( user_has_weapon( iTarget, iWeapon ) )                     return false;                                 case CSW_FLASHBANG:                 if( cs_get_user_bpammo( iTarget, CSW_FLASHBANG ) == 2 )                     return false;         }                 cs_set_user_bpammo( iOwner, iWeapon, cs_get_user_bpammo( iOwner, iWeapon ) - 1 );         give_item( iTarget, szWeapon );     }         engclient_cmd( iTarget, szWeapon );     deploy_next_best( iOwner );         return true; }

Code:
strip_user_weapon( const id, const iSlot ) {     new iEnt = get_pdata_cbase( id, m_rgpPlayerItems[ iSlot ], OFFSET_PLAYER );         if( pev_valid( iEnt ) )     {         new szWeapon[ 32 ];                 pev( iEnt, pev_classname, szWeapon, charsmax( szWeapon ) );         set_pev( id, pev_weapons, pev( id, pev_weapons ) & ~( 1<<get_weaponid( szWeapon ) ) );                 set_pdata_cbase( id, m_rgpPlayerItems[ iSlot ], -1, OFFSET_PLAYER );     } }

Code:
deploy_next_best( const id ) {     new iEnt, szWeapon[ 32 ];         for( new i = 1 ; i < MAX_WEAPON_SLOTS ; i ++ )     {         iEnt = get_pdata_cbase( id, m_rgpPlayerItems[ i ], OFFSET_PLAYER );                 if( iEnt > 0 )         {             pev( iEnt, pev_classname, szWeapon, charsmax( szWeapon ) );             engclient_cmd( id, szWeapon );                         break;         }     }         return iEnt; }
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 05-04-2013 at 08:56.
hornet is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-03-2013 , 17:14   Re: is this method correct?
Reply With Quote #6

tested and only thing is if you donate to your self it strips weapon but does not give.. but thats ok i'll just edit the player list to not show yourself.
__________________
Blizzard_87 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-04-2013 , 08:32   Re: is this method correct?
Reply With Quote #7

I've updated my original post. Try it out.
Also no I didn't take transferring to self into consideration - it seems like a silly idea for your plugin anyway ;)
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-06-2013 , 18:24   Re: is this method correct?
Reply With Quote #8

Quote:
Originally Posted by hornet View Post
I've updated my original post. Try it out.
Also no I didn't take transferring to self into consideration - it seems like a silly idea for your plugin anyway ;)
thanks seems to be working, uploading Beta version of my new update. for Donations.
__________________
Blizzard_87 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 10:49.


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