Command and Conquer: Renegade Official Forums - RDF feed
type: channel
description: C&C: Renegade --> Dying since 2003™, resurrected in 2024!
items: C++ void On_Player_Death???
items: Re: C++ void On_Player_Death???

C++ void On_Player_Death???
type: item
description: Hey, i tried to make a code that turns people on team nod when they getkilled or when they die. This is the code i use in gmmain.cpp: void On_Player_Death(int i,const char *Nick) { GameObject *obj = Get_GameObj(ID); if (Commands->Get_Player_Type(obj) == 1) { Commands->Attach_Script(obj, "JFW_Change_Team_On_Custom", "0"); Commands->Attach_Script(obj, "JFW_Change_Spawn_Character", "Mutant_1_Renegade"); } }; This is the error i get: 1>.\gmmain.cpp(1303) : error C2065: 'ID' : undeclared identifier 1>Build log was saved at "file://c:\Westwood\RenegadeFDS\Server\SSGM Source\tmp\scripts\debug\BuildLog.htm" 1>SSGM - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== I asked some friend of me what's wrong, he said it's the ID wich would be correct I think xD He said the void On_Player_Death doesn't exist, I believe him, because i changed void On_Player_Join i think to player_death.. If someone of you guys would be so kind to give me the correct function how to use this? I searched in the ssgm files but couldn't find anything.. :s
creator: MutateMeh
date: 2010-07-06T21:47:59-00:00

Re: C++ void On_Player_Death???
type: item
description: void On_Player_Death(int i,const char *Nick) { GameObject *obj = Get_GameObj(i); if (Commands->Get_Player_Type(obj) == 1) { Commands->Attach_Script(obj, "JFW_Change_Team_On_Custom", "0"); Commands->Attach_Script(obj, "JFW_Change_Spawn_Character", "Mutant_1_Renegade"); } };
creator: snazy2000
date: 2010-07-06T21:54:23-00:00

Re: C++ void On_Player_Death???
type: item
description: Wait, so you just created a random function called On_Player_Death and you expect it to actually get called when a player dies? If it's not defined in the plugin interface then it's not going to work. Also, its complaining about ID because your passing a variable called ID to Get_GameObj but that variable has never been declared or initialized.
creator: danpaul88
date: 2010-07-06T22:12:18-00:00

Re: C++ void On_Player_Death???
type: item
description: Well, that was my question.. What IS the correct function? snazy's response helped me to 0 errors but nothing happens when i use it in-game, so what is the right function?
creator: MutateMeh
date: 2010-07-06T22:27:55-00:00

Re: C++ void On_Player_Death???
type: item
description: If the SSGM files don't define a function for that event then it simply doesn't exist and your out of luck. Not having worked with the SSGM plugin interface myself I don't know if it does or does not provide something with that functionality. Try looking for 'Killed' or 'Destroyed' in function names, that's what the engine calls death events internally so it would make sense for SSGM to follow that convention.
creator: danpaul88
date: 2010-07-06T22:31:03-00:00

Re: C++ void On_Player_Death???
type: item
description: couldn't find anything like that:o
creator: MutateMeh
date: 2010-07-06T23:02:25-00:00

Re: C++ void On_Player_Death???
type: item
description: If you really must use SSGM and not a plugin for it, then do the following: Open gmmain.ccp and find this portion of code: void ObjectHookCall(void *data,GameObject *obj) { if (Settings->Is_Disabled(obj)) { Commands->Destroy_Object(obj); return; } else if (Commands->Is_A_Star(obj)) { if ((Settings->GameMode == 3 || Settings->GameMode == 4) && !Settings->Is_Sniper(obj)) { Commands->Destroy_Object(obj); return; } else { Attach_Script_Once(obj,"MDB_SSGM_Player",""); } } This is a hook, and it is catching Game Objects when they are created. The "else if (Commands->Is_A_Star(obj)) {" part is basically saying "if the object is a player", so everything encapsulated in that part is dealing with players... The first part in that encapsulation (the part saying " if ((Settings->GameMode == 3 || Settings->GameMode == 4) && !Settings->Is_Sniper(obj)) {") basically means, if the game mode is 3 or 4, and the player isn't a sniper, then destroy the object. The the second part is saying, otherwise, attach this script to them "Attach_Script_Once(obj,"MDB_SSGM_Player","");". Now you could very well modify the MDB_SSGM_Player script so that on ::Killed it is changing the team if they are on GDI. However, it is better to add you script at this point instead, so you would change the above code to this: void ObjectHookCall(void *data,GameObject *obj) { if (Settings->Is_Disabled(obj)) { Commands->Destroy_Object(obj); return; } else if (Commands->Is_A_Star(obj)) { if ((Settings->GameMode == 3 || Settings->GameMode == 4) && !Settings->Is_Sniper(obj)) { Commands->Destroy_Object(obj); return; } else { Attach_Script_Once(obj,"MDB_SSGM_Player",""); Attach_Script_Once(obj,"MutateMeh_Death_Script",""); } } So basically, what you've done is attach the script "MutateMeh_Death_Script" to every single player. Now you need to write the actual script... //note, not tested and not properly indented due to typing directly into the browser and no IDE. // place in the .cpp file void MutateMeh_Death_Script::…
creator: reborn
date: 2010-07-07T07:42:10-00:00

Re: C++ void On_Player_Death???
type: item
description: Reborn your codegave me 0 errors, the compile went all perfect. But when i test it on my server, i just die.. and respawn as gdi.. not even another spawncharacter.. So i doubt if the script actually works.
creator: MutateMeh
date: 2010-07-07T11:44:54-00:00

Re: C++ void On_Player_Death???
type: item
description: Post your code.
creator: reborn
date: 2010-07-07T12:42:50-00:00

Re: C++ void On_Player_Death???
type: item
description: this is my gmmain.cpp /* Renegade Scripts.dll SSGM main functions and classes Copyright 2007 Vloktboky, Whitedragon(MDB), Mac, 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. */ #include <fstream> #include <stdarg.h> #include "scripts.h" #include "date.h" #include "engine.h" #include "gmmain.h" #ifdef WIN32 #include <ddeml.h> #else #include <dlfcn.h> #endif bool OkLoad = false; #ifndef WIN32 extern void *bhs; UnloaderClass Unloader; #endif DataStruct *Data = 0; SettingsStruct *Settings = 0; //****************************************************************************** //******************************* SETTINGS STUFF ******************************* //****************************************************************************** ScriptRegistrant<MutateMeh_Death_Script> MutateMeh_Death_Script_Registrant("MutateMeh_Death_Script",""); void SSGMSettings::Load() { LoadSString(FDSLogRoot,"FDSLogRoot","ssgm",true,false); LoadBool(Gamelog,"EnableGamelog",true,true,false); LoadBool(NewGamelog,"EnableNewGamelog",true,true,false); LoadBool(EnableLogging,"EnableLog",true,true,false); LoadBool(EchoLog,"EchoLog",true,true,false); LoadBool(MergeGamelogRenlog,"WriteGamelogtoSSGMlog",false,true,false); if (MergeGamelogRenlog) { Gamelog_Archive_Logfiles = false; } else { LoadBool(Gamelog_Archive_Logfiles,"GamelogArchiveLogfiles",false,true,false,false); } LoadInt(GameMode,"GameMode"); if (GameMode > 5 || GameMode < 1) { GameMode = 1; FDSMessage("Gamemod…
creator: MutateMeh
date: 2010-07-07T13:43:18-00:00

Re: C++ void On_Player_Death???
type: item
description: MutateMeh wrote on Wed, 07 July 2010 09:43 Maybe i did something wrong i don't know, i'm a pretty beginner in c++ so if it is, tell me You're a pretty beginner? I guess it beats being an ugly beginner! In your gmmain.cpp file you did not update the object create hook, so while the script is valid, it's not being called because it isn't attached to any players. I posted what you should do, but I guess you forgot? else { Attach_Script_Once(obj,"MDB_SSGM_Player",""); } should be else { Attach_Script_Once(obj,"MDB_SSGM_Player",""); Attach_Script_Once(obj,"MutateMeh_Death_Script",""); } Also, the registrant should go under the script itself, really.
creator: reborn
date: 2010-07-07T14:12:32-00:00

Re: C++ void On_Player_Death???
type: item
description: THAT WORKS!! Well, almost, something's wrong with the spawn character, it won't change like it should change. It just changed you to nod but not your spawncharacter, any idea what could be causing this? Thank you very much for the help anyways!
creator: MutateMeh
date: 2010-07-07T14:24:33-00:00

Re: C++ void On_Player_Death???
type: item
description: Not a problem. I am not familar with "JFW_Change_Spawn_Character", it could possibly be broken, or you're not using it correctly. Try taking a look at "Change_Spawn_Char", it's being used in gmmain.cpp so it must be working...
creator: reborn
date: 2010-07-07T14:28:55-00:00

Re: C++ void On_Player_Death???
type: item
description: Okay thanks again man i won't bother you with this anymore xD
creator: MutateMeh
date: 2010-07-07T14:45:34-00:00

Re: C++ void On_Player_Death???
type: item
description: It's fine, you can ask more questions. These are the type I prefer to see to be honest.
creator: reborn
date: 2010-07-07T14:54:25-00:00

Re: C++ void On_Player_Death???
type: item
description: Okay you will maybe laugh with this but.. i tried something with the change_spawn_character and the error seams clear, but i just don't understand what it means xD Code: void MutateMeh_Death_Script::Killed(GameObject *obj,GameObject *shooter) { if (Commands->Get_Player_Type(obj) == 1) { Change_Team(obj, 0); Change_Spawn_Char(obj, "Nun"); } } ScriptRegistrant<MutateMeh_Death_Script> MutateMeh_Death_Script_Registrant("MutateMeh_Death_Script",""); Error: 1>.\gmmain.cpp(1311) : error C2664: 'Change_Spawn_Char' : cannot convert parameter 1 from 'GameObject *' to 'int' 1> There is no context in which this conversion is possible 1>Creating browse information file... 1>Microsoft Browse Information Maintenance Utility Version 9.00.30729 1>Copyright (C) Microsoft Corporation. All rights reserved. 1>Build log was saved at "file://c:\Westwood\RenegadeFDS\Server\SSGM Source\tmp\scripts\debug\BuildLog.htm" 1>SSGM - 1 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
creator: MutateMeh
date: 2010-07-07T15:00:04-00:00

Re: C++ void On_Player_Death???
type: item
description: It seems that Change_Spawn_Char's first parameter is expecting an integer, not a GameObject. So it's either after the playe ID, or possibly the team type. If it wants the team type, then it's going to be setting the spawn character globally, and you'll have to do something a bit different to get individuals to have different spawn characters... //edit Looking at the use of it in gmmain.cpp it's after the team type, not the player ID. I am guessing you want to only set the default spawn character for the people on GDI that was killed, and normal Nod players to still be soldiers? Or a global change of spawn characters on Nod would be fine for you? Both are possible, but the former would be a bit more trickier.
creator: reborn
date: 2010-07-07T15:05:53-00:00

Re: C++ void On_Player_Death???
type: item
description: Well basically everyone on nod should have the same spawn character..
creator: MutateMeh
date: 2010-07-07T15:07:27-00:00

Re: C++ void On_Player_Death???
type: item
description: MutateMeh wrote on Wed, 07 July 2010 11:07 Well basically everyone on nod should have the same spawn character.. The use the setting in SSGM.ini to change the defualt spawn character of Nod, or call that change_spawn_char function only Once (no need to keep setting it over and over again). Instead of: Change_Spawn_Char(obj, "Nun"); try: Change_Spawn_Char(0, "Nun"); // I am not sure "Nun" is a valid character preset? o.0 But seriously, you do not need to be making this call every time a person dies, just call it Once on map load, or when the server starts...
creator: reborn
date: 2010-07-07T15:11:56-00:00

Re: C++ void On_Player_Death???
type: item
description: Hmm you got a point there Nun IS a character I use LevelEdit to get my char names so it is correct, and it worked on a buy command like !buy nun lolz hmm Well, i guess i now have What i need!! I have a long way to xD
creator: MutateMeh
date: 2010-07-07T15:15:08-00:00