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

Solved read char by char from arguments (and other questions)


Post New Thread Reply   
 
Thread Tools Display Modes
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-25-2019 , 22:21   Re: read char by char from arguments (and other questions)
Reply With Quote #11

Quote:
Originally Posted by nacknic View Post
@HamletEagle
of course i checked before i ask, not work ;(
picture: https://imgur.com/a/YIBk7jO
You have to save the .sma file as "UTF-8 without BOM" to get UTF-8 characters to work in plugins.

Quote:
Originally Posted by nacknic View Post
thanks to your help, i success what i want to do:
in your script you do loop and print string/sub-strings like chars by usin %c in print coomand.
i added format() because i want really change to chars to read and exam char by char:
Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "nacknic"


public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say", "xmath")
}

public xmath(id)
{
    new args[64], c[64];
    read_args(args, charsmax(args));
    remove_quotes(args);
    new iLen = strlen(args);

    for(new i; i < iLen; i++) {
    	format(c[i], charsmax(c), "%c", args[i]);
    }
    
    if(c[0] == '!' && c[1] == 'c') client_print(id, print_chat, "work");
    else client_print(id, print_chat, "didn't works");
}
is there efficient way , read char and not format to char like i do ?
What are you trying to do? I don't know why you are using a loop with format() to simply copy a string or, more importantly, why are you copying the string at all anyways? Just use args directly. If you need to copy a string into a new variable use copy(c, charsmax(c), args).

Also note that the second argument in format() is not correct in your for loop. To do it properly, you'd need to use charsmax(c) - i. This is probably not the most comprehendable for someone new to programming so I'd recommend using copy() as I stated above, removing the 'c' variable, or explain what you are actually trying to do.
__________________

Last edited by fysiks; 03-25-2019 at 22:25.
fysiks 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:25.


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