Title: Displaying Messages Post by: SkreamerVirii on September 03, 2008, 11:16:04 PM Adding and displaying messages when you activate or fire a weapon
If you have downloade dmy mod and have tested out any of the grenades you will see that when you throw a grenade a little message right bleow tyhe centerof the creen a message appears well im going to show you how to add such a message first we need to open up g_missle.c then we need to stroll on down to line 1170 you should be reading this code switch(grenadeWPID) { case WP_GRENADE_LAUNCHER: bolt->classname = "grenade"; // bolt->damage = 100; // bolt->splashDamage = 100; if ( g_gametype.integer >= GT_WOLF ) bolt->splashRadius = 300; else bolt->splashRadius = 150; bolt->methodOfDeath = MOD_GRENADE; bolt->splashMethodOfDeath = MOD_GRENADE_SPLASH; bolt->s.eFlags = EF_BOUNCE_HALF | EF_BOUNCE; break; now we want to add this trap_SendServerCommand( self-g_entities, "cp \"Grenaaaaade!\""); the reason i want to use this is because if we scroll down a little bit more to this code case WP_DYNAMITE: case WP_DYNAMITE2: bolt->accuracy = 0; // JPW NERVE sets to score below if dynamite is in trigger_objective_info & it's an objective trap_SendServerCommand( self-g_entities, "cp \"Dynamite is set, but NOT armed!\""); // differentiate non-armed dynamite with non-pulsing dlight bolt->s.teamNum = self->client->sess.sessionTeam + 4; bolt->classname = "dynamite"; bolt->damage = 0; bolt->splashDamage = 333; bolt->splashRadius = 800; bolt->methodOfDeath = MOD_DYNAMITE; bolt->splashMethodOfDeath = MOD_DYNAMITE_SPLASH; bolt->s.eFlags = (EF_BOUNCE | EF_BOUNCE_HALF); // EF_BOUNCE_HEAVY; and if you notice like i did this is actually what made me come up with this idea trap_SendServerCommand( self-g_entities, "cp \"Dynamite is set, but NOT armed!\""); that this is the messageyou get when you drop some dynamite so i then took trap_SendServerCommand( self-g_entities, "cp \"Dynamite is set, but NOT armed!\""); figured out where it would best fit and grenades popped into my mind immediatly so i scrolled back up to switch(grenadeWPID) { case WP_GRENADE_LAUNCHER: bolt->classname = "grenade"; // bolt->damage = 100; // bolt->splashDamage = 100; if ( g_gametype.integer >= GT_WOLF ) bolt->splashRadius = 300; else bolt->splashRadius = 150; bolt->methodOfDeath = MOD_GRENADE; bolt->splashMethodOfDeath = MOD_GRENADE_SPLASH; bolt->s.eFlags = EF_BOUNCE_HALF | EF_BOUNCE; break; looked at where the code was orginally placed case WP_DYNAMITE: case WP_DYNAMITE2: bolt->accuracy = 0; // JPW NERVE sets to score below if dynamite is in trigger_objective_info & it's an objective trap_SendServerCommand( self-g_entities, "cp \"Dynamite is set, but NOT armed!\""); // differentiate non-armed dynamite with non-pulsing dlight bolt->s.teamNum = self->client->sess.sessionTeam + 4; bolt->classname = "dynamite"; and placed my code in and around the same place but in the grenades block so it looked something like this switch(grenadeWPID) { case WP_GRENADE_LAUNCHER: trap_SendServerCommand( self-g_entities, "cp \"Grenaaaaade!\""); bolt->classname = "grenade"; // bolt->damage = 100; // bolt->splashDamage = 100; if ( g_gametype.integer >= GT_WOLF ) bolt->splashRadius = 300; else bolt->splashRadius = 150; bolt->methodOfDeath = MOD_GRENADE; bolt->splashMethodOfDeath = MOD_GRENADE_SPLASH; bolt->s.eFlags = EF_BOUNCE_HALF | EF_BOUNCE; break; Okay now compile run the game and throw a grenade it should say whatever it is you type in for the message and that message should stay printed on the screen for a while then fade away enjoy!!! |