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

Client index 0 is invalid?


Post New Thread Reply   
 
Thread Tools Display Modes
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 01-08-2014 , 09:43   Re: Client index 0 is invalid?
Reply With Quote #21

Like this?

PHP Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3])
{
    
//do function

gilmon is offline
Send a message via MSN to gilmon
V952
Member
Join Date: Jan 2012
Location: Odessa, Ukraine
Old 01-08-2014 , 09:44   Re: Client index 0 is invalid?
Reply With Quote #22

PHP Code:
...
// Hook:
SDKHook(pEntitySDKHook_OnTakeDamageOnEntityTakeDamage);
...
...
public 
Action:OnEntityTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
 ...
 
// Plugin_Continue to do nothing, Plugin_Stop to block the function.
 
return Plugin_Continue;

__________________
HL2DM Real-Life Server: 195.138.78.198:27015
V952 is offline
Send a message via Skype™ to V952
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 01-08-2014 , 10:43   Re: Client index 0 is invalid?
Reply With Quote #23

Quote:
Originally Posted by gilmon View Post
Thanks for the help,sorry don't know how to call/hook this event,do you have any example?
This should work:
PHP Code:
#include <sourcemod>
#include <sdkhooks>

#define IsPlayer(%0) (1<=%0<=MaxClients && IsClientInGame(%0))

public Plugin:myinfo 
{
    
name "TK Somemore..",
    
author "wbyokomo",
    
description "Revert damage done to attacker.",
    
version "0.0.1",
    
url "<- URL ->"
}

public 
OnClientPostAdminCheck(id)
{
    
SDKHook(idSDKHook_OnTakeDamageOnTakeDamage)
}

public 
Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
    
//attacker not valid/connected @ selfdamage
    
if(!IsPlayer(attacker) || victim == attacker) return Plugin_Continue;
    
    
//ok he is TK you
    
if(GetClientTeam(victim) == GetClientTeam(attacker))
    {
        
//SDKHooks_TakeDamage(entity, inflictor, attacker, Float:damage, damageType=DMG_GENERIC, weapon=-1, const Float:damageForce[3]=NULL_VECTOR, const Float:damagePosition[3]=NULL_VECTOR); 
        //do damage to attacker
        
SDKHooks_TakeDamage(attacker00damagedamagetype)
        
//set 0.0 damage to victim
        
damage 0.0
        
return Plugin_Changed;
    }
    
    return 
Plugin_Continue;

yokomo is offline
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 01-09-2014 , 00:59   Re: Client index 0 is invalid?
Reply With Quote #24

Thanks a lot,tested for half a day until now,works very good!
gilmon is offline
Send a message via MSN to gilmon
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 01-09-2014 , 02:12   Re: Client index 0 is invalid?
Reply With Quote #25

Quote:
Originally Posted by gilmon View Post
Thanks a lot,tested for half a day until now,works very good!
Sound funny for me when i try to burn someone from molotov, i also burned and ouch ouch ouch fire.. my HP decrease.
yokomo is offline
gilmon
Senior Member
Join Date: Feb 2011
Location: China
Old 01-09-2014 , 07:33   Re: Client index 0 is invalid?
Reply With Quote #26

Yeah I notice it too, before this i'm asking how to find "fire damage" deal this one.

Also..when plugin reload,plugin stop work?

Last edited by gilmon; 01-09-2014 at 07:35. Reason: new notice
gilmon is offline
Send a message via MSN to gilmon
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 01-09-2014 , 10:22   Re: Client index 0 is invalid?
Reply With Quote #27

Quote:
Originally Posted by gilmon View Post
Yeah I notice it too, before this i'm asking how to find "fire damage" deal this one.

Also..when plugin reload,plugin stop work?
What do you mean by plugin reload? i don't even hook any round_* event. I just hook TakeDamage when player join server.

Well try to change into:
PHP Code:
//public OnClientPostAdminCheck(id)
public OnClientPutInServer(id)
{
    
SDKHook(idSDKHook_OnTakeDamageOnTakeDamage)

yokomo is offline
xf117
Senior Member
Join Date: Mar 2010
Location: Russia
Old 01-10-2014 , 05:57   Re: Client index 0 is invalid?
Reply With Quote #28

You'll have to do AskPluginLoad2 to hook players manually. Neither OnClientPutInServer nor OnClientPostAdminCheck called on existing clients if you load your plugin during the game.
xf117 is offline
Send a message via ICQ to xf117
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 01-10-2014 , 20:46   Re: Client index 0 is invalid?
Reply With Quote #29

Quote:
Originally Posted by xf117 View Post
You'll have to do AskPluginLoad2 to hook players manually. Neither OnClientPutInServer nor OnClientPostAdminCheck called on existing clients if you load your plugin during the game.
PHP Code:
public OnPluginStart()
{
    for (new 
=1MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
             
OnClientPutInServer(i);
        }
    }

Mathias. is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 01-10-2014 , 22:29   Re: Client index 0 is invalid?
Reply With Quote #30

Quote:
Originally Posted by Black-Rabbit View Post
PHP Code:
public OnPluginStart()
{
    for (new 
=1MaxClientsi++)
    {
        if (
IsClientInGame(i))
        {
             
OnClientPutInServer(i);
        }
    }

<

-->

<=
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work
RedSword 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 07:30.


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