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

Attacker


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nhnkl159
Senior Member
Join Date: Jul 2012
Location: Israel 3>
Old 08-20-2015 , 14:12   Attacker
Reply With Quote #1

Hey This is my simple code :

Code:
new String:killer[64][68];
 
 
public void OnPluginStart()
{
        RegConsoleCmd("sm_test", Command_test, "", 0);
        HookEvent("player_death", Event_PD, EventHookMode);
}
 
public Action:Command_test(client, args)
{

       CPrintToChat(i, "{green} %N Killed By %s", client, killer[client]);

}
 
 
public Action:Event_PD(Handle:event, String:name[], bool:dontBroadcast)
{
        new attackerId = GetEventInt(event, "attacker", 0);
        new attacker = GetClientOfUserId(attackerId);
        decl String:name1[64];
        GetClientName(attacker, name1, 64);
        return Plugin_Handled;
}
How Can I PrintToChat With Command the attacker?
Thx For Helpers
__________________

Last edited by nhnkl159; 08-20-2015 at 14:14.
nhnkl159 is offline
Send a message via Skype™ to nhnkl159
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 08-20-2015 , 15:15   Re: Attacker
Reply With Quote #2

try:
PHP Code:
#include <morecolors>
int killer[MAXPLAYERS+1];

public 
void OnPluginStart()
{
    
RegConsoleCommand("sm_test"Command_Test""0);
    
HookEvent("player_death"Event_PD);
}

public 
Action Command_Test(int clientint args)
{
    
int myKiller GetClientOfUserId(killer[client]);
    
PrintToServer("%i and %i"myKillerview_as<int>(IsClientInGame(myKiller));
    if (
IsClientInGame(myKiller))
        
CReplyToCommand(client"You were killed by %N"myKiller);
    
killer[victim] = 0;
}

public 
void Event_PD(Event event, const char[] namebool dontBroadcast)
{
    
int victim GetClientOfUserId(event.GetInt("userid")), attacker event.GetInt("attacker");
    if (
IsClientInGame(victim))
    {
        
PrintToServer("Testing: %N and %i"victimattacker);
        
killer[victim] = attacker;
    }

__________________

Last edited by WildCard65; 08-21-2015 at 06:37.
WildCard65 is offline
nhnkl159
Senior Member
Join Date: Jul 2012
Location: Israel 3>
Old 08-21-2015 , 03:11   Re: Attacker
Reply With Quote #3

Quote:
Originally Posted by WildCard65 View Post
try:
PHP Code:
#include <morecolors>
int killer[MAXPLAYERS+1];

public 
void OnPluginStart()
{
    
RegConsoleCommand("sm_test"Command_Test""0);
    
HookEvent("player_death"Event_PD);
}

public 
Action Command_Test(int clientint args)
{
    
int myKiller GetClientOfUserId(killer[client]);
    if (
IsClientInGame(myKiller))
        
CPrintToChat(client"You were killed by %N"myKiller);
    
killer[victim] = 0;
}

public 
void Event_PD(Event event, const char[] namebool dontBroadcast)
{
    
int victim GetClientOfUserId(event.GetInt("userid")), attacker event.GetInt("attacker");
    if (
IsClientInGame(victim))
        
killer[victim] = attacker;

not working :/
__________________
nhnkl159 is offline
Send a message via Skype™ to nhnkl159
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 08-21-2015 , 06:35   Re: Attacker
Reply With Quote #4

I added debugging to my code.
__________________

Last edited by WildCard65; 08-21-2015 at 06:37.
WildCard65 is offline
nhnkl159
Senior Member
Join Date: Jul 2012
Location: Israel 3>
Old 08-21-2015 , 12:43   Re: Attacker
Reply With Quote #5

Quote:
Originally Posted by WildCard65 View Post
I added debugging to my code.
int victim = GetClientOfUserId(event.GetInt("userid")), attacker = event.GetInt("attacker");

error 105
connot find method or property Handle.GetInt

i try :

Quote:
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
But Still Not Showing Name..

its Show :
Quote:
You were killed by {nothing}
__________________

Last edited by nhnkl159; 08-21-2015 at 12:53.
nhnkl159 is offline
Send a message via Skype™ to nhnkl159
Miu
Veteran Member
Join Date: Nov 2013
Old 08-21-2015 , 13:23   Re: Attacker
Reply With Quote #6

try new attacker = GetEventInt(event, "attacker");

Last edited by Miu; 08-21-2015 at 13:24.
Miu is offline
nhnkl159
Senior Member
Join Date: Jul 2012
Location: Israel 3>
Old 08-21-2015 , 13:50   Re: Attacker
Reply With Quote #7

Quote:
Originally Posted by Miu View Post
try new attacker = GetEventInt(event, "attacker");

same.. i got no Name of the attacker
__________________

Last edited by nhnkl159; 08-21-2015 at 13:50.
nhnkl159 is offline
Send a message via Skype™ to nhnkl159
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 08-21-2015 , 14:21   Re: Attacker
Reply With Quote #8

I wrote code in 1.7 syntax, also what does my debugging lines print to server console say?
__________________
WildCard65 is offline
nhnkl159
Senior Member
Join Date: Jul 2012
Location: Israel 3>
Old 08-21-2015 , 14:26   Re: Attacker
Reply With Quote #9

Quote:
Originally Posted by WildCard65 View Post
I wrote code in 1.7 syntax, also what does my debugging lines print to server console say?

i was remove the printtoserver..

but its no matter i need that will print to chat with a command.
__________________
nhnkl159 is offline
Send a message via Skype™ to nhnkl159
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 06:55.


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