Raised This Month: $ Target: $400
 0% 

format/ex question/help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
da_ciouzan_oan
Junior Member
Join Date: Jun 2010
Old 11-10-2011 , 16:42   Re: format/ex question/help
Reply With Quote #9

Quote:
Originally Posted by ConnorMcLeod View Post
formatex(msg, charsmax(msg), "%s is now %s.")

->

formatex(msg, charsmax(msg), "%%s is now %%s.")

If it's not working, try :

msg = "%s is now %s."
It worked with '%%s'. Thanks.
But I still have a little problem at my script, not the test one.

I have this:

Code:
public client_command(id) {     new command[32], argument = 1, paramsplit[11][5][64], message[192], count = 0, Float:floatmsg[10], nummsg[10], strmsg[10][64], cont = 1     read_argv(0, command, charsmax(command))         if(get_cvar_num("amx_show_activity") == 0)     {         for(new i; i < _fileCount; i++)         {             if(equali(command, _fileData[i][1]))             {                 log_amx("[debug] Command '%s' detected", _fileData[i][1])                 if(get_user_flags(id) & read_flags(_fileData[i][2]))                 {                     log_amx("[debug] Access '%s' detected", _fileData[i][2])                     for(new a; a < 11; a++)                     {                         if(_fileData[i][a][1] == ':')                         {                             log_amx("[debug] Delimiter ':' detected")                             paramsplit[a][4][0] = -1                             split(_fileData[i][a], paramsplit[a][0], 63, paramsplit[a][1], 63, ":")                                                         log_amx("[debug] String splited into '%s' and '%s'", paramsplit[a][0], paramsplit[a][1])                             if(paramsplit[a][0][0] == 's') // string                                 paramsplit[a][4][0] = 1                             else if(paramsplit[a][0][0] == 'n') // integer (num)                                 paramsplit[a][4][0] = 2                             else if(paramsplit[a][0][0] == 'f') // float                                 paramsplit[a][4][0] = 3                                                             if(equali(paramsplit[a][1], "targetname"))                             {                                 read_argv(argument, paramsplit[a][1], charsmax(paramsplit[][]))                                 paramsplit[a][3][0] = cmd_target(id, paramsplit[a][1], CMDTARGET_OBEY_IMMUNITY | CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF)                                                                 if(!paramsplit[a][3][0])                                 {                                     log_amx("[debug] Invalid target.")                                     cont = 0                                     break;                                 }                                                                       if(!is_user_alive(paramsplit[a][3][0]))                                 {                                     log_amx("[debug] Target is dead.")                                     cont = 0                                     break;                                 }                                                                 get_user_name(paramsplit[a][3][0], paramsplit[a][0], charsmax(paramsplit[][]))                                 log_amx("[debug] A target name has been found")                                 log_amx("[debug] Name returned: '%s'", paramsplit[a][0])                                 argument++;                             }                             else if(equali(paramsplit[a][1], "adminname"))                             {                                 log_amx("[debug] An admin name has been found")                                 get_user_name(id, paramsplit[a][0], charsmax(paramsplit[][]))                                 log_amx("[debug] Name returned: '%s'", paramsplit[a][0])                             }                             else                             {                                 log_amx("[debug] Argument %s has been found !", paramsplit[a][1])                                 read_argv(argument, paramsplit[a][1], charsmax(paramsplit[][]))                                                                 if(strlen(paramsplit[a][1]) == 0)                                 {                                     log_amx("[debug] No argument inserted.")                                     cont = 0                                     break;                                 }                                                                   formatex(paramsplit[a][0], charsmax(paramsplit[][]), "%s", paramsplit[a][1])                                 log_amx("[debug] Message returned: '%s'", paramsplit[a][0])                                 argument++;                             }                                                             if(paramsplit[a][4][0] == 2)                                 nummsg[a] = str_to_num(paramsplit[a][1])                             else if(paramsplit[a][4][0] == 3)                                 floatmsg[a] = str_to_float(paramsplit[a][1])                             else                                 copy(strmsg[a], charsmax(strmsg[]), paramsplit[a][0])                             count++;                         }                     }                     if(cont == 1)                     {                         log_amx("[debug] Loop stopped at %d arguments!", count)                         switch(count)                         {                             case 1:                             {                                 formatex(message, charsmax(message), _fileData[i][10],                                     (paramsplit[3][4][0] == 3) ? floatmsg[3] : (paramsplit[3][4][0] == 2) ? nummsg[3] : strmsg[3])                                 log_amx("[debug] Message '%s' has been formatted!", message)                                 }                             case 2:                             {                                   formatex(message, charsmax(message), _fileData[i][10],                                     (paramsplit[3][4][0] == 3) ? floatmsg : (paramsplit[3][4][0] == 2) ? nummsg : paramsplit[3][0],                                     (paramsplit[4][4][0] == 3) ? floatmsg : (paramsplit[4][4][0] == 2) ? nummsg : paramsplit[4][0])                                 log_amx("[debug] Message '%s' has been formatted!", message)                                 }                             case 3:                             {                                 formatex(message, charsmax(message), _fileData[i][10],                                     (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0],                                     (paramsplit[4][4][0] == 3) ? floatmsg : paramsplit[4][0],                                     (paramsplit[5][4][0] == 3) ? floatmsg : paramsplit[5][0])                                 log_amx("[debug] Message '%s' has been formatted!", message)                             }                             case 4:                             {                                 formatex(message, charsmax(message), _fileData[i][10],                                     (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0],                                     (paramsplit[4][4][0] == 3) ? floatmsg : paramsplit[4][0],                                     (paramsplit[5][4][0] == 3) ? floatmsg : paramsplit[5][0],                                     (paramsplit[6][4][0] == 3) ? floatmsg : paramsplit[6][0])                                 log_amx("[debug] Message '%s' has been formatted!", message)                             }                             case 5:                             {                                   formatex(message, charsmax(message), _fileData[i][10],                                     (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0],                                     (paramsplit[4][4][0] == 3) ? floatmsg : paramsplit[4][0],                                     (paramsplit[5][4][0] == 3) ? floatmsg : paramsplit[5][0],                                     (paramsplit[6][4][0] == 3) ? floatmsg : paramsplit[6][0],                                     (paramsplit[7][4][0] == 3) ? floatmsg : paramsplit[7][0])                                 log_amx("[debug] Message '%s' has been formatted!", message)                             }                             case 6:                             {                                 formatex(message, charsmax(message), _fileData[i][10],                                     (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0],                                     (paramsplit[4][4][0] == 3) ? floatmsg : paramsplit[4][0],                                     (paramsplit[5][4][0] == 3) ? floatmsg : paramsplit[5][0],                                     (paramsplit[6][4][0] == 3) ? floatmsg : paramsplit[6][0],                                     (paramsplit[7][4][0] == 3) ? floatmsg : paramsplit[7][0],                                     (paramsplit[8][4][0] == 3) ? floatmsg : paramsplit[8][0])                                 log_amx("[debug] Message '%s' has been formatted!", message)                             }                             case 7:                             {                                 formatex(message, charsmax(message), _fileData[i][10],                                     (paramsplit[3][4][0] == 3) ? floatmsg : paramsplit[3][0],                                     (paramsplit[4][4][0] == 3) ? floatmsg : paramsplit[4][0],                                     (paramsplit[5][4][0] == 3) ? floatmsg : paramsplit[5][0],                                     (paramsplit[6][4][0] == 3) ? floatmsg : paramsplit[6][0],                                     (paramsplit[7][4][0] == 3) ? floatmsg : paramsplit[7][0],                                     (paramsplit[8][4][0] == 3) ? floatmsg : paramsplit[8][0],                                     (paramsplit[9][4][0] == 3) ? floatmsg : paramsplit[9][0])                                 log_amx("[debug] Message '%s' has been formatted!", message)                             }                         }                         client_print(0, print_chat, "%s", message, paramsplit[3][0], paramsplit[4][0])                         log_amx("[debug] Message '%s' has been printed into chat", message, paramsplit[3][0], paramsplit[4][0])                     }                     else                         log_amx("[debug] Something went wrong and the loop stopped at argument %d.", argument)                 }             }         }     } }


Error: Array must be indexed (variable "strmsg") on line 180
Line 180:
Code:
formatex(message, charsmax(message), _fileData[i][10], (paramsplit[3][4][0] == 3) ? floatmsg[3] : (paramsplit[3][4][0] == 2) ? nummsg[3] : strmsg[3])

The other cases are not modified.. tried a lot of things, that's why the other case looks diferent (3 to 7)

LE: I know.. there are a lot of useless variables, because I tried a lot of things ^.^. I'll clean up my code after I fix this error.

Last edited by da_ciouzan_oan; 11-10-2011 at 16:47.
da_ciouzan_oan is offline
 



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 14:22.


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