TheReferee Posted January 2, 2013 Posted January 2, 2013 Hello, I'm really bad at modding xPThis is for jk2 btw >.< Q1: is it possible to make text that is displayed on a timer and if so can you help me?EX: Every 10mins, "I hope you are enjoying your stay" is displayed Q2: Does anyone know the code for stats after a duel (health/shield) Q3: Does anyone know the code to make broadcasting messages easier (amsay all/dcsay all)EX: /amsay all Welcome to the Server:D Thank you
Fighter Posted January 2, 2013 Posted January 2, 2013 Code for Q2:In g_active.c, in the ClientThink_real function, search for: trap_SendServerCommand( -1, va("cp \"%s %s %s!\n\"", ent->client->pers.netname, G_GetStripEdString("SVINGAME", "PLDUELWINNER"), duelAgainst->client->pers.netname) );and replace it with trap_SendServerCommand( -1, va("cp \"%s %s %s with %i health and %i shields remaining!\n\"", ent->client->pers.netname, G_GetStripEdString("SVINGAME", "PLDUELWINNER"), duelAgainst->client->pers.netname, ent->client->ps.stats[STAT_HEALTH], ent->client->ps.stats[STAT_ARMOR]) );Edit: Looking at the code again, it looks like you need to move the above line so it's before this piece of code: if (ent->health < ent->client->ps.stats[STAT_MAX_HEALTH]) { ent->client->ps.stats[STAT_HEALTH] = ent->health = ent->client->ps.stats[STAT_MAX_HEALTH]; }otherwise it'll just print that the winner won with full health remaining. Code for Q3:I think this is a combination of JK3 ClanMod and some OJP code that I use a variation of in my JK3 mod, but it should work fine in JK2:http://pastebin.com/CGXBMWPh If I figure out Q1, I'll update this post.
TheReferee Posted January 3, 2013 Author Posted January 3, 2013 i cant seem to get Q2 to work >.< trap_SendServerCommand( -1, va("cp \"%s %s %s with %i health and %i shields remaining!\n\"", ent->client->pers.netname, G_GetStripEdString("SVINGAME", "PLDUELWINNER"), duelAgainst->client->pers.netname, ent->client->ps.stats[STAT_HEALTH], ent->client->ps.stats[STAT_ARMOR]) ); if (ent->health < ent->client->ps.stats[STAT_MAX_HEALTH]) { ent->client->ps.stats[STAT_HEALTH] = ent->health = ent->client->ps.stats[STAT_MAX_HEALTH]; }how was it suppose to be set up? and i do have probably an easier question, how do you start a duel with 100/100 health I've gotten as far as ent->client->ps.stats[STAT_HEALTH = 100]; ent->client->ps.stats[STAT_ARMOR] = 100; duelAgainst->client->ps.stats[STAT_HEALTH] = 100; duelAgainst->client->ps.stats[STAT_ARMOR] = 100; but for some reason the health doesnt go to 100 only the armor does >.<
eezstreet Posted January 3, 2013 Posted January 3, 2013 eh, that code looks a bit bizarreshould beent->client->ps.stats[sTAT_HEALTH] = 100;
Fighter Posted January 3, 2013 Posted January 3, 2013 ent->client->ps.stats[STAT_HEALTH = 100]; I think he's referring to how that line looks weird, which probably explains why you weren't getting health. As for Q2, I'll take a look at it again.
TheReferee Posted January 3, 2013 Author Posted January 3, 2013 yea i looked at that and still nothing unfortunatelyent->client->ps.stats[sTAT_HEALTH] = 100i had it right in my code dont know why it was typed that way
TheReferee Posted January 3, 2013 Author Posted January 3, 2013 if (ent->health > 0 && ent->client->ps.stats[STAT_HEALTH] > 0) { ent->client->ps.stats[STAT_HEALTH] = ent->health = ent->client->health; ent->client->ps.stats[STAT_ARMOR] = ent->client->armor; {I came up with this for the starting player health, but im not sure how to quit put it in with the rest of the code >.<
eezstreet Posted January 3, 2013 Posted January 3, 2013 well, you'll probably want the brackets to look correct after that, I think that the engage duel function:void Cmd_EngageDuel_f(gentity_t *ent)Is probably the best place to start
TheReferee Posted January 5, 2013 Author Posted January 5, 2013 Ok i finally figured everything out K so the codes i had were alllmost rightBoth went into g_active.c i was just missing the ent->health = 100 (reason was because all ent's have health so you have to set it that way)ent->client->ps.stats[sTAT_HEALTH] = ent->health = 100;ent->client->ps.stats[sTAT_ARMOR] = 100; duelAgainst->client->ps.stats[sTAT_HEALTH] = duelAgainst->health = 100; (same down here but change ent to duelAgainst because the challengie needs health too)duelAgainst->client->ps.stats[sTAT_ARMOR] = 100; Alsotrap_SendServerCommand( -1, va("cp \"%s %s %s with %i health and %i shields remaining!\n\"", ent->client->pers.netname, G_GetStripEdString("SVINGAME", "PLDUELWINNER"), duelAgainst->client->pers.netname, ent->client->ps.stats[STAT_HEALTH], ent->client->ps.stats[STAT_ARMOR]) );The code needed some changes "cp" changed to "print" because the messages was getting pushed off to the side and couldn't bee seen "%i" was also changed to "%d" because that is how health and armor is shown, this code also had to moved up before the player was given health for winning the duel or else the message would display the new health of the player rather then the end of duel health (100/100 instead of 20/0 or what ever) Thank you guys for your help lead me on the right path, thank you
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now