Raised This Month: $51 Target: $400
 12% 

Plugin Invalid client index 0 pls help :(


Post New Thread Reply   
 
Thread Tools Display Modes
quake84
Junior Member
Join Date: Aug 2014
Location: Poland
Old 12-17-2016 , 13:06   Re: Plugin Invalid client index 0 pls help :(
Reply With Quote #11

Polish allowed on public forums? Apparently only if I add a translation, which won't be a problem c:

Polish version:

Zacznijmy od tego że wygodniej ci będzie z SPEditem. Jak ci się plugin nie kompiluje, to możesz kliknąć na segment komunikatu o błędzie który jasno ci pokaże o którą linijkę chodzi. To zwyczajnie ułatwi ci w przyszłości życie, i będziesz sobie radzić bez naszej pomocy.

Następna sprawa: Nieładnie tak zmieniać twórcę pluginu i podkradać jego pracę z GitHuba. (plugin który określiłeś mianem "mój" należy do CSnajpera. A wzieliście go stąd.

No i na koniec: Błędy i ostrzeżenia które otrzymujesz są spowodowane ostatnią funkcją: "stock bool IsValidClient".

Include "cmod.inc" już zawiera taką samą funkcję:

Usunięcie tej funkcji z pluginu usuwa kolizję oznaczeń przez co wszystko działa jak należy.

English version, for mods and everyone else:

Firstly, your life would be easier if you used SPEdit. Then, you can just highlight the error log to see which line causes it. That way you can deal with issues without our help.

Secondly, it's not nice stealing a plugin from someone's github and changing the author+website to match your or your friend's names. Original plugin

Lastly: Errors and warnings in your plugin are caused by the fact that the include "cmod" (from the same author from Git and it generates the same warnings, only confirms my statement) already defines a function called "IsValidClient" and those two collide. Removing it from the plugin makes it compile with no issues.


Hope this helps // Mam nadzieję że pomogłem.

Last edited by quake84; 12-17-2016 at 13:12. Reason: Typo
quake84 is offline
BulgarPL
Member
Join Date: Dec 2015
Old 12-17-2016 , 14:03   Re: Plugin Invalid client index 0 pls help :(
Reply With Quote #12

Sprawdzę i dam znać.
I try this.
BulgarPL is offline
BulgarPL
Member
Join Date: Dec 2015
Old 12-18-2016 , 10:02   Re: Plugin Invalid client index 0 pls help :(
Reply With Quote #13

It did not help

I did something like this:
I do not know if it makes any sense i try this evening

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"
};

new sanitarneKlasa[MAXPLAYERS+1] = 0;
new sanitarneItem[MAXPLAYERS+1] = 0;
new Handle:timer_klasa[MAXPLAYERS+1] = INVALID_HANDLE;
new Handle:timer_item[MAXPLAYERS+1] = INVALID_HANDLE;


//natywy
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
    //natywy
    CreateNative("Sanitarne", native_sanitarne);
    
    return APLRes_Success;
}

public OnClientConnected(client)
{
    sanitarneKlasa[client] = 0;
    sanitarneItem[client] = 0;
}

public native_sanitarne(Handle:plugin, numParams)
{
    new client = GetNativeCell(1);
    new klasa = GetNativeCell(2);
    new item = GetNativeCell(3);
    
    if(klasa == -1 || item == -1)
    {
        if(klasa == -1)
        {
            if(timer_klasa[client] != INVALID_HANDLE)
            {
                CloseHandle(timer_klasa[client])
                timer_klasa[client] = INVALID_HANDLE;
            }
        }
        if(item == -1)
        {
            if(timer_item[client] != INVALID_HANDLE)
            {
                CloseHandle(timer_item[client])
                timer_item[client] = INVALID_HANDLE;
            }
        }
        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)
{
    new id = client;
    
    for(new i = 1; i <= MaxClients; i++)
    {
    if(!IsClientInGame(i))
        continue;
    if(!IsPlayerAlive(i))
        continue;            
    if(IsPlayerAlive(id))
    {
        if(sanitarneKlasa[id] || sanitarneItem[id])
        {
            //dodatkowe hp
            new hp = GetClientHealth(id) + sanitarneKlasa[id] + sanitarneItem[id];
            new 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] != INVALID_HANDLE)
            {
                CloseHandle(timer_klasa[client])
                timer_klasa[client] = INVALID_HANDLE;
            }
            if(timer_item[client] != INVALID_HANDLE)
            {
                CloseHandle(timer_item[client])
                timer_item[client] = INVALID_HANDLE;
            }
        }
    }
    }
    return Plugin_Continue;
}

stock bool:IsValid(client)
{
    if ( !( 1 <= client <= MaxClients ) || !IsClientInGame(client) ) 
        return false; 
     
    return true; 
}
BulgarPL is offline
quake84
Junior Member
Join Date: Aug 2014
Location: Poland
Old 12-18-2016 , 10:40   Re: Plugin Invalid client index 0 pls help :(
Reply With Quote #14

I copied your code and tried compiling it.

Compiles without issues, are you sure this is your current code?
__________________
...
quake84 is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 12-18-2016 , 11:01   Re: Plugin Invalid client index 0 pls help :(
Reply With Quote #15

His compiler must be outdated or something. Get a new one here: http://sourcemod.net/
__________________
Benoist3012 is offline
BulgarPL
Member
Join Date: Dec 2015
Old 12-18-2016 , 13:28   Re: Plugin Invalid client index 0 pls help :(
Reply With Quote #16

I have no problems witch compiling it and the plugin is workin fine.

The problem are just the serwer logs and i want to remove these.

Code:
L 12/18/2016 - 15:23:42: [SM] Call stack trace:
L 12/18/2016 - 15:23:42: [SM]   [0] IsPlayerAlive
L 12/18/2016 - 15:23:42: [SM]   [1] Line 78, skill.sanitarne.sp::lecz
L 12/18/2016 - 15:23:47: [SM] Exception reported: Invalid client index 0
L 12/18/2016 - 15:23:47: [SM] Blaming: skill.sanitarne.smx
L 12/18/2016 - 15:23:47: [SM] Call stack trace:
L 12/18/2016 - 15:23:47: [SM]   [0] IsPlayerAlive
L 12/18/2016 - 15:23:47: [SM]   [1] Line 78, skill.sanitarne.sp::lecz
L 12/18/2016 - 15:23:52: [SM] Exception reported: Invalid client index 0
L 12/18/2016 - 15:23:52: [SM] Blaming: skill.sanitarne.smx
L 12/18/2016 - 15:23:52: [SM] Call stack trace:
L 12/18/2016 - 15:23:52: [SM]   [0] IsPlayerAlive
L 12/18/2016 - 15:23:52: [SM]   [1] Line 78, skill.sanitarne.sp::lecz
L 12/18/2016 - 15:23:57: [SM] Exception reported: Invalid client index 0
L 12/18/2016 - 15:23:57: [SM] Blaming: skill.sanitarne.smx
BulgarPL is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 12-18-2016 , 17:52   Re: Plugin Invalid client index 0 pls help :(
Reply With Quote #17

PHP Code:
    if(!IsClientInGame(i))
        continue;
    if(!
IsPlayerAlive(i))
        continue; 
for
PHP Code:
    if(!IsClientInGame(i))      
        return;    
    if(!
IsPlayerAlive(i))  
      return; 
__________________


Max-Play.pl - the best polish servers

Last edited by CamerDisco; 12-18-2016 at 17:53.
CamerDisco is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 12-18-2016 , 18:11   Re: Plugin Invalid client index 0 pls help :(
Reply With Quote #18

Quote:
Originally Posted by CamerDisco View Post
PHP Code:
    if(!IsClientInGame(i))
        continue;
    if(!
IsPlayerAlive(i))
        continue; 
for
PHP Code:
    if(!IsClientInGame(i))      
        return;    
    if(!
IsPlayerAlive(i))  
      return; 
If the goal in the timer is really to loop through all clients, then "return;" won't work.

continue; will go further to the next client.
return; will break completely out and not continue the loop at all.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 12-18-2016 , 18:14   Re: Plugin Invalid client index 0 pls help :(
Reply With Quote #19

Quote:
Originally Posted by CamerDisco View Post
PHP Code:
    if(!IsClientInGame(i))
        continue;
    if(!
IsPlayerAlive(i))
        continue; 
for
PHP Code:
    if(!IsClientInGame(i))      
        return;    
    if(!
IsPlayerAlive(i))  
      return; 
"continue;" is right in this case since he is skipping invalid clients. "return;" is to exit a void function and "continue;" is to jump to the next iteration in the loop.

Although he didn't need the loop because he isn't even using the variable "i", so i removed it since it wasn't used at all.

Also should be using userid instead to pass through a timer, also i change SetEntData to SetEntProp since FindDataMapOffs is deprecated and isn't safe.

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"
};

new sanitarneKlasa[MAXPLAYERS+1] = 0;
new sanitarneItem[MAXPLAYERS+1] = 0;
new Handle:timer_klasa[MAXPLAYERS+1] = INVALID_HANDLE;
new Handle:timer_item[MAXPLAYERS+1] = INVALID_HANDLE;


//natywy
public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
{
    //natywy
    CreateNative("Sanitarne", native_sanitarne);
    
    return APLRes_Success;
}

public OnClientConnected(client)
{
    sanitarneKlasa[client] = 0;
    sanitarneItem[client] = 0;
}

public native_sanitarne(Handle:plugin, numParams)
{
    new client = GetNativeCell(1);
    new klasa = GetNativeCell(2);
    new item = GetNativeCell(3);
    
    if(klasa == -1 || item == -1)
    {
        if(klasa == -1)
        {
            if(timer_klasa[client] != INVALID_HANDLE)
            {
                CloseHandle(timer_klasa[client])
                timer_klasa[client] = INVALID_HANDLE;
            }
        }
        if(item == -1)
        {
            if(timer_item[client] != INVALID_HANDLE)
            {
                CloseHandle(timer_item[client])
                timer_item[client] = INVALID_HANDLE;
            }
        }
        return;
    }
    
    if(klasa)
    {
        timer_klasa[client] = CreateTimer(5.0, lecz, GetClientUserId(client), TIMER_REPEAT);
        sanitarneKlasa[client] = klasa;
    }
    if(item)
    {
        timer_item[client] = CreateTimer(5.0, lecz, GetClientUserId(client), TIMER_REPEAT);
        sanitarneItem[client] = item;
    }
}

public Action:lecz(Handle:timer, any:userid)
{
    new client = GetClientOfUserId(userid);
    if(IsClientInGame(client) && IsPlayerAlive(client))
	{
		if(sanitarneKlasa[client] || sanitarneItem[client])
		{
			//dodatkowe hp
			new hp = GetClientHealth(client) + sanitarneKlasa[client] + sanitarneItem[client];
			new maxHp = 100 + Cmod_GetClientCON(client)  + Cmod_GetClassCON(client) + Cmod_GetBonusCON(client)
			if(hp > maxHp)
				SetEntProp(client, Prop_Data, "m_iHealth", maxHp);
			else
				SetEntProp(client, Prop_Data, "m_iHealth", hp);
		}
		else
		{
			if(timer_klasa[client] != INVALID_HANDLE)
			{
				CloseHandle(timer_klasa[client])
				timer_klasa[client] = INVALID_HANDLE;
			}
			if(timer_item[client] != INVALID_HANDLE)
			{
				CloseHandle(timer_item[client])
				timer_item[client] = INVALID_HANDLE;
			}
		}
	}
    return Plugin_Continue;
}

stock bool:IsValid(client)
{
    if ( !( 1 <= client <= MaxClients ) || !IsClientInGame(client) ) 
        return false; 
     
    return true; 
}
__________________

Last edited by Chaosxk; 12-21-2016 at 22:17.
Chaosxk is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 12-21-2016 , 06:03   Re: Plugin Invalid client index 0 pls help :(
Reply With Quote #20

Quote:
Originally Posted by Chaosxk View Post
also i change SetEntData to SetEntProp since it is depreciated.
Not sure if you mean depreciated or deprecated, but if you do mean deprecated, then it's kinda wrong.
Code:
SetEntData
/
Code:
GetEntData
is used to set/get infos from an hidden property on an entity.

Howerver doing:
Code:
SetEntData(id, FindDataMapOffs(id, "m_iHealth"), hp, 4, true);
As you said isn't safe, without counting FindDataMapOffs is also deprecated.

Not saying your answer was wrong, just you know, making things clear.
__________________
Benoist3012 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode