AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Attacker (https://forums.alliedmods.net/showthread.php?t=270405)

nhnkl159 08-20-2015 14:12

Attacker
 
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

WildCard65 08-20-2015 15:15

Re: Attacker
 
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;
    }



nhnkl159 08-21-2015 03:11

Re: Attacker
 
Quote:

Originally Posted by WildCard65 (Post 2335287)
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 :/

WildCard65 08-21-2015 06:35

Re: Attacker
 
I added debugging to my code.

nhnkl159 08-21-2015 12:43

Re: Attacker
 
Quote:

Originally Posted by WildCard65 (Post 2335456)
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}

Miu 08-21-2015 13:23

Re: Attacker
 
try new attacker = GetEventInt(event, "attacker");

nhnkl159 08-21-2015 13:50

Re: Attacker
 
Quote:

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


same.. i got no Name of the attacker

WildCard65 08-21-2015 14:21

Re: Attacker
 
I wrote code in 1.7 syntax, also what does my debugging lines print to server console say?

nhnkl159 08-21-2015 14:26

Re: Attacker
 
Quote:

Originally Posted by WildCard65 (Post 2335578)
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.


All times are GMT -4. The time now is 15:34.

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