Raised This Month: $51 Target: $400
 12% 

[SOLVED] Format a message?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-14-2016 , 12:36   [SOLVED] Format a message?
Reply With Quote #1

Can anyone explain to me how i can do the following?

I have about 20 cases with different type of victims, and i would like to save the desired text i want to display for each specific case then insert it into a hud message
PHP Code:

fw_PlayerKilled
(victimattacker)
{
        if(
leader_human(victim))
        {
                
save "Last Kill: get_pcvar_num(cvar_numer_points_last) Points" text in a variable/array
        else if(
last_human(victim))
        {
                
save "Last Kill: get_pcvar_num(cvar_numer_points_last Points" text in a variable/array
        }
        
set_hudmessage(bla bla)
        
show_hudmessage(attacker"%s"text from above cases)

__________________

Last edited by Depresie; 02-15-2016 at 10:06.
Depresie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-14-2016 , 13:45   Re: [HELP] Format a message?
Reply With Quote #2

I don't understand what you're trying to do, can you try to explain better? Maybe give some examples.
__________________
Bugsy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-14-2016 , 14:02   Re: [HELP] Format a message?
Reply With Quote #3

Ok, i will try to explain again

I want to send a hud message to the attacker when he killed a player, but i want the message to be different depending on the case, following the next example

PHP Code:

public fw_PlayerKilled(victimattacker)
{
         new 
g_mesage
         
if(is_user_last_human(victim))
         {
                   
g_message "You killed the Last Human, You were awarded get_pcvar_num(cvar_last_human_reward) points"
         
}
         else if(
is_user_first_kill(victim))
         { 
                 
g_message "You killed the bla bla, awarded bla bla cvar points"
         

          
set_hudmessage(255,0,0, ...............)
          
show_hudmessage(attacker"%s"g_message")

__________________

Last edited by Depresie; 02-14-2016 at 14:03.
Depresie is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 02-14-2016 , 14:10   Re: [HELP] Format a message?
Reply With Quote #4

format

Last edited by EpicMonkey; 02-14-2016 at 14:13. Reason: Fixed link
EpicMonkey is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-14-2016 , 14:38   Re: [HELP] Format a message?
Reply With Quote #5

You may need to do what you are already doing. The if checking will stop when it hits a true condition so if there's a chance of a player having more than 1 condition, put them in the order of priority.

PHP Code:
if ( is_thisid ) )
   
copyszMsg charsmaxszMsg ) , "You did this" );
else if ( 
is_this_insteadid ) )
   
copyszMsg charsmaxszMsg ) , "You did this instead" ); 
__________________
Bugsy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-14-2016 , 14:48   Re: [HELP] Format a message?
Reply With Quote #6

So i should make a global variable szMsg? and what about fomat? do i have to use it aswell?
Can you give me a more concrete example please?
__________________
Depresie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-14-2016 , 15:10   Re: [HELP] Format a message?
Reply With Quote #7

PHP Code:
enum KillStatus
{
    
LeaderHuman,
    
LastHuman,
    
ThisInstead2,
    
ThisInstead3
}

new const 
KillStatusMsgKillStatus ][] =  
{
    
"Leader human msg",
    
"Last human msg",
    
"This instead 2",
    
"This instead 3"
};

public 
Killedid )
{
    new 
KillStatus:ksStatus;
    
    if ( 
is_leader_humanid ) ) ksStatus LeaderHuman;
    else if ( 
is_last_humanid ) ) ksStatus LastHuman;
    else if ( 
is_this_instead2id ) ) ksStatus ThisInstead2;
    else if ( 
is_this_instead3id ) ) ksStatus ThisInstead3;

    
show_hudmessageid KillStatusMsgksStatus ] );

__________________
Bugsy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-14-2016 , 15:15   Re: [HELP] Format a message?
Reply With Quote #8

Nice, but could you explain to me one thing please ?

This line, how does it work? what ":" stands for in this case
PHP Code:
new KillStatus:ksStatus
And how can i add a cvar value into the text?
__________________

Last edited by Depresie; 02-14-2016 at 15:17.
Depresie is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-14-2016 , 15:24   Re: [HELP] Format a message?
Reply With Quote #9

Quote:
Originally Posted by Depresie View Post
Nice, but could you explain to me one thing please ?

This line, how does it work? what ":" stands for in this case
PHP Code:
new KillStatus:ksStatus
I created an enumerator (KillStatus) to define items (LeaderHuman,LastHuman,ThisInstead2,ThisInste ad3). Defining a variable with this tag will make it expect to hold only one of the items that I defined under that type/tag. Technically there is no change in the data, but the compiler will throw a warning if you try to place data other than the defined type in the variable.

So if you did:
ksStatus = ThisInstead3
you will have no issues/warnings
but if you did:
ksStatus = 3
you would get warning. Even though ThisInstead3 equals 3 as defined in the enumerator, it will give you a warning. If you ever have a need to do this and want to not get a warning, you can tag it like this:
ksStatus = KillStatus: 3

I think someone wrote a tut on enumerators/types in the tuts section.
__________________

Last edited by Bugsy; 02-14-2016 at 15:25.
Bugsy is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 02-14-2016 , 15:26   Re: [HELP] Format a message?
Reply With Quote #10

I understood now, thanks

But, how can i add a cvar value into the text? also the cvar value would be different for each case...
__________________
Depresie 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 13:11.


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