PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <cmod>
public Plugin myinfo = {
name = "Cmod Skill: Sanitarne",
author = "Raflik",
description = "Skill Sanitarne",
version = "0.1",
url = "www"
};
int sanitarneKlasa[MAXPLAYERS+1] = 0;
int sanitarneItem[MAXPLAYERS+1] = 0;
Handle timer_klasa[MAXPLAYERS+1] = null;
Handle timer_item[MAXPLAYERS+1] = null;
//natywy
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
{
//natywy
CreateNative("Sanitarne", native_sanitarne);
return APLRes_Success;
}
public void OnClientConnected(int client)
{
sanitarneKlasa[client] = 0;
sanitarneItem[client] = 0;
}
//public native_sanitarne(Handle:plugin, numParams)
public int native_sanitarne(Handle plugin, int numParams)
{
int client = GetNativeCell(1);
int klasa = GetNativeCell(2);
int item = GetNativeCell(3);
if(klasa == -1 || item == -1)
{
if(klasa == -1)
{
if(timer_klasa[client] != null)
{
CloseHandle(timer_klasa[client])
timer_klasa[client] = null;
}
}
if(item == -1)
{
if(timer_item[client] != null)
{
CloseHandle(timer_item[client])
timer_item[client] = null;
}
}
return;
}
if(klasa)
{
timer_klasa[client] = CreateTimer(5.0, lecz, client, TIMER_REPEAT);
sanitarneKlasa[client] = klasa;
}
if(item)
{
timer_item[client] = CreateTimer(5.0, lecz, client, TIMER_REPEAT);
sanitarneItem[client] = item;
}
}
public Action lecz(Handle timer, any client)
{
int id = client;
if(IsValidClient(id) && IsPlayerAlive(id))
{
if(sanitarneKlasa[id] || sanitarneItem[id])
{
//dodatkowe hp
int hp = GetClientHealth(id) + sanitarneKlasa[id] + sanitarneItem[id];
int maxHp = 100 + Cmod_GetClientCON(id) + Cmod_GetClassCON(id) + Cmod_GetBonusCON(id)
if(hp > maxHp)
SetEntData(id, FindDataMapOffs(id, "m_iHealth"), maxHp, 4, true);
else
SetEntData(id, FindDataMapOffs(id, "m_iHealth"), hp, 4, true);
}
else
{
if(timer_klasa[client] != null)
{
CloseHandle(timer_klasa[client])
timer_klasa[client] = null;
}
if(timer_item[client] != null)
{
CloseHandle(timer_item[client])
timer_item[client] = null;
}
}
}
return Plugin_Continue;
}
stock bool IsValidClient(int client)
{
return (1 <= client <= MaxClients && IsClientInGame(client));
}
__________________