int CLuaPedDefs::GetPedTotalAmmo ( lua_State* luaVM ) { CPed* pPed; unsigned char ucSlot = 0; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pPed ); if ( !argStream.HasErrors () ) argStream.ReadNumber ( ucSlot, pPed->GetWeaponSlot () ); if ( !argStream.HasErrors () ) { CWeapon* pWeapon = pPed->GetWeapon ( ucSlot ); if ( pWeapon ) { lua_pushnumber ( luaVM, pWeapon->usAmmo ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); lua_pushboolean ( luaVM, false ); return 1; }
int CLuaPedDefs::GetPedWeapon ( lua_State* luaVM ) { CPed* pPed; unsigned char ucSlot; CScriptArgReader argStream ( luaVM ); argStream.ReadUserData ( pPed ); argStream.ReadNumber ( ucSlot, 0xFF ); if ( !argStream.HasErrors () ) { if ( ucSlot == 0xFF ) ucSlot = pPed->GetWeaponSlot (); CWeapon* pWeapon = pPed->GetWeapon ( ucSlot ); if ( pWeapon ) { unsigned char ucWeapon = pWeapon->ucType; lua_pushnumber ( luaVM, ucWeapon ); return 1; } } else m_pScriptDebugging->LogCustom ( luaVM, argStream.GetFullErrorMessage () ); // Failed lua_pushboolean ( luaVM, false ); return 1; }
////////////////////////////////////////////////////////////////////////////////////////// // // CVehicle::BurstTyre // (Used for CAutomobile and CBike hooks) // // Called when an inflated vehicle tyre is hit by a bullet // ////////////////////////////////////////////////////////////////////////////////////////// bool OnMY_CVehicle_BurstTyre( CVehicleSAInterface* pVehicle, uchar ucTyre ) { if ( m_pVehicleDamageHandler ) { eWeaponType weaponType = WEAPONTYPE_INVALID; // Discover weapon if possible CPed* pInitiator = pGameInterface->GetPools()->GetPed ( (DWORD *)pBulletImpactInitiator ); if ( pInitiator ) { CWeapon* pWeapon = pInitiator->GetWeapon ( pInitiator->GetCurrentWeaponSlot () ); if ( pWeapon ) weaponType = pWeapon->GetType (); } if ( !m_pVehicleDamageHandler( pVehicle, 0, pBulletImpactInitiator, weaponType, vecSavedBulletImpactEndPosition, ucTyre ) ) return false; } return true; }