Hey coders,
i am using Hook grab rope plugin on our servers and i want to make it works after death (admins can grab after they die)...
In code was IsPlayerAlive, sure if i remove it, grab works in death cam, but when death admin grab something or somebody and drop bind button, he has still item or player in grab and admin must reconnect...
Here is my edited code:
PHP Code:
public Action_Grab(client)
{
if(g_cvarEnable[Grab] && g_Frozen[Grab])
{
if( client > 0 &&
client <= MaxClients &&
!g_Status[client][Grab] &&
!g_Grabbed[client])
{
if(HasAccess(client, Grab))
{
g_Status[client][Grab] = true; // Tell plugin the seeker is grabbing a player
// Call grab search forward
new ret;
Call_StartForward(FwdClientGrabSearch);
Call_PushCell(client);
Call_Finish(ret);
if(ret)
{
g_Status[client][Grab] = false;
return;
}
// Start grab search timer
CreateTimer(0.1, GrabSearch, client, TIMER_REPEAT); // Start a timer that searches for a client to grab
}
else
PrintToChat(client,"\x01\x0B\x04[HGR]\x01 %t\x04 grab.", "No Permission");
}
}
else
PrintToChat(client, "\x01\x0B\x04[HGR] Grab\x01 %t", "Disabled");
}
public Action:GrabSearch(Handle:timer, any:client)
{
PrintCenterText(client, "%t", "Searching"); // Tell client the plugin is searching for a target
if( client > 0 &&
IsClientInGame(client) &&
g_Status[client][Grab] &&
!g_Grabbed[client])
{
// Init variables
new Float:clientloc[3], Float:clientang[3];
GetClientEyePosition(client, clientloc);
GetClientEyeAngles(client, clientang);
// Grab search traceray
TR_TraceRayFilter(clientloc, clientang, MASK_ALL, RayType_Infinite, TraceRayGrabEnt); // Create a ray that tells where the player is looking
g_Targetindex[client][Grab] = TR_GetEntityIndex(); // Set the seekers targetindex to the person he picked up
// Found a player or object
if(g_Targetindex[client][Grab] > 0 && IsValidEntity(g_Targetindex[client][Grab]))
{
// Init variables
new Float:targetloc[3];
GetEntityOrigin(g_Targetindex[client][Grab], targetloc); // Find the target's xyz coordinate
g_Distance[client][1] = GetVectorDistance(targetloc, clientloc); // Tell plugin the distance between the two to maintain
if( g_Targetindex[client][Grab] > 0 &&
g_Targetindex[client][Grab] <= MaxClients &&
IsClientInGame(g_Targetindex[client][Grab]))
{
g_MaxSpeed[client] = GetEntPropFloat(client, Prop_Send, "m_flMaxspeed");
g_Grabbed[g_Targetindex[client][Grab]] = true; // If target is a player, tell plugin player is being grabbed
SetEntPropFloat(g_Targetindex[client][Grab], Prop_Send, "m_flMaxspeed", 0.01); // Slow grab target
}
// Call grab forward
new ret;
Call_StartForward(FwdClientGrab);
Call_PushCell(client);
Call_Finish(ret);
if(ret)
{
Action_Drop(client);
return Plugin_Stop;
}
// Finish grabbing
EmitSoundFromOrigin(g_cvarSound[Grab], targetloc); // Emit sound from the entity being grabbed
CreateTimer(0.05, Grabbing, client, TIMER_REPEAT); // Start a repeating timer that will reposition the target in the grabber's crosshairs
return Plugin_Stop; // Stop the search timer
}
}
else
{
Action_Drop(client);
return Plugin_Stop; // Stop the timer
}
return Plugin_Continue;
}
public Action:Grabbing(Handle:timer, any:client)
{
PrintCenterText(client, "%t", "Found");
if( IsClientInGame(client) &&
g_Status[client][Grab] &&
!g_Grabbed[client] &&
IsValidEntity(g_Targetindex[client][Grab]))
{
if( g_Targetindex[client][Grab] > MaxClients ||
g_Targetindex[client][Grab] > 0 &&
g_Targetindex[client][Grab] <= MaxClients &&
IsClientInGame(g_Targetindex[client][Grab]))
{
// Init variables
new Float:clientloc[3], Float:clientang[3], Float:targetloc[3], Float:velocity[3];
GetClientEyePosition(client, clientloc);
GetClientEyeAngles(client, clientang);
GetEntityOrigin(g_Targetindex[client][Grab], targetloc);
// Grab traceray
g_TRIgnore[client] = true;
TR_TraceRayFilter(clientloc, clientang, MASK_ALL, RayType_Infinite, TraceRayTryToHit); // Find where the player is aiming
TR_GetEndPosition(velocity); // Get the end position of the trace ray
g_TRIgnore[client] = false;
// Calculate velocity vector
SubtractVectors(velocity, clientloc, velocity);
NormalizeVector(velocity, velocity);
if(g_Attracting[client][0])
g_Distance[client][1] += g_cvarSpeed[1] * 10.0;
else if(g_Attracting[client][1])
{
g_Distance[client][1] -= g_cvarSpeed[1] * 10.0;
if(g_Distance[client][1] <= 30.0)
g_Distance[client][1] = 30.0;
}
ScaleVector(velocity, g_Distance[client][1]);
AddVectors(velocity, clientloc, velocity);
SubtractVectors(velocity, targetloc, velocity);
ScaleVector(velocity, g_cvarSpeed[1] * 3 / 5);
// Move grab target
TeleportEntity(g_Targetindex[client][Grab], NULL_VECTOR, NULL_VECTOR, velocity);
// Make a beam from grabber to grabbed
new color[4];
if(g_Targetindex[client][Grab] <= MaxClients)
targetloc[2] += 45;
clientloc[2] -= 5;
GetBeamColor(client, Grab, color);
BeamEffect(clientloc, targetloc, 0.2, g_cvarInitWidth[1], g_cvarEndWidth[1], color, g_cvarAmplitude[1], 0);
}
else
{
Action_Drop(client);
return Plugin_Stop; // Stop the timer
}
}
else
{
Action_Drop(client);
return Plugin_Stop; // Stop the timer
}
return Plugin_Continue;
}
public Action_Drop(client)
{
if( IsClientInGame(client) &&
g_Status[client][Grab] )
{
g_Status[client][Grab] = false; // Tell plugin the grabber has dropped his target
if(g_Targetindex[client][Grab] > 0)
{
PrintCenterText(client, "%t", "Dropped");
if( g_Targetindex[client][Grab] > 0 &&
g_Targetindex[client][Grab] <= MaxClients &&
IsClientInGame(g_Targetindex[client][Grab]))
{
g_Grabbed[g_Targetindex[client][Grab]] = false; // Tell plugin the target is no longer being grabbed
SetEntPropFloat(g_Targetindex[client][Grab], Prop_Send, "m_flMaxspeed", g_MaxSpeed[client]); // Set speed back to normal
}
g_Targetindex[client][Grab] = -1;
}
else
PrintCenterText(client, "%t", "Not Found");
}
}
If you know how to make it works, like when admin is in death cam, he will grab somebody and when he drop bind button, player will drop too, or grab will be removed.
I will be happy if you help me with this, thanks.