Raised This Month: $32 Target: $400
 8% 

Objectives


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   General Purpose       
uTg | bigpapajiggs
Senior Member
Join Date: Sep 2005
Location: Bellingham, WA
Old 11-13-2005 , 17:06   Objectives
Reply With Quote #1

This displays the objectives for whatever type of map you are playing. It shows them at the begginning of each round.

Tested and works.

Map Types Supported (will add more when I try more types):

CS
DE
FY
AWP
KA
AS
DM
HE
SCOUT
KZ
AIM


Thanks to v3x for help with various things.
Thanks to Brad for lots of help.
Attached Files
File Type: sma Get Plugin or Get Source (objectives.sma - 1493 views - 2.1 KB)
__________________
What's my confidence level? I do crossword puzzles with a pen.
uTg | bigpapajiggs is offline
Send a message via AIM to uTg | bigpapajiggs Send a message via MSN to uTg | bigpapajiggs Send a message via Yahoo to uTg | bigpapajiggs
Striker
Senior Member
Join Date: Mar 2004
Location: Germany
Old 11-13-2005 , 17:19  
Reply With Quote #2

nice and useful plugin ;)

here are all map-types.. : http://www.fpsbanana.com/?section=vi...aptypes.main.1
__________________
Striker is offline
Send a message via ICQ to Striker Send a message via MSN to Striker
eFrigid
Senior Member
Join Date: Aug 2005
Location: 3o3
Old 11-13-2005 , 18:45  
Reply With Quote #3

Nice
__________________
lol
eFrigid is offline
Send a message via AIM to eFrigid Send a message via MSN to eFrigid Send a message via Skype™ to eFrigid
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-14-2005 , 15:30  
Reply With Quote #4

Good concept. Issues with the coding.

The for loop is wrong in this code:
Code:
public NewRound() {     new players[32], num, i     get_players(players, num, "ac")     for(i = 0; i <= num; i++)     {         showobjectives(players[i])     } }
Change the 'for' line to this:
Code:
for(i = 0; i < num; i++)
There's no need to use cs_get_user_team and I'm pretty sure that as a rule, you shouldn't. Instead just use get_user_team. As a bonus, you no longer have to include cstrike.

Finally, use if else instead of a bunch of if statements. You'll be able to reduce the duplication of return PLUGIN_HANDLED all over the place. For that matter, get rid of return PLUGIN_HANDLED altogether as you're not using the return value for anything and show_objectives isn't a forward.

Edit: You might also want to handle the case where maps include more than one objective.

Edit2: Make it multilingual while you're at it. There's a huge segment of AMXX servers out there whose primary language isn't English.
Brad is offline
uTg | bigpapajiggs
Senior Member
Join Date: Sep 2005
Location: Bellingham, WA
Old 12-15-2005 , 11:00  
Reply With Quote #5

Thank you for the tips Brad. A few questions though.


Quote:
Originally Posted by Brad
There's no need to use cs_get_user_team and I'm pretty sure that as a rule, you shouldn't. Instead just use get_user_team.
For this part, what would I use in the if? Would it just be TEAM_T or would it continue to be CS_TEAM_T?

Quote:
Originally Posted by Brad
Finally, use if else instead of a bunch of if statements. You'll be able to reduce the duplication of return PLUGIN_HANDLED all over the place. For that matter, get rid of return PLUGIN_HANDLED altogether as you're not using the return value for anything and show_objectives isn't a forward.
I don't know if it's sad that I don't really know how to do that. Please explain a little more.


EDIT: PS - I haven't looked at these forums for a while (computer issues), and just noticed you are a moderator. Good job, I think it's well deserved.
__________________
What's my confidence level? I do crossword puzzles with a pen.
uTg | bigpapajiggs is offline
Send a message via AIM to uTg | bigpapajiggs Send a message via MSN to uTg | bigpapajiggs Send a message via Yahoo to uTg | bigpapajiggs
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-15-2005 , 12:17  
Reply With Quote #6

Quote:
Originally Posted by Brad
There's no need to use cs_get_user_team and I'm pretty sure that as a rule, you shouldn't. Instead just use get_user_team.
Quote:
Originally Posted by Lord Saddler
For this part, what would I use in the if? Would it just be TEAM_T or would it continue to be CS_TEAM_T?
You should define TEAM_T as 1 and TEAM_CT as 2 at the start of your script. Then you can use TEAM_T and TEAM_CT as needed throughout your script.

Quote:
Originally Posted by Brad
Finally, use if else instead of a bunch of if statements. You'll be able to reduce the duplication of return PLUGIN_HANDLED all over the place. For that matter, get rid of return PLUGIN_HANDLED altogether as you're not using the return value for anything and show_objectives isn't a forward.
Quote:
Originally Posted by Lord Saddler
I don't know if it's sad that I don't really know how to do that. Please explain a little more.
You are using consecutive if statements.

if ...
if ...
if ...

And you are returning PLUGIN_HANDLED from each, essentially stopping any further code from running. If instead you used if else you wouldn't need to explicitly stop further code from running with your returns.

if ...
else if ...
else if ...

Compare your original code (shown first) to my code (shown second). Let me know if you have any questions. I've left a couple of my suggestions out as an exercise for you.

Your initial code:
Code:
//Thanks to v3x for help with various things #include <amxmodx> #include <amxmisc> #include <cstrike> public plugin_init() {     register_plugin("Objectives","1.0","Lord Saddler")     register_logevent("NewRound", 2, "0=World triggered", "1=Round_Start") } public NewRound() {     new players[32], num, i     get_players(players, num, "ac")     for(i = 0; i <= num; i++)     {         showobjectives(players[i])     } } public showobjectives(id) {     new map[32]     get_mapname(map,31)         if(containi(map,"cs_")!=-1)     {         new CsTeams:team = cs_get_user_team(id)                 switch(team)         {             case CS_TEAM_CT:             {                 client_print(id,print_center,"Your objective: Infiltrate the Terrorist hideout, save the hostages!")             }             case CS_TEAM_T:             {                 client_print(id,print_center,"Your objective: Protect your hostages from the Counter-Terrorists!")             }         }            return PLUGIN_HANDLED     }         if(containi(map,"de_")!=-1)     {         new CsTeams:team = cs_get_user_team(id)                 switch(team)         {             case CS_TEAM_CT:             {                 client_print(id,print_center,"Your objective: Stop the Terrorists from planting their C4!")             }             case CS_TEAM_T:             {                 client_print(id,print_center,"Your objective: Plant the C4 and guard it!")             }         }         return PLUGIN_HANDLED     }         if(containi(map,"fy_")!=-1)     {         client_print(id,print_center,"Your objective: Kill the opposing team at any cost!")                 return PLUGIN_HANDLED     }         if(containi(map,"aim_")!=-1)     {         client_print(id,print_center,"Your objective: Test your aim!")                 return PLUGIN_HANDLED     }         if(containi(map,"awp_")!=-1)     {         client_print(id,print_center,"Your objective: Snipe your way to victory with the AWP!")                 return PLUGIN_HANDLED     }         if(containi(map,"ka_")!=-1)     {         client_print(id,print_center,"Your objective: Stab, slash and cut your way to victory!")                 return PLUGIN_HANDLED     }         if(containi(map,"as_")!=-1)     {         new CsTeams:team = cs_get_user_team(id)                 switch(team)         {             case CS_TEAM_CT:             {                 client_print(id,print_center,"Your objective: Protect the VIP!")             }         case CS_TEAM_T:             {                 client_print(id,print_center,"Your objective: Kill the VIP!")             }         }         return PLUGIN_HANDLED     }         if(containi(map,"dm_")!=-1)     {         client_print(id,print_center,"Your objective: No real objective here, just kill EVERYONE!")                 return PLUGIN_HANDLED     }         if(containi(map,"he_")!=-1)     {         client_print(id,print_center,"Your objective: Blow shit up!")                 return PLUGIN_HANDLED     }         if(containi(map,"scout")!=-1)     {         client_print(id,print_center,"Your objective: Scout your way to victory!")                 return PLUGIN_HANDLED     }         if(containi(map,"kz_")!=-1)     {         client_print(id,print_center,"Your objective: CLIMB!")                 return PLUGIN_HANDLED     }         return PLUGIN_HANDLED }
My first stab at it:
Code:
//Thanks to v3x for help with various things #include <amxmodx> #include <amxmisc> #define TEAM_T  1 #define TEAM_CT 2 public plugin_init() {     register_plugin("Objectives","1.0","Lord Saddler")     register_logevent("NewRound", 2, "0=World triggered", "1=Round_Start") } public NewRound() {     new players[32], num, i     get_players(players, num, "ac")     for(i = 0; i < num; i++)     {         showobjectives(players[i])     } } public showobjectives(id) {     new teamID = get_user_team(id)     new objective[64] = "Unknown."     new map[32]     get_mapname(map, 31)     if (containi(map, "cs_") != -1)     {         switch(teamID)         {             case TEAM_CT: copy(objective, 63, "Infiltrate the Terrorist hideout, save the hostages!")             case TEAM_T:  copy(objective, 63, "Protect your hostages from the Counter-Terrorists!")         }        }     else if (containi(map,"de_") != -1)     {         switch(teamID)         {             case CS_TEAM_CT: copy(objective, 63, "Stop the Terrorists from planting their C4!")             case CS_TEAM_T:  copy(objective, 63, "Plant the C4 and guard it!")         }     }     else if (containi(map,"fy_") != -1)  copy(objective, 63, "Kill the opposing team at any cost!")     else if (containi(map,"aim_") != -1) copy(objective, 63, "Test your aim!")     else if (containi(map,"awp_") != -1) copy(objective, 63, "Snipe your way to victory with the AWP!")     else if (containi(map,"ka_") != -1)  copy(objective, 63, "Stab, slash and cut your way to victory!")     else if (containi(map,"as_") != -1)     {         switch(teamID)         {             case CS_TEAM_CT: copy(objective, 63, "Protect the VIP!")             case CS_TEAM_T:  copy(objective, 63, "Kill the VIP!")         }     }     else if (containi(map,"dm_") != -1)   copy(objective, 63, "No real objective here, just kill EVERYONE!")     else if (containi(map,"he_") != -1)   copy(objective, 63, "Blow shit up!")     else if (containi(map,"scout") != -1) copy(objective, 63, "Scout your way to victory!")     else if (containi(map,"kz_") != -1)   copy(objective, 63, "CLIMB!")     client_print(id, print_center, "Your Objective: %s", objective) }
Note how I avoided the consecutive if statements.

What I left out of my code was:
  • multilingual support
  • ability to handle maps with multiple objectives
  • perhaps an aesthetic reordering of the conditionals
Quote:
Originally Posted by Lord Saddler
EDIT: PS - I haven't looked at these forums for a while (computer issues), and just noticed you are a moderator. Good job, I think it's well deserved.
Thank you.
Brad is offline
uTg | bigpapajiggs
Senior Member
Join Date: Sep 2005
Location: Bellingham, WA
Old 12-16-2005 , 00:15  
Reply With Quote #7

Ok Brad, I added the one you made. I will work on this soon, but as of now I am tired and must sleep. Thank you for the help, and thanks for the approval Geesu
__________________
What's my confidence level? I do crossword puzzles with a pen.
uTg | bigpapajiggs is offline
Send a message via AIM to uTg | bigpapajiggs Send a message via MSN to uTg | bigpapajiggs Send a message via Yahoo to uTg | bigpapajiggs
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 04-11-2007 , 23:55   Re: Objectives
Reply With Quote #8

There are 4 errors which are very minor but cannot be overlooked.

Line around 47
Code:
case CS_TEAM_CT: copy(objective, 63, "Stop the Terrorists from planting their C4!") 
			case CS_TEAM_T:  copy(objective, 63, "Plant the C4 and guard it!")
Line around 55
Code:
case CS_TEAM_CT: copy(objective, 63, "Protect the VIP!") 
			case CS_TEAM_T:  copy(objective, 63, "Kill the VIP!")
Cannot be CS_TEAM_CT or CS_TEAM_T because those don't exist.

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-12-2009 , 14:25   Re: Objectives
Reply With Quote #9

This plugin dosen't compile, author inactive, unapprove ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 08-12-2009 , 15:23   Re: Objectives
Reply With Quote #10

Quote:
Originally Posted by ConnorMcLeod View Post
This plugin dosen't compile, author inactive, unapprove ?
Agreed. Unapproved.
Brad 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 15:36.


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