float targetPos[MAXPLAYERS+1][3]; int targetEnt[MAXPLAYERS+1]; static char STORE_KEY[] = "SEND_TO_HEAVEN"; void SendToHeaven_OnActivate(int apologizer, int target, const char[] eventId) { Handle h = CreateTimer(1.0, Timer_Levitate, GetClientUserId(apologizer), TIMER_REPEAT); SorryStore[apologizer].SetBool(STORE_KEY, true); } Action Timer_Levitate(Handle h, int userid) { int client = GetClientOfUserId(userid); if(client > 0) { int entity = FindNearestEntityInRange(client, "player", 500.0); if(entity > 0) { targetEnt[client] = entity; GetEntPropVector(entity, Prop_Data, "m_vecOrigin", targetPos[client]); } } return Plugin_Handled; } Action SendToHeaven_OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon, int& subtype, int& cmdnum, int& tickcount, int& seed, int mouse[2]) { if(client > 0 && SorryStore[client].ContainsKey(STORE_KEY)) { // Make client "look at" the target for the calculation float result[3], pos[3]; GetClientAbsOrigin(client, pos); MakeVectorFromPoints(targetPos[client], pos, result); GetVectorAngles(result, angles); if(angles[0] >= 270){ angles[0] -= 270; angles[0] = (90-angles[0]); } else { if(angles[0] <= 90){ angles[0] *= -1; } } angles[1] -= 180; // PrintToServer("look at -> (%.0f %.0f %.0f) %d", targetPos[client][0], targetPos[client][1], targetPos[client][2], targetEnt[client]); if(buttons & IN_FORWARD) { // GetHorizontalPositionFromOrigin(pos, angles, 1.0, pos); float theta = DegToRad(angles[1]); vel[0] = 150.0 * Cosine(theta); vel[1] = 150.0 * Sine(theta); SetAbsVelocity(client, vel); // TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vel); // SetAbsOrigin(client, pos); return Plugin_Changed; } else if(buttons & IN_BACK) { float theta = DegToRad(angles[1]); vel[0] = -150.0 * Cosine(theta); vel[1] = -150.0 * Sine(theta); SetAbsVelocity(client, vel); } else if(buttons & IN_MOVELEFT) { float theta = DegToRad(angles[1] - 90.0); vel[0] = -150.0 * Cosine(theta); vel[1] = -150.0 * Sine(theta); SetAbsVelocity(client, vel); } else if(buttons & IN_MOVERIGHT) { float theta = DegToRad(angles[1] - 90.0); vel[0] = 150.0 * Cosine(theta); vel[1] = 150.0 * Sine(theta); SetAbsVelocity(client, vel); } return Plugin_Changed; } return Plugin_Continue; } void SetHorizontalVelocity(int client, const float heading, const float speed) { float theta = DegToRad(heading); float vel[3]; vel[0] += speed * Cosine(theta); vel[1] += speed * Sine(theta); SetAbsVelocity(client, vel); }