*edit
i am making a costume plugin. some costumes has name suffix of "w" for women and "m" for men. to make it simple im trying to make a code that detects what character is choosed (w/m) then random costume will bound to that chara based on gender. because the costumes are so many, i'm facing this problem. the costume is named "y19s4coswolfw" for women. it has "y19s4coswolfm" counterpart for men. if men is choosen, costume should be "y19s4coswolfm" whereas for women it should be "y19s4coswolfw". im thinking to simply just rename the suffix, which is "w" to "m" for men. the code below.
Code:
if(g_choosensex[id] == 1 /*men*/ && equal(szChoosenCos[strlen(szChoosenCos)-1], "w") /*if choosen cos is have "w" suffix*/)
{
// replace char
replace(szChoosenCos, charsmax(szChoosenCos), "w", "m")
new szCheck[64]
formatex(szCheck, charsmax(szCheck), "models/costume/%s.mdl", szChoosenCos)
// if doesn't exists then delete any suffix
if(!file_exists(szCheck))
{
if(equal(szChoosenCos[strlen(szChoosenCos)-2], "_m")) replace(szChoosenCos, charsmax(szChoosenCos), szChoosenCos[strlen(szChoosenCos)-2], "")
if(equal(szChoosenCos[strlen(szChoosenCos)-1], "m")) replace(szChoosenCos, charsmax(szChoosenCos), szChoosenCos[strlen(szChoosenCos)-1], "")
}
}
but the result of renaming is
which means the first 'w' from "y19s4coswolfw" is replaced instead the suffix 'w' i want.
Also i've tried :
Code:
replace(sz, charsmax(sz), sz[strlen(sz)-1], "m")
which is in my understanding will directed to the suffix but still gave same "y19s4cosmolfw" result.
How can i solve this?