made a few common Warcraft skills. I hope they are working and you find them useful

Skills I got so far:
- Regeneration (+maxHP and Amount Param)
- Long Jump
- Respawn (+counter)
- Mole (+getRandomPlayer)
More are comming!
Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools_stocks>
new int:LongJumpFlag[MAXPLAYERS+1];//Multiplier Var and Switch if a player has long jump
new int:RespawnFlag[MAXPLAYERS+1];//Counter to see if a player will be revived on death
new int:RegenHealthFlag[MAXPLAYERS+1];//Max HP to which a player can recover
new int:RegenAmountFlag[MAXPLAYERS+1];//How much HP is recovered
public Plugin:myinfo =
{
name = "Common WCS-Skills",
author = "DisturbeD",
description = "",
version = "1.0.0.0",
url = "http://war3source.com/"
};
public OnPluginStart()
{
HookEvent("player_death",PlayerDeathEvent);
HookEvent("player_jump",PlayerJumpEvent);
}
public PlayerDeathEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new client=GetClientOfUserId(GetEventInt(event,"userid"));
if(RespawnFlag[client])
{
new float:origin[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", origin);
CS_RespawnPlayer(client);
TeleportEntity(client, origin, NULL_VECTOR, NULL_VECTOR);
RespawnFlag[client]--;
}
}
public PlayerJumpEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new client=GetClientOfUserId(GetEventInt(event,"userid"));
if(LongJumpFlag[client])
{
new Float:velocity[3]={0.0,0.0,0.0};
velocity[0]=GetEntDataFloat(client,GetVelocityOffset_0);
velocity[1]=GetEntDataFloat(client,GetVelocityOffset_1);
velocity[0]*=float(LongJumpFlag[client])*0.20;
velocity[1]*=float(LongJumpFlag[client])*0.20;
SetEntDataVector(client,BaseVelocityOffset,velocity[3],true);
}
}
public Action:War3_GiveRegeneration(any:client,float:delayloop,int:maxhp,int:regrate)
{
RegenHealthFlag[client]=maxhp;
RegenAmountFlag[client]=regrate;
CreateTimer(delayloop,RegenerationLoop,client,TIMER_REPEAT);
}
public Action:War3_GiveLongJump(any:client,int:amount)
{
LongJumpFlag[client]= amount;
}
public Action:War3_GiveRespawn(any:client,int:amount)
{
RespawnFlag[client]+= amount;
}
public Action:War3_GiveMole(any:client,float:delay,int:chance)
{
if(GetRandomInt(1,100)<=chance)
{
if(client)
{
new int:ClientTeam=GetClientTeam(client);
if(ClientTeam)
{
new int:RandPlayer=GetRandomPlayer(5-ClientTeam);
if(RandOpPlayer!=-1)
{
new Float:origin[3];
GetEntPropVector(RandPlayer, Prop_Send, "m_vecOrigin", origin);
if(ClientTeam=2)
SetEntityModel(client,"models/player/t_urban");
else
SetEntityModel(client,"models/player/ct_phoenix");
PrintToChat(client,"You will be teleported as a mole in %d seconds.", delay);
CreateTimer(delay,MoleTeleport,client,origin);
}
}
}
}
else
PrintToChat(client,"You failed becoming a mole.");
}
public Action:MoleTeleport(Handle:timer,any:client,float:origin[3])
{
if(IsPlayerAlive(client))
{
TeleportEntity(client, origin, NULL_VECTOR, NULL_VECTOR);
}
CloseHandle(timer);
}
int:GetRandomPlayer(int:TeamID)
{
new playerList[MAXPLAYERS];
new playerCount;
for (new i = 1; i <= MAXPLAYERS; i++)
{
if (GetClientTeam(i) != TeamID)
continue;
if (!IsClientInGame(i))
continue;
if(!IsPlayerAlive(i))
continue;
playerList[playerCount] = i;
playerCount++;
}
if (playerCount == 0)
return -1;
return playerList[GetRandomInt(0, playerCount-1)];
}
public Action:RegenerationLoop(Handle:timer,any:client)
{
if(RegenAmountFlag[client]&&RegenHealthFlag[client]&&GetClientHealth(client)<=RegenHealthFlag[client])
{
if(IsPlayerAlive(client)&&IsClientInGame(client))
{
new new_hp=GetClientHealth(client)+RegenAmountFlag[client];
if(new_hp>RegenHealthFlag[client])
SetEntityHealth(client,RegenAmountFlag[client]);
else
SetEntityHealth(client,new_hp);
}
else
{
RegenAmountFlag[client]=0;
CloseHandle(timer);
}
}
}
#include <sourcemod>
#include <sdktools_stocks>
new int:LongJumpFlag[MAXPLAYERS+1];//Multiplier Var and Switch if a player has long jump
new int:RespawnFlag[MAXPLAYERS+1];//Counter to see if a player will be revived on death
new int:RegenHealthFlag[MAXPLAYERS+1];//Max HP to which a player can recover
new int:RegenAmountFlag[MAXPLAYERS+1];//How much HP is recovered
public Plugin:myinfo =
{
name = "Common WCS-Skills",
author = "DisturbeD",
description = "",
version = "1.0.0.0",
url = "http://war3source.com/"
};
public OnPluginStart()
{
HookEvent("player_death",PlayerDeathEvent);
HookEvent("player_jump",PlayerJumpEvent);
}
public PlayerDeathEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new client=GetClientOfUserId(GetEventInt(event,"userid"));
if(RespawnFlag[client])
{
new float:origin[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", origin);
CS_RespawnPlayer(client);
TeleportEntity(client, origin, NULL_VECTOR, NULL_VECTOR);
RespawnFlag[client]--;
}
}
public PlayerJumpEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
new client=GetClientOfUserId(GetEventInt(event,"userid"));
if(LongJumpFlag[client])
{
new Float:velocity[3]={0.0,0.0,0.0};
velocity[0]=GetEntDataFloat(client,GetVelocityOffset_0);
velocity[1]=GetEntDataFloat(client,GetVelocityOffset_1);
velocity[0]*=float(LongJumpFlag[client])*0.20;
velocity[1]*=float(LongJumpFlag[client])*0.20;
SetEntDataVector(client,BaseVelocityOffset,velocity[3],true);
}
}
public Action:War3_GiveRegeneration(any:client,float:delayloop,int:maxhp,int:regrate)
{
RegenHealthFlag[client]=maxhp;
RegenAmountFlag[client]=regrate;
CreateTimer(delayloop,RegenerationLoop,client,TIMER_REPEAT);
}
public Action:War3_GiveLongJump(any:client,int:amount)
{
LongJumpFlag[client]= amount;
}
public Action:War3_GiveRespawn(any:client,int:amount)
{
RespawnFlag[client]+= amount;
}
public Action:War3_GiveMole(any:client,float:delay,int:chance)
{
if(GetRandomInt(1,100)<=chance)
{
if(client)
{
new int:ClientTeam=GetClientTeam(client);
if(ClientTeam)
{
new int:RandPlayer=GetRandomPlayer(5-ClientTeam);
if(RandOpPlayer!=-1)
{
new Float:origin[3];
GetEntPropVector(RandPlayer, Prop_Send, "m_vecOrigin", origin);
if(ClientTeam=2)
SetEntityModel(client,"models/player/t_urban");
else
SetEntityModel(client,"models/player/ct_phoenix");
PrintToChat(client,"You will be teleported as a mole in %d seconds.", delay);
CreateTimer(delay,MoleTeleport,client,origin);
}
}
}
}
else
PrintToChat(client,"You failed becoming a mole.");
}
public Action:MoleTeleport(Handle:timer,any:client,float:origin[3])
{
if(IsPlayerAlive(client))
{
TeleportEntity(client, origin, NULL_VECTOR, NULL_VECTOR);
}
CloseHandle(timer);
}
int:GetRandomPlayer(int:TeamID)
{
new playerList[MAXPLAYERS];
new playerCount;
for (new i = 1; i <= MAXPLAYERS; i++)
{
if (GetClientTeam(i) != TeamID)
continue;
if (!IsClientInGame(i))
continue;
if(!IsPlayerAlive(i))
continue;
playerList[playerCount] = i;
playerCount++;
}
if (playerCount == 0)
return -1;
return playerList[GetRandomInt(0, playerCount-1)];
}
public Action:RegenerationLoop(Handle:timer,any:client)
{
if(RegenAmountFlag[client]&&RegenHealthFlag[client]&&GetClientHealth(client)<=RegenHealthFlag[client])
{
if(IsPlayerAlive(client)&&IsClientInGame(client))
{
new new_hp=GetClientHealth(client)+RegenAmountFlag[client];
if(new_hp>RegenHealthFlag[client])
SetEntityHealth(client,RegenAmountFlag[client]);
else
SetEntityHealth(client,new_hp);
}
else
{
RegenAmountFlag[client]=0;
CloseHandle(timer);
}
}
}






Logged
:



where do I give players negative hp? players with negative hp suicide and the attacker gets 1 score.. pls help me tho if smth is missing :S