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

IsClientInGame always returning false??


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Flyman
New Member
Join Date: Sep 2007
Location: Australia
Old 09-01-2007 , 02:46   IsClientInGame always returning false??
Reply With Quote #1

Hi all,
for some strange reason which I can't figure out why, my clients are never in game according to this function, IsClientInGame(index) also just removing it from the script causes errors with the other functions, which I expected to happen anyway.

Can anyone explain to me why my clients are never in game even when they have been running around for 20 minutes, am I using the wrong user index or something??

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <events>

#pragma semicolon 1
#define PLUGIN_VERSION "1.0"

public Plugin:myinfo 
{
    
name "Jihad",
    
author "david balogh",
    
description "Plays a Jihad sound on a suicide kill",
    
version PLUGIN_VERSION,
    
url "http://www.ma15plus.com/"
};

public 
OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeathEventHookMode_Pre);
}

public 
OnMapStart()
{
    
PrecacheSound("sound/jihad.mp3"true);
    
AddFileToDownloadsTable("sound/jihad.mp3");
}

public 
Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    
PrintToChatAll("Death Event triggered");
    
    new 
String:victimname[64];
    new 
String:attackername[64];    
    new 
victimId GetEventInt(event"userid");
    new 
attackerId GetEventInt(event"attacker");
    new 
players GetMaxClients();
    
    
PrintToChatAll("AttackerId: %d victimId: %d"attackerIdvictimId);
    if(
attackerId != victimId)
    {
        
PrintToChatAll("Is Client In Game: %d :: %d"IsClientInGame(attackerId), IsClientInGame(victimId));
        if(
IsClientInGame(attackerId) && IsClientInGame(victimId))
        {
            
PrintToChatAll("Is Attacker Alive: %d Is Victim Alive: %d"IsPlayerAlive(attackerId), IsPlayerAlive(victimId));
            if(!
IsPlayerAlive(attackerId) && !IsPlayerAlive(victimId))
            {
                for (new 
Loop 1Loop playersLoop++)
                {
                    if(
IsClientInGame(Loop))
                    {
                        
ClientCommand(Loop"play jihad.mp3");
                    }
                }

                
GetClientName(victimIdvictimnamesizeof(victimname));
                
GetClientName(attackerIdattackernamesizeof(attackername));
                
PrintToChatAll("%s Went Jihad!!!!!!!!!!!!!!!!!!! on %s"attackernamevictimname);
            }
        }
    }
    
PrintToChatAll("End of death event");

    return;

This is my first script in this language, so I'm not sure how it all works yet.

Also does anyone have any IDE suggestions for this language?? notepad is a pain to use!!

Thanks for your help
David

EDIT: the mod is HL2DM

Last edited by Flyman; 09-01-2007 at 02:50.
Flyman is offline
Send a message via ICQ to Flyman Send a message via MSN to Flyman
dubbeh
Senior Member
Join Date: Jul 2007
Old 09-01-2007 , 03:23   Re: IsClientInGame always returning false??
Reply With Quote #2

I'm not sure about the IsClientInGame problem - code looks fine to me

For an IDE I recommend PSPad - pimpinjuice did a pre-configured one here & a more up to date syntax highlighter can be found here

Just put up the one I've been adding to overtime up
__________________
SM Plugins - dubbeh.net - Plugin requests are welcome
dubbeh is offline
Knagg0
SourceMod Donor
Join Date: Dec 2005
Location: Germany
Old 09-01-2007 , 03:59   Re: IsClientInGame always returning false??
Reply With Quote #3

You have to use the index of a client and not the userid ;)

Code:
/**
 * Translates an userid index to the real player index.
 *
 * @param userid		Userid value.
 * @return				Client value.
 * @error				Returns 0 if invalid userid.
 */
native GetClientOfUserId(userid);
__________________

MFZB Gaming Community

[ www.mfzb.de ]

Knagg0 is offline
Flyman
New Member
Join Date: Sep 2007
Location: Australia
Old 09-01-2007 , 04:47   Re: IsClientInGame always returning false??
Reply With Quote #4

I new it was something simple, it works now thanks.

Cheers for the IDE link it is making life easier already.


Thank you for your help, now time for me to go test the next bit.
Flyman is offline
Send a message via ICQ to Flyman Send a message via MSN to Flyman
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 08:33.


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