Home » Renegade Discussions » Mod Forum » Headshot message for Server.
() 1 Vote
Headshot message for Server. [message #439848] |
Sun, 21 November 2010 14:50 |
crysis992
Messages: 314 Registered: June 2008
Karma: 0
|
Recruit |
|
|
Hello, im working atm on kill strike messages, okay I´ve done them so far. But now i want a headshot message.
"<nick> killed <KILLEDnick>. Headshot"
I did the killstrike script on this way:
if (kills == 2)
{
Create_2D_WAV_Sound_Player(obj,"multikill.wav");
Console_Input(StrFormat("msg %s made a double kill (2)", Get_Player_Name(obj)).c_str());
}
else if (kills == 3)
.
.
.
.
its working, but how i do this headshot thing? I rly have no idea + im just a beginner in this c++ shit *lol*
|
|
|
|
Re: Headshot message for Server. [message #439855 is a reply to message #439848] |
Sun, 21 November 2010 15:52 |
crysis992
Messages: 314 Registered: June 2008
Karma: 0
|
Recruit |
|
|
Okay Ive tested the kill strikes with more players and it seems that they are bugged.
If someone make a doulbe kill, and he get killed the message comes.
Sometimes the message appear 4-8 times.
Thats what I´ve done:
gmscripts.cpp
//******************************************************************************
//************************* PLAYER RELATED SCRIPTS *****************************
//******************************************************************************
//This script is attached to all players.
void MDB_SSGM_Player::Created(GameObject *obj) {
if (Settings->ForceTeam != -1) {
if (Commands->Get_Player_Type(obj) != Settings->ForceTeam) {
Change_Team(obj,Settings->ForceTeam);
return;
}
}
const char *Nick = Get_Player_Name(obj);
if (strstr(Nick,";")) { //Breaks gamelog. Crashes if done in the player join hook.
Console_Input(StrFormat("kick %d",Get_Player_ID(obj)).c_str());
delete[] Nick;
return;
}
delete[] Nick;
if (Settings->GameMode != 1) {
Commands->Set_Is_Visible(obj,false);
}
Commands->Attach_Script(obj,"MDB_SSGM_Taunt_Key","Taunt1,h_a_a0a0_l12");
Commands->Attach_Script(obj,"MDB_SSGM_Taunt_Key","Taunt2,H_A_a0a0_L22");
Commands->Attach_Script(obj,"MDB_SSGM_Taunt_Key","Taunt3,H_A_a0a0_L23");
Commands->Attach_Script(obj,"MDB_SSGM_Taunt_Key","Taunt4,H_A_a0a0_L24");
Commands->Attach_Script(obj,"MDB_SSGM_Taunt_Key","Taunt5,H_A_a0a0_L25");
Commands->Attach_Script(obj,"MDB_SSGM_Taunt_Key","Taunt6,H_A_a0a0_L58");
Commands->Attach_Script(obj,"MDB_SSGM_Taunt_Key","Taunt7,H_A_cresentkick");
Commands->Attach_Script(obj,"MDB_SSGM_Taunt_Key","Taunt8,H_A_sidekick");
Commands->Attach_Script(obj,"MDB_SSGM_Taunt_Key","Taunt9,H_A_punchcombo");
Commands->Attach_Script(obj,"MDB_SSGM_WriteLog_Key","VoteYes,!vote yes,0");
Commands->Attach_Script(obj,"MDB_SSGM_WriteLog_Key","VoteNo,!vote no,0");
if (Settings->GameMode == 2) {
Commands->Attach_Script(obj,"MDB_SSGM_ChatCommand_Key","VehBind,!captures,1");
Commands->Attach_Script(obj,"MDB_SSGM_ChatCommand_Key","VehBL,!flaginfo,1");
}
[COLOR=red] if (Settings->GameMode == 3) {
Commands->Attach_Script(obj,"z_player","");
}[/COLOR]
.
.
.
gmscripts.h
//******************************************************************************
//************************* PLAYER RELATED SCRIPTS *****************************
//******************************************************************************
//This script is attached to all players.
class MDB_SSGM_Player : public ScriptImpClass {
void Created(GameObject *obj);
void Destroyed(GameObject *obj);
void z_Player(GameObject *obj);
void Killed(GameObject *obj, GameObject *shooter);
void Timer_Expired(GameObject *obj, int number);
void MDB_SSGM_Player::Custom(GameObject *obj, int message, int param, GameObject *sender);
Vector3 SpawnPos;
int AfkDetect;
bool WasKilled;
};
c_kills.cpp
#include "scripts.h"
#include "engine.h"
#include "gmmain.h"
#include "cry_kills.h"
#include "gmgamelog.h"
#include "date.h"
#include <stdarg.h>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <ddeml.h>
#endif
#include <fstream>
#include <iostream>
#include <sstream>
#include <time.h>
#include <algorithm>
#include <map>
void z_Player::Created(GameObject *obj)
{
kills = 0;
}
void z_Player::Custom(GameObject *obj, int message, int param, GameObject *sender)
{
if (kills == 2)
{
Commands->Create_2D_WAV_Sound("double_kill.wav");
Console_Input(StrFormat("msg %s made a double kill (2)", Get_Player_Name(obj)).c_str());
}
else if (kills == 3)
{
Commands->Create_2D_WAV_Sound("triplekill.mp3");
Commands->Create_2D_WAV_Sound("triplekill.wav");
Console_Input(StrFormat("msg %s made a Tripple. (3)", Get_Player_Name(obj)).c_str());
}
else if (kills == 4)
{
Commands->Create_2D_WAV_Sound("multikill.wav");
Console_Input(StrFormat("msg %s made a Multikill (4)", Get_Player_Name(obj)).c_str());
}
else if (kills == 6)
{
Commands->Create_2D_WAV_Sound("Monsterkill_F.wav");
Console_Input(StrFormat("msg %s made a M-M-M-M-Monster Kill!!! (6)", Get_Player_Name(obj)).c_str());
}
else if (kills == 8)
{
Commands->Create_2D_WAV_Sound("rampage.wav");
Console_Input(StrFormat("msg Oh my GOD! %s is on a rampage (7)", Get_Player_Name(obj)).c_str());
}
else if (kills == 9)
{
char msg[250];
Commands->Create_2D_WAV_Sound("unstoppable.wav");
Console_Input(StrFormat("msg %s is unstoppable!!", Get_Player_Name(obj)).c_str());
}
else if (kills == 13)
{
char msg2[250];
Console_Input(StrFormat("msg [Info]: %s is on a killingspree (3)", Get_Player_Name(obj)).c_str());
Commands->Create_2D_WAV_Sound("monsterkill.wav");
Send_Message(255,255,255,msg2);
}
else if (kills == 15)
{
Commands->Create_2D_WAV_Sound("godlike.mp3");
Console_Input(StrFormat("msg %s is godlike...", Get_Player_Name(obj)).c_str());
}
}
void z_Player::Register_Auto_Save_Variables()
{
Auto_Save_Variable(1,4,&kills);
}
ScriptRegistrant<z_Player> z_Player_Registrant("z_Player","");
cry_kills.h
class z_Player : public ScriptImpClass {
void Created(GameObject *obj);
void Custom(GameObject *obj, int message, int param, GameObject *sender);
void Register_Auto_Save_Variables();
int kills;
};
So i dont know why its not working correctly or whats the problem
Some IRC Logs:
[ 23:49:44] 15|><>7 [Cry]BoT 15<><| 7[Message] Host: [INFO] Renegadeskins.Net Sniper server for HoH Clan
[ 23:49:48] 15|><>7 [Cry]BoT 15<><| 7[Message] [THS]-Jure made a double kill (2)
[ 23:49:51] 15|><>7 [Cry]BoT 15<><| 7[Message] [THS]-Jure made a Tripple. (3)
[ 23:49:51] 15|><>7 [Cry]BoT 15<><| 07[Kill] 04[THS]-Jure killed [THS]-Maxim with Sniper Rifle.
[ 23:49:51] 15|><>7 [Cry]BoT 15<><| 04[THS]-Jure killed [THS]-Maxim (Nod Blackhand Sniper/Sniper Rifle 04vs GDI Havoc04)
[ 23:50:06] 15|><>7 [Cry]BoT 15<><| 7[Message] [THS]-Jure made a Tripple. (3)
---------------------------
[ 23:48:04] 15|><>7 [Cry]BoT 15<><| 04Finalchapter killed [THS]-Maxim (Nod Blackhand Sniper/Sniper Rifle 04vs GDI Deadeye04)
[ 23:48:11] 15|><>7 [Cry]BoT 15<><| 7[Message] Finalchapter made a double kill (2)
[ 23:48:12] 15|><>7 [Cry]BoT 15<><| 7[Message] Finalchapter made a double kill (2)
[ 23:48:13] 15|><>7 [Cry]BoT 15<><| 7[Message] Finalchapter made a double kill (2)
[ 23:48:18] 15|><>7 [Cry]BoT 15<><| 7[Message] Finalchapter made a double kill (2)
|
|
|
Re: Headshot message for Server. [message #439873 is a reply to message #439848] |
Mon, 22 November 2010 01:26 |
|
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
Where do you send the custom that updates the amount of kills a player has gained? I do not see how the variable "kills" is increased.
Also, the multi spamming of the message could be because you're not filter which custom it is you're looking for, so on death the player may be receiving several customs, which are all triggering that message.
[Updated on: Mon, 22 November 2010 01:27] Report message to a moderator
|
|
|
|
|
|
Re: Headshot message for Server. [message #439948 is a reply to message #439848] |
Tue, 23 November 2010 01:13 |
|
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
I will write this for you so you understand it when I have the time.
Infact, I'll write two implementations, one similar to jnz's with a global variable, and one in the format you're more used to seeing.
|
|
|
Re: Headshot message for Server. [message #439972 is a reply to message #439848] |
Tue, 23 November 2010 14:41 |
|
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
I wrote this, and it's compiled, but I never actually bothered to test it, mainly because I do not have the custom .wav files you're referencing, and secondly because I couldn't be bothered really.
Here is the first version, written more in the style that jnz posted, with global variables and a code that is not exactly conforming to the standard renegade API useage. I will if I have time write a script that's all tidy and familiar to you and the renegade API.
It's important to remeber though, that while in this instance it's probably better to use the API classes and conform to that standard, it isn't always... There are thing that are deemed "impossible" by some, that really are quite simple useing "hacks" like this.
Plus, if you only learn to code using the renegade API you'll end up very confused later on when you want to write something else.
I wrote this as a SSGM plugin, and have attached the full source code.
/* Renegade Scripts.dll
Example Plugin Code
Copyright 2007 Whitedragon(MDB), Jonathan Wilson, spencer "reborn" elliott
This file is part of the Renegade scripts.dll
The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version. See the file COPYING for more details.
In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
Only the source code to the module(s) containing the licenced code has to be released.
*/
/* This is an example of how to implement a server hack to make it register, record and display player kill sprees.
This has been done WITHOUT the client scripts.dll in mind and has NOT respected the accepted use of the renegade API.
It uses global variables and custom C++ functions. Ironically it is more readable to other programmers outside the renegade community.
In this instance however, it is probably easier and more efficient to use the classes that the API lends itself to, this is just an example...
*/
#include "scripts.h"
#include <stdarg.h>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include "engine.h"
#include "gmmain.h"
#include "KillMessages.h"
int PlayerKills[127];
int ObjectHookID = 0;
ObjectCreateHookStruct *ObjectHookStruct = 0;
// This hook is caled when an object is created
void ObjectHookCall(void *data,GameObject *obj)
{
//This is kinda like a little filter...
//I'm basically saying here that if the object that was created is a player, then do the following...
if(Commands->Is_A_Star(obj))
{
//This ensures that all players get this script attached to them
Commands->Attach_Script(obj, "KillMessages", "");
}
}
void Plugin_Load()
{
//When the plugin loads this code is called and sets up the object creation hook.
ObjectHookStruct = new ObjectCreateHookStruct;
ObjectHookStruct->hook = ObjectHookCall;
ObjectHookStruct->data = 0;
ObjectHookID = AddObjectCreateHook(ObjectHookStruct);
}
//This is a C++ function.
//I created the function because I call it several times in different places,
//so it cuts down on the amount of lines I need to write, and makes things neater, it also cuts down on chanecs for error.
//and if I ned to make a change to the function, it's only here that I need to change it.
//It's use is limited to setting the global variable of PlayerKills for a specific player to Zero.
void ZeroOutKills(int PlayerID)
{
PlayerKills[PlayerID] = 0;
}
//Another function.
//int Amount is actually over kill TBH, I always know I will be adding only 1 kill at a time, but this is just to demonstrate really.
void AddKill(int PlayerID, int Amount)
{
PlayerKills[PlayerID] += PlayerKills[PlayerID] + Amount;
}
//A funtion to get the running killing spree count of a player
int GetKillingSpreeCount(int PlayerID)
{
int kills = PlayerKills[PlayerID];
return kills;
}
//This is the actual "Guts" of the pluging. It is the script that is attached to the players and updates kills etc.
void KillMessages::Created(GameObject *obj)
{
//When player spawns set their running kills to zero.
//The function ZeroOutKills takes the player ID, so the below does this: Get_Player_ID(obj)
//That retrieves the player ID for me from the GameObject, which is the piece of information I know about the player.
ZeroOutKills(Get_Player_ID(obj));
}
void KillMessages::Killed(GameObject *obj, GameObject *shooter)
{
//Just a little safety check to make sure that the killer is actually a player and not a patch of tiberium or something stupid like fall damage...
if(Commands->Is_A_Star(shooter))
{
//Update the player's running kill amount that shot the player.
//So basically what you're doing here is waiting for the player to die
//then when they do die, update the amount of kills for the person that killed them.
AddKill(Get_Player_ID(obj), 1);
if (GetKillingSpreeCount(Get_Player_ID(shooter)) == 2)
{
Commands->Create_2D_WAV_Sound("double_kill.wav");
Console_Input(StrFormat("msg %s made a double kill (2)", Get_Player_Name(shooter)).c_str());
}
else if (GetKillingSpreeCount(Get_Player_ID(shooter)) == 3)
{
Commands->Create_2D_WAV_Sound("triplekill.wav");
Console_Input(StrFormat("msg %s made a Tripple. (3)", Get_Player_Name(shooter)).c_str());
}
else if (GetKillingSpreeCount(Get_Player_ID(shooter)) == 4)
{
Commands->Create_2D_WAV_Sound("multikill.wav");
Console_Input(StrFormat("msg %s made a Multikill (4)", Get_Player_Name(shooter)).c_str());
}
else if (GetKillingSpreeCount(Get_Player_ID(shooter)) == 6)
{
Commands->Create_2D_WAV_Sound("Monsterkill_F.wav");
Console_Input(StrFormat("msg %s made a M-M-M-M-Monster Kill!!! (6)", Get_Player_Name(shooter)).c_str());
}
else if (GetKillingSpreeCount(Get_Player_ID(shooter)) == 8)
{
Commands->Create_2D_WAV_Sound("rampage.wav");
Console_Input(StrFormat("msg Oh my GOD! %s is on a rampage (7)", Get_Player_Name(shooter)).c_str());
}
else if (GetKillingSpreeCount(Get_Player_ID(shooter)) == 9)
{
Commands->Create_2D_WAV_Sound("unstoppable.wav");
Console_Input(StrFormat("msg %s is unstoppable!!", Get_Player_Name(shooter)).c_str());
}
else if (GetKillingSpreeCount(Get_Player_ID(shooter)) == 13)
{
Console_Input(StrFormat("msg %s is on a killingspree", Get_Player_Name(shooter)).c_str());
Commands->Create_2D_WAV_Sound("monsterkill.wav");
}
else if (GetKillingSpreeCount(Get_Player_ID(shooter)) == 15)
{
Commands->Create_2D_WAV_Sound("godlike.mp3");
Console_Input(StrFormat("msg %s is godlike...", Get_Player_Name(shooter)).c_str());
}
}
}
void Plugin_Unload()
{
//This is just the unloading of the plugin, the standard example doesn't remove the hook and can cause a crash.
//remember to do this in your own plugins.
RemoveObjectCreateHook(ObjectHookID);
delete ObjectHookStruct;
}
extern "C"
{
//This is the player join hook. This code here is called when a player joins the server.
DLLEXPORT void SSGM_Player_Join_Hook(int ID, const char *Nick)
{
//When the player joins, set their kills to 0.
//This is just good practice, but probably redundant, as it is also set to 0 when they spawn.
ZeroOutKills(ID);
}
//This is the map load hook. This code is called when the map loads.
DLLEXPORT void SSGM_Level_Loaded_Hook()
{
//This is a simple "for" loop. This loop basically set every single players kills to 0 when the map loads.
//It also is probably redundant as when the map loads and the player spawns their kills would be set to 0.
for(unsigned int i = 1; i <= 127; i++)
{
ZeroOutKills(i);
}
}
}
/* Renegade Scripts.dll
Example Plugin Code
Copyright 2007 Whitedragon(MDB), Jonathan Wilson
This file is part of the Renegade scripts.dll
The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version. See the file COPYING for more details.
In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
Only the source code to the module(s) containing the licenced code has to be released.
*/
#define PluginName "reborn's killing spree plugin"
#define PluginVersion "1.0"
void Plugin_Load();
void ZeroOutKills(int PlayerID);
void AddKill(int PlayerID, int Amount);
int GetKillingSpreeCount(int PlayerID);
class KillMessages : public ScriptImpClass
{
void Created(GameObject *obj);
void Killed(GameObject *obj, GameObject *Killer);
};
void Plugin_Unload();
Download the full source code here.
|
|
|
|
|
|
|
|
|
|
|
Re: Headshot message for Server. [message #440071 is a reply to message #439848] |
Thu, 25 November 2010 23:34 |
|
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
This line here is wrong:
for(unsigned int i = 1; i <= 127; i++)
It should be:
for(unsigned int i = 0; i < 127; i++)
It's not the first time 0 based indexing caught me out. What a newbie mistake!
|
|
|
|
|
|
Re: Headshot message for Server. [message #440292 is a reply to message #439848] |
Mon, 29 November 2010 14:03 |
|
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
AddKill(Get_Player_ID(obj), 1);
Should be:
AddKill(Get_Player_ID(shooter), 1);
Updated download to include various fixes, here.
Sorry for delay, I have been very busy.
|
|
|
|
|
Goto Forum:
Current Time: Tue Dec 03 11:36:29 MST 2024
Total time taken to generate the page: 0.01747 seconds
|