View Single Post
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 12-17-2016 , 09:19   Re: Plugin Invalid client index 0 pls help :(
Reply With Quote #2

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 myselfbool latechar[] errorint 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 pluginint numParams)
{
    
int client GetNativeCell(1);
    
int klasa GetNativeCell(2);
    
int item GetNativeCell(3);
    
    if(
klasa == -|| 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.0leczclientTIMER_REPEAT);
        
sanitarneKlasa[client] = klasa;
    }
    if(
item)
    {
        
timer_item[client] = CreateTimer(5.0leczclientTIMER_REPEAT);
        
sanitarneItem[client] = item;
    }
}

public 
Action lecz(Handle timerany 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(idFindDataMapOffs(id"m_iHealth"), maxHp4true);
            else
                
SetEntData(idFindDataMapOffs(id"m_iHealth"), hp4true);
        }
        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 (
<= client <= MaxClients && IsClientInGame(client));

__________________
xines is offline