Raised This Month: $ Target: $400
 0% 

Solved Replace in a String that Contains Repeated Chars


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
damage220
Member
Join Date: Jul 2022
Location: Ukraine
Old 07-20-2022 , 09:45   Re: Replace in a String that Contains Repeated Chars
Reply With Quote #6

Quote:
Originally Posted by asdian View Post
edited the post. sorry for inconvenience..
It is much clearer now. So, you need only to change the last character. +ARUKARI- has already posted an answer, you need to edit the last cell in an array.
PHP Code:
szChoosenCos[strlen(szChoosenCos) - 1] = 'w'
String is an array of characters terminated with null byte. You can replace
PHP Code:
equal(szChoosenCos[strlen(szChoosenCos)-1], "w"
with
PHP Code:
if(szChoosenCos[strlen(szChoosenCos)-1] == 'w'// note single quote 
Then, if you want to delete the suffix, you should terminate the string with null byte.
PHP Code:
szChoosenCos[strlen(szChoosenCos) - 1] = '^0'
You can also apply suffix with formatex which may be better depending on your needs.
PHP Code:
formatex(szCheckcharsmax(szCheck), "models/costume/%s_w.mdl"szChoosenCos
Or even create a matrix with all the models to speed things up.
PHP Code:
new const models[][][] = {
    {
"models/costume/model1_m.mdl""models/costume/model1_w.mdl"},
    {
"models/costume/model2_m.mdl""models/costume/model2_w.mdl"},
    {
"models/costume/model3_m.mdl""models/costume/model3_w.mdl"},
};

// get first man model
models[0][0

Last edited by damage220; 07-20-2022 at 09:59.
damage220 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 00:19.


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