PDA

View Full Version : [SOLVED] Hamsandwich, 3 functions


atomen
04-11-2008, 10:41
I'm testing hamsandwich with different things but i have 2 questions
about 2 functions
/**
* Description: Called whenever two entities touch.
* Forward params: function(this, idother);
* Return type: None.
* Execute params: ExecuteHam(Ham_Touch, this, idother);
*/
Ham_Touch,
Does this work when 2 players collide with each other or do they not count as a entity in this case ?

The second question :
/**
* 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,
How does this function work ?
Should "idother" be the weapon id ?

It seems to work with weapon_* and CSW_* constants because it is not returning any tag mismatch on any of them.

Exolent[jNr]
04-11-2008, 10:44
1. The classname that you supply in RegisterHam will be the classname of the toucher:
RegisterHam(Ham_Touch, "player", "fwd_Ham_Touch");

// ...

public fwd_Ham_Touch(id, ent)
{
// player touched another entity
}

2. You don't get tag mismatch because you are supplying an integer either way.
I assume it will be an entity index, but you should try testing to see.

v3x
04-11-2008, 12:03
Of course it will work.

atomen
04-11-2008, 18:03
I need some more help about hamsandwich.

Look at this code, what am i doing wrong ?
if(cs_get_user_team(iVictimID) == CS_TEAM_T)
ExecuteHam(Ham_GiveAmmo, iVictimID, 80, "ammo_9mm", 120)

else
ExecuteHam(Ham_GiveAmmo, iVictimID, 76, "ammo_45acp", 100)I know the code is triggered, tested with text print. But it is not working :/

They user already has a pistol but they aren't getting any ammo.

atomen
04-12-2008, 09:52
Solved the problem, just posting to let other people how the function works.
I also recommend this function before all the other functions to give a player ammunition.
ExecuteHam(Ham_GiveAmmo, iVictimID, 80, "9mm", 120)
My problem was that i had "ammo_" before the ammo type.