Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include sourcemod
- #include sdktools
- #include sdkhooks
- public OnMapStart()
- {
- AddCommandListener(CommandListener);
- }
- public Action:CommandListener(client, const String:command[], args)
- {
- if (StrEqual(command, "impulse", false))
- {
- if(bIsSurvivor(client))
- {
- int slot = GetPlayerWeaponSlot(client, 0);
- if (IsValidEntity(slot))
- {
- SDKCallWeaponDrop(client, slot);
- }
- return Plugin_Handled;
- }
- }
- return Plugin_Continue;
- }
- stock bool bIsSurvivor(int client)
- {
- return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
- }
- stock SDKCallWeaponDrop(client, weapon)
- {
- decl Float:vecAngles[3], Float:vecTarget[3], Float:vecVelocity[3];
- if (GetPlayerEye(client, vecTarget))
- {
- GetClientEyeAngles(client, vecAngles);
- GetAngleVectors(vecAngles, vecVelocity, NULL_VECTOR, NULL_VECTOR)
- vecVelocity[0] *= 800.0;
- vecVelocity[1] *= 800.0;
- vecVelocity[2] *= 800.0;
- SDKHooks_DropWeapon(client, weapon, NULL_VECTOR, NULL_VECTOR);
- TeleportEntity(weapon, NULL_VECTOR, NULL_VECTOR, vecVelocity)
- }
- }
- stock bool:GetPlayerEye(client, Float:vecTarget[3])
- {
- decl Float:Origin[3], Float:Angles[3];
- GetClientEyePosition(client, Origin);
- GetClientEyeAngles(client, Angles);
- new Handle:trace = TR_TraceRayFilterEx(Origin, Angles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer);
- if (TR_DidHit(trace))
- {
- TR_GetEndPosition(vecTarget, trace);
- CloseHandle(trace);
- return true;
- }
- CloseHandle(trace);
- return false;
- }
- public bool:TraceEntityFilterPlayer(entity, contentsMask)
- {
- return entity > GetMaxClients() || !entity;
- }
Advertisement
Add Comment
Please, Sign In to add comment