AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_AddPlayerItem (https://forums.alliedmods.net/showthread.php?t=196634)

Liverwiz 09-23-2012 15:01

Ham_AddPlayerItem
 
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


meTaLiCroSS 09-23-2012 15:15

Re: Ham_AddPlayerItem
 
Quote:

Originally Posted by Liverwiz (Post 1804794)
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

...

micapat 09-23-2012 15:22

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

What ?

Liverwiz 09-23-2012 15:33

Re: Ham_AddPlayerItem
 
Quote:

Originally Posted by meTaLiCroSS (Post 1804807)
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....

meTaLiCroSS 09-23-2012 15:37

Re: Ham_AddPlayerItem
 
Quote:

Originally Posted by Liverwiz (Post 1804819)
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.

Liverwiz 09-23-2012 16:04

Re: Ham_AddPlayerItem
 
Quote:

Originally Posted by meTaLiCroSS (Post 1804823)
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.

micapat 09-23-2012 16:06

Re: Ham_AddPlayerItem
 
Why do you need to use this ? Which kind of item do you want to give ?

Liverwiz 09-23-2012 16:19

Re: Ham_AddPlayerItem
 
Quote:

Originally Posted by micapat (Post 1804852)
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.

micapat 09-23-2012 16:21

Re: Ham_AddPlayerItem
 
And why give_item isn't a good solution .__. ?

meTaLiCroSS 09-23-2012 16:36

Re: Ham_AddPlayerItem
 
Quote:

Originally Posted by Liverwiz (Post 1804850)
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


All times are GMT -4. The time now is 08:16.

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