Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include sdktools
- #include sdkhooks
- #pragma semicolon 1
- #pragma newdecls required
- public void OnPluginStart()
- {
- RegConsoleCmd("sm_drop", iDrop);
- }
- public Action iDrop(int client, int args)
- {
- if(IsClientInGame(client) && GetClientTeam(client) == 2)
- {
- int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- if(IsValidEntity(iCurrentWeapon))
- {
- SDKCallWeaponDrop(client, iCurrentWeapon);
- }
- }
- return Plugin_Handled;
- }
- stock void SDKCallWeaponDrop(int client, int weapon)
- {
- float vecAngles[3], vecTarget[3], vecVelocity[3];
- if (GetPlayerEye(client, vecTarget))
- {
- GetClientEyeAngles(client, vecAngles);
- GetAngleVectors(vecAngles, vecVelocity, NULL_VECTOR, NULL_VECTOR);
- vecVelocity[0] *= 425.0;
- vecVelocity[1] *= 375.0;
- vecVelocity[2] *= 350.0;
- SDKHooks_DropWeapon(client, weapon, NULL_VECTOR, NULL_VECTOR);
- TeleportEntity(weapon, NULL_VECTOR, NULL_VECTOR, vecVelocity);
- }
- }
- stock bool GetPlayerEye(int client, float vecTarget[3])
- {
- float Origin[3], Angles[3];
- GetClientEyePosition(client, Origin);
- GetClientEyeAngles(client, Angles);
- 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(int entity, int contentsMask)
- {
- return entity > GetMaxClients() || !entity;
- }
Advertisement
Add Comment
Please, Sign In to add comment