Raised This Month: $ Target: $400
 0% 

Hook Saytext Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
devilicioux
Veteran Member
Join Date: Jun 2013
Location: Delhi,India
Old 09-16-2013 , 14:57   Hook Saytext Help
Reply With Quote #1

It might look like a strange scripting help request
but what i am trying to do is divide the saytext by player character by character
Like we just hook test and print like

PHP Code:
format (strText191"%s"message
what i want is to print like | after each character of the message ..lol dont even have a clue how to do that.

2 things now.

1) Suppose i say hello
it should print in chat like |h|e|l|l|o|

2) Suppose i say "hey how are you"
it prints in chat like |hey |how |are |you

Anyone got ideas ?
__________________
You keep bringing ANTICHRISTUS down .. He will rise again and kick asses !

#RespectList ANTICHRISTUS fysiks Bugsy

Most Common Errors You Can Encounter Every Now and Then
devilicioux is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-16-2013 , 15:42   Re: Hook Saytext Help
Reply With Quote #2

There's no practical use for the code that would be needed to do these things.
Therefor you should ask what you really need.
(Use formatex instead of format)

Code:
#include <amxmodx> public plugin_init() {     register_plugin("Test Plugin 6", "", "");         new string[10] = "hello";     new string2[20];         for ( new i = 0 ; string[i] && i * 2 + 1 < charsmax(string2) ; i++ ) {         string2[i * 2] = '|';         string2[i * 2 + 1] = string[i];     }     string2[strlen(string2)] = '|';         server_print("string: %s^nstring2: %s", string, string2); }

Code:
#include <amxmodx> public plugin_init() {     register_plugin("Test Plugin 6", "", "");         new string[10] = "hello";     new string2[20];         for ( new i = 0, o = 0 ; string[i] && o + 1 < charsmax(string2) ; i++, o += 2 ) {         string2[o] = '|';         string2[o + 1] = string[i];     }     string2[strlen(string2)] = '|';         server_print("string: %s^nstring2: %s", string, string2); }

Code:
string: hello
string2: |h|e|l|l|o|
Code:
#include <amxmodx> public plugin_init() {     register_plugin("Test Plugin 6", "", "");         new string[20] = "hey how are you";     new string2[40] = "|";         for ( new i = 0, o = 1 ; string[i] && o + 1 < charsmax(string2) ; i++, o++ ) {         string2[o] = string[i];         if ( string[i] == ' ' )             string2[++o] = '|';     }         server_print("string: %s^nstring2: %s", string, string2); }

Code:
string: hey how are you
string2: |hey |how |are |you
__________________

Last edited by Black Rose; 09-16-2013 at 15:44.
Black Rose is offline
Old 09-17-2013, 03:25
devilicioux
This message has been deleted by devilicioux. Reason: wrong code correct one below
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-17-2013 , 15:26   Re: Hook Saytext Help
Reply With Quote #3

"x03" is not a character constant. You are basically printing that as text.

How do you display the text?

Code:
            if(++o%2==0)             { string2[++o] = 4; }             else if(++o%3==0)             { string2[++o] = 3; }             else             { string2[++o] = 1; }
This will increment o for every check AND every string input. Even if the actual statement returns false it's already too late. You would therefor end up with the following:
"Test string"
->
"Test ^0^4string"
or
"Test ^0^0^3string"
or
"Test ^0^0^1string"

This will of course print "Test " since strings are null terminated meaning the function printing the message will stop reading the input once it hits ^0 (a.k.a. 0, null or EOS).

Only increment once.
Code:
            if(++o%2==0)             { string2[o] = 4; }             else if(o%3==0)             { string2[o] = 3; }             else             { string2[o] = 1; }

If you ever are in doubt when using strings, print them like an array to debug.
Code:
    new c, string[] = "whatever";     for ( new i = 0 ; i < sizeof string ; i++) {         c = string[i];         server_print("%d: %c(%d)", i, c == 0 || c == 10 || c == 13 ? ' ' : c, c);     }
This will tell you exactly where it went wrong so you know what to look for in the code.
__________________

Last edited by Black Rose; 09-17-2013 at 17:31.
Black Rose is offline
devilicioux
Veteran Member
Join Date: Jun 2013
Location: Delhi,India
Old 09-17-2013 , 17:21   Re: Hook Saytext Help
Reply With Quote #4

Thanks man learning so much from your posts and explanations !! Finally .. Credits to you Plugin Working fine now.
HaiL Black Rose
__________________
You keep bringing ANTICHRISTUS down .. He will rise again and kick asses !

#RespectList ANTICHRISTUS fysiks Bugsy

Most Common Errors You Can Encounter Every Now and Then
devilicioux 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 19:02.


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