Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- ConVar szybkosc_odepchniecia;
- ConVar sila_odepchniecia;
- ConVar odlegosc_do_odepchniecia;
- ConVar cooldown;
- int iCooldown[MAXPLAYERS+1];
- public Plugin myinfo =
- {
- name = "Odpychanie na E",
- author = "SUPER TIMOR",
- description = "Plugin na odpychanie graczy",
- version = "1.0",
- url = "http://goBoosting.pl"
- };
- public void OnPluginStart()
- {
- HookEvent("player_spawn", OdrodzenieGracza);
- szybkosc_odepchniecia = CreateConVar("szybkosc_odepchniecia", "25.0", "Szybkosc lotu odepchnietego");
- sila_odepchniecia = CreateConVar("sila_odepchniecia", "8.0", "Sila odepchniecia");
- odlegosc_do_odepchniecia = CreateConVar("odlegosc_do_odepchniecia", "70.0", "Ogległość, w której muszą się znajdować gracze by się odepchnąć");
- cooldown = CreateConVar("odepchniecie_cooldown", "5", "Ile sekund między odepchnięciami?");
- AutoExecConfig(true, "", "sourcemod");
- }
- public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapons)
- {
- if(!IsValidClient(client) || !IsPlayerAlive(client))
- return Plugin_Continue;
- if(buttons & IN_USE)
- {
- if(iCooldown[client] >= GetTime())
- return Plugin_Continue;
- int target = GetClientAimTarget(client);
- if(!IsValidClient(target) || !IsPlayerAlive(target))
- return Plugin_Continue;
- float clientPos[3], targetPos[3], pushVel[3];
- GetClientAbsOrigin(client, clientPos);
- GetClientAbsOrigin(target, targetPos);
- float distance = GetVectorDistance(targetPos, clientPos);
- distance = (distance > 0.0) ? distance : 1.0;
- if(distance > odlegosc_do_odepchniecia.FloatValue)
- return Plugin_Continue;
- SubtractVectors(clientPos, targetPos, pushVel);
- pushVel[0] = -pushVel[0];
- pushVel[1] = -pushVel[1];
- pushVel[2] = szybkosc_odepchniecia.FloatValue;
- ScaleVector(pushVel, sila_odepchniecia.FloatValue);
- TeleportEntity(target, NULL_VECTOR, NULL_VECTOR, pushVel);
- iCooldown[client] = GetTime() + cooldown.IntValue;
- }
- return Plugin_Continue;
- }
- public Action OdrodzenieGracza(Event event, char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- iCooldown[client] = 0;
- }
- public bool IsValidClient(int client)
- {
- if(client >= 1 && client <= MaxClients && IsClientInGame(client))
- return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement