Raised This Month: $ Target: $400
 0% 

Ham_AddPlayerItem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 09-23-2012 , 15:01   Ham_AddPlayerItem
Reply With Quote #1

I'm trying to give an item to a player when they spawn.
fun module's give_item prints a message. I don't want this to happen.

So then i saw hamsandwich's Ham_AddPlayerItem and i'm wondering what the parameters are.

Quote:
/**
* Description: Adds an item to the player's inventory.
* Forward params: function(this, idother);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_AddPlayerItem, this, idother);
*/
Ham_AddPlayerItem,
what is this and idother?
My assumption is that this is the player to add the item to and idother is the ID of the item to give. Is this correct?

PHP Code:
new entID get_weaponid(szOtherAutoWeapons[i])
ExecuteHam(Ham_AddPlayerItemidentID
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 09-23-2012 at 15:02.
Liverwiz is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 09-23-2012 , 15:15   Re: Ham_AddPlayerItem
Reply With Quote #2

Quote:
Originally Posted by Liverwiz View Post
PHP Code:
new entID get_weaponid(szOtherAutoWeapons[i])
ExecuteHam(Ham_AddPlayerItemidentID
get_weaponid doesn't returns an entity index LOL

Have you tried with the search button? it's magic: http://forums.alliedmods.net/showthread.php?t=56377

...
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 09-23-2012 , 15:22   Re: Ham_AddPlayerItem
Reply With Quote #3

"fun module's give_item prints a message. I don't want this to happen."

What ?
__________________
micapat is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 09-23-2012 , 15:33   Re: Ham_AddPlayerItem
Reply With Quote #4

Quote:
Originally Posted by meTaLiCroSS View Post
get_weaponid doesn't returns an entity index LOL

Have you tried with the search button? it's magic: http://forums.alliedmods.net/showthread.php?t=56377

...
i know it doesn't.
And that is way more complicated than i was looking for....i.e. 1 native call as opposed to 32342.....
And yet still doesn't answer my question....
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 09-23-2012 , 15:37   Re: Ham_AddPlayerItem
Reply With Quote #5

Quote:
Originally Posted by Liverwiz View Post
i know it doesn't.
And that is way more complicated than i was looking for....i.e. 1 native call as opposed to 32342.....
And yet still doesn't answer my question....
The answer is on the stock that I gave you lol, "this" it's the player id, "idOther" it's the weapon id that should be added to "this"'s inventory.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 09-23-2012 , 16:04   Re: Ham_AddPlayerItem
Reply With Quote #6

Quote:
Originally Posted by meTaLiCroSS View Post
The answer is on the stock that I gave you lol, "this" it's the player id, "idOther" it's the weapon id that should be added to "this"'s inventory.
That crashes the server....using my above code.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 09-23-2012 , 16:06   Re: Ham_AddPlayerItem
Reply With Quote #7

Why do you need to use this ? Which kind of item do you want to give ?
__________________
micapat is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 09-23-2012 , 16:19   Re: Ham_AddPlayerItem
Reply With Quote #8

Quote:
Originally Posted by micapat View Post
Why do you need to use this ? Which kind of item do you want to give ?
Any items defined by the user.
i.e. i have an array of item names (weapons/armor) to give to clients.
__________________
What an elegant solution to a problem that doesn't need solving....
Liverwiz is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 09-23-2012 , 16:21   Re: Ham_AddPlayerItem
Reply With Quote #9

And why give_item isn't a good solution .__. ?
__________________
micapat is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 09-23-2012 , 16:36   Re: Ham_AddPlayerItem
Reply With Quote #10

Quote:
Originally Posted by Liverwiz View Post
That crashes the server....using my above code.
The weapon id, damn man, SEE THE LINK AND THE STOCK THAT I GAVE YOU, a new entity it's created, THAT IS THE WEAPON ID

Code:
int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) {     CBasePlayerItem *pInsert;         pInsert = m_rgpPlayerItems[pItem->iItemSlot()];     while (pInsert)     {         if (FClassnameIs( pInsert->pev, STRING( pItem->pev->classname) ))         {             if (pItem->AddDuplicate( pInsert ))             {                 g_pGameRules->PlayerGotWeapon ( this, pItem );                 pItem->CheckRespawn();                 // ugly hack to update clip w/o an update clip message                 pInsert->UpdateItemInfo( );                 if (m_pActiveItem)                     m_pActiveItem->UpdateItemInfo( );                 pItem->Kill( );             }             else if (gEvilImpulse101)             {                 // FIXME: remove anyway for deathmatch testing                 pItem->Kill( );             }             return FALSE;         }         pInsert = pInsert->m_pNext;     }     if (pItem->AddToPlayer( this ))     {         g_pGameRules->PlayerGotWeapon ( this, pItem );         pItem->CheckRespawn();         pItem->m_pNext = m_rgpPlayerItems[pItem->iItemSlot()];         m_rgpPlayerItems[pItem->iItemSlot()] = pItem;         // should we switch to this item?         if ( g_pGameRules->FShouldSwitchWeapon( this, pItem ) )         {             SwitchWeapon( pItem );         }         return TRUE;     }     else if (gEvilImpulse101)     {         // FIXME: remove anyway for deathmatch testing         pItem->Kill( );     }     return FALSE; }

You're just applying an insignificant number, it should be the weapon entity index
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS 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 08:15.


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