UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Truncate a string

broken avatar :(
Created 12 years ago
by DidUknowiPwn
0 Members and 1 Guest are viewing this topic.
1,823 views
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 3 years ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
Signature
Do not take life too seriously. You will never get out of it alive.
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Alright so, let's say I have this string: zombie_colt_upgraded and I want to remove the _upgraded portion, you'd do.
Code Snippet
Plaintext
remove_upg_string(string)
{
return strTok(string,"_upgraded")[0];
}
And this will ONLY work on weapon strings that are zombie_NAME_upgraded and not other weapon names such as: m2_flamethrower_zombie_upgraded as it'll only return m2 as the string. So, I'm looking for another way to remove part of the string, anyone got any ideas/suggestions?
Marked as best answer by DidUknowiPwn 12 years ago
broken avatar :(
×
broken avatar :(
[UGX] Founder
Location: usBay Area, California
Date Registered: 24 June 2011
Last active: 3 years ago
Posts
5,544
Respect
6,646Add +1
Forum Rank
Immortal
Primary Group
UGX Administrator
My Groups
More
My Contact & Social Links
More
Signature
If Java had true garbage collection, most programs would delete themselves upon execution.
×
treminaor's Groups
UGX Administrator
UGX Team Member
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
I would suggest getSubStr() and isSubStr if you want to do a check for the text first (which I reccomend).

Code Snippet
Plaintext
if(isSubStr(weapon_name, "upgraded")) 
weapon_name = getSubStr(weapon_name, 0, weapon_name.size - 9);
broken avatar :(
×
broken avatar :(
[UGX] Documentation Writer & Programmer
Location: usLos Angeles, CA
Date Registered: 23 August 2013
Last active: 3 years ago
Posts
1,322
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Team Member
My Groups
More
My Contact & Social Links
More
Personal Quote
(ง º ω º )ง u wont sum m8y?
×
DidUknowiPwn's Groups
UGX Team Member
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
I would suggest getSubStr() and isSubStr if you want to do a check for the text first (which I reccomend).

Code Snippet
Plaintext
if(isSubStr(weapon_name, "upgraded")) 
weapon_name = getSubStr(weapon_name, 0, weapon_name.size - 9);

Much obligied, if anyone wants to see the example I did:

What was inputted:
Code Snippet
Plaintext
		IPrintLn(remove_upg_string("m2_flamethrower_zombie_upgraded"));
IPrintLn(remove_upg_string("zombie_colt_upgraded"));

 
Loading ...