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

I'm doing something wrong, my event wont fire


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Craftkiller
Junior Member
Join Date: Jul 2007
Old 07-03-2007 , 10:54   I'm doing something wrong, my event wont fire
Reply With Quote #1

My goal is to eventually write a team balancer that works based on Mani Admin ranks but everyones gotta start somewhere. Can someone please tell me why I dont respawn when I type !revive

Quote:
#include <sourcemod>
#include <sdktools>
new Handle:hGameConf;
new Handle:hRoundRespawn;
//void CCSPlayer::RoundRespawn();
public Plugin:myinfo = {
name = "Craftkiller's Team Balancer",
author = "Craftkiller",
description = "Balances teams based on Mani Admin Rank",
version = "1.0",
url = "http://craftkiller.com"
};

public OnPluginStart()
{
RegConsoleCmd("sm_revive", Revive)
hGameConf = LoadGameConfigFile("plugin.sdkexamples");
StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "RoundRespawn");
hRoundRespawn = EndPrepSDKCall();
}
public Action:Revive(client, args)
{
if (client)
{
new String:name[32]
GetClientName(client, name, sizeof(name))
PrintToConsole(client, "Command from client: %s", name)
RespawnPlayer(client);

} else {
PrintToServer("Command from server.")
}
}
RespawnPlayer(client)
{
SDKCall(hRoundRespawn, client);
}
Craftkiller is offline
Hell Phoenix
Senior Member
Join Date: Jan 2005
Old 07-03-2007 , 13:17   Re: I'm doing something wrong, my event wont fire
Reply With Quote #2

!revive is never caught by the plugin. You need to hook into the chat first and see if thats what they said, and if it is, fire the event. You can look at a bunch of the approved plugins for examples.
__________________
Hell Phoenix is offline
ferret
SourceMod Developer
Join Date: Dec 2004
Location: Atlanta, GA
Old 07-03-2007 , 13:23   Re: I'm doing something wrong, my event wont fire
Reply With Quote #3

!revive only works if you use RegAdminCmd, not RegConsoleCmd.

You'll need to do like Hell Phoenix said (RegConsoleCmd on say and say_team), or make it into a RegAdminCmd.
__________________
I'm a blast from the past!
ferret is offline
Craftkiller
Junior Member
Join Date: Jul 2007
Old 07-07-2007 , 15:04   Re: I'm doing something wrong, my event wont fire
Reply With Quote #4

Thank you guys, I will try that
Craftkiller is offline
Craftkiller
Junior Member
Join Date: Jul 2007
Old 07-19-2007 , 16:32   Re: I'm doing something wrong, my event wont fire
Reply With Quote #5

Ok I decided to switch over to killing instead of reviving, and I still have a small problem.
Now the thing works almost completely. It says the person was killing in the top right, creates the X on the minimap, even makes my server go "Headshot!" however it doesn't actually kill the person. What am I doing wrong now?

Code:
#include <sourcemod>
#include <sdktools>
//void CCSPlayer::RoundRespawn();
public Plugin:myinfo = {
    name = "Craftkiller's Team Balancer",
    author = "Craftkiller",
    description = "Balances teams based on Mani Admin Rank",
    version = "1.0",
    url = "http://craftkiller.com"
};
 
public OnPluginStart() 
{
    RegConsoleCmd("sm_kill", smKill)
}
public Action:smKill(client, args)
{
    if (client)
    {
        ReplyToCommand(client, "Killing...");
        new String:name[32]
        GetClientName(client, name, sizeof(name))
        ReplyToCommand(client, "Name:%s", name);
        //RespawnPlayer(client);
        decl String:arg[65];
        GetCmdArg(1, arg, sizeof(arg));
        ReplyToCommand(client, "Target:%s", arg);
        new clients[64];
        new numClients = SearchForClients(arg, clients, 2);
        ReplyToCommand(client, "Num:%d", numClients);
        if (numClients == 0)
        {
            ReplyToCommand(client, "No matching client");
            return Plugin_Handled;
        } else if (numClients > 1) {
            ReplyToCommand(client, "More than one client matches");
            return Plugin_Handled;
        }
        ReplyToCommand(client, "1 target");
        decl String:name2[65];
    
        GetClientName(clients[0], name2, sizeof(name));
        ReplyToCommand(client, "Target:%s", name2);
        ReplyToCommand(client, "Sending Command.... pray");
        SendDeathMessage(client, clients[0], "p90", true);
    } else {
        PrintToServer("Command from server.")
    }
    return Plugin_Continue
}
SendDeathMessage(attacker, victim, const String:weapon[], bool:headshot)
{
    new Handle:event = CreateEvent("player_death");
    if (event == INVALID_HANDLE)
    {
        return
    }
 
    SetEventInt(event, "userid", GetClientUserId(victim));
    SetEventInt(event, "attacker", GetClientUserId(attacker));
    SetEventString(event, "weapon", weapon);
    SetEventBool(event, "headshot", headshot);
    FireEvent(event);
}
Craftkiller is offline
pRED*
Join Date: Dec 2006
Old 07-19-2007 , 17:02   Re: I'm doing something wrong, my event wont fire
Reply With Quote #6

Death message != Kill.

All that does is send the message that appears in the top right hand corner of the screen. Other plugins hook this message to play sounds and stuff...

Look in supercmds for slay coding if you want.. Virtual function CommitSuicide();
pRED* is offline
Craftkiller
Junior Member
Join Date: Jul 2007
Old 07-19-2007 , 21:01   Re: I'm doing something wrong, my event wont fire
Reply With Quote #7

oh thank you! super commands is exactly what I needed!
Craftkiller 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 06:36.


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