Raised This Month: $ Target: $400
 0% 

[CSS] Passing dynamic value to Format


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dnextreme88
Junior Member
Join Date: Jan 2021
Old 12-22-2022 , 22:53   [CSS] Passing dynamic value to Format
Reply With Quote #1

How do I pass a dynamic value in the Format() function? I have this code snippet

HTML Code:
if (randomChatToUse == 1) {
    Format(buffer, sizeof(buffer), "say %t", "Killed1", victimName);
    FakeClientCommand(attackerClient, buffer);
} else if (randomChatToUse == 2) {
    Format(buffer, sizeof(buffer), "say %t", "Killed2", victimName);
    FakeClientCommand(attackerClient, buffer);
} else if (randomChatToUse == 3) {
    Format(buffer, sizeof(buffer), "say %t", "Killed3", victimName);
    FakeClientCommand(attackerClient, buffer);
}
I'd like to only use something like
HTML Code:
Format(buffer, sizeof(buffer), "say %t", "Killed%i", randomChatToUse, victvictimName);
FakeClientCommand(attackerClient, buffer);
But this doesn't seem to work. Or is it even possible?
dnextreme88 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-23-2022 , 11:09   Re: [CSS] Passing dynamic value to Format
Reply With Quote #2

lower case %t works on PrintToChat etc. etc. what acts directly to one or more clients.

When format string, use %T, "phrase", client index.

PHP Code:
    Format(buffersizeof(buffer), "Killed%i"randomChatToUse);
    
Format(buffersizeof(buffer), "say %T"bufferattackerClientvictimName);
    
FakeClientCommand(attackerClientbuffer); 
__________________
Do not Private Message @me
Bacardi is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 12-23-2022 , 12:08   Re: [CSS] Passing dynamic value to Format
Reply With Quote #3

Bacardi, why not this way?
PHP Code:
    FormatEx(buffersizeof(buffer), "Killed%i"randomChatToUse);
    
FakeClientCommand(attackerClient"say %t"buffervictimName); 
__________________

Last edited by Grey83; 12-23-2022 at 12:08.
Grey83 is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-23-2022 , 13:42   Re: [CSS] Passing dynamic value to Format
Reply With Quote #4

works as well
__________________
Do not Private Message @me
Bacardi is offline
dnextreme88
Junior Member
Join Date: Jan 2021
Old 12-28-2022 , 00:50   Re: [CSS] Passing dynamic value to Format
Reply With Quote #5

Thanks guys, it worked!
dnextreme88 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 08:12.


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