| 661 | } |
| 662 | |
| 663 | static cell_t SlapPlayer(IPluginContext *pContext, const cell_t *params) |
| 664 | { |
| 665 | static bool s_slap_supported = false; |
| 666 | static bool s_slap_setup = false; |
| 667 | static ICallWrapper *s_teleport = NULL; |
| 668 | static int s_health_offs = 0; |
| 669 | static int s_sound_count = 0; |
| 670 | static int s_frag_offs = 0; |
| 671 | |
| 672 | if (!s_slap_setup) |
| 673 | { |
| 674 | int tries = 0; |
| 675 | |
| 676 | s_slap_setup = true; |
| 677 | |
| 678 | if (IsTeleportSupported()) |
| 679 | { |
| 680 | tries++; |
| 681 | } |
| 682 | if (IsGetVelocitySupported()) |
| 683 | { |
| 684 | tries++; |
| 685 | } |
| 686 | |
| 687 | /* Setup health */ |
| 688 | if (g_pGameConf->GetOffset("m_iHealth", &s_health_offs) && s_health_offs) |
| 689 | { |
| 690 | tries++; |
| 691 | } |
| 692 | |
| 693 | if (tries == 3) |
| 694 | { |
| 695 | s_slap_supported = true; |
| 696 | |
| 697 | const char *key; |
| 698 | if ((key = g_pGameConf->GetKeyValue("SlapSoundCount")) != NULL) |
| 699 | { |
| 700 | s_sound_count = atoi(key); |
| 701 | } |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | if (!s_slap_supported) |
| 706 | { |
| 707 | return pContext->ThrowNativeError("This function is not supported on this mod"); |
| 708 | } |
| 709 | |
| 710 | /* First check if the client is valid */ |
| 711 | IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]); |
| 712 | if (!player) |
| 713 | { |
| 714 | return pContext->ThrowNativeError("Client %d is not valid", params[1]); |
| 715 | } else if (!player->IsInGame()) { |
| 716 | return pContext->ThrowNativeError("Client %d is not in game", params[1]); |
| 717 | } |
| 718 | |
| 719 | edict_t *pEdict = player->GetEdict(); |
| 720 | CBaseEntity *pEntity = pEdict->GetUnknown()->GetBaseEntity(); |
nothing calls this directly
no test coverage detected