[Solved]Subtracting and adding strings?

Posts 1–2 of 2 · Page 1 of 1
[Solved]Subtracting and adding strings?
Okay, so I want to do something like this:

This is your current gun:
usp_mp

I want to subtract _mp from it:
usp

then add _xmags_mp to it:
usp_xmags_mp

But I want it to work with every gun, but I can't get the string functions to work(strtok, getsubstr, etc.) with the gun names.

Code:
	self.currentWeapon = self getCurrentWeapon();
		newaawep = strtok(self.currentWeapon, "_");
		newaawep += "xmags_mp"; // or _xmags_mp ??
I tested that, and it's not returning a proper, or valid string value ( it is not a console error, just isn't returning a string ).
So how can I do something like what I explained?
Thanks if you help me
Code:
//Method 1, works for simple guns with no attachments like "ump45_mp"
currentWeapon = self getCurrentWeapon();
newWeapon = strTok(currentWeapon, "_mp");
finalWeapon = newWeapon[0] + "_xmags_mp";

//Method 2, works for nearly all guns, removes previous attachments
currentWeapon = self getCurrentWeapon();
newWeapon = strTok(currentWeapon, "_");
finalWeapon = newWeapon[0] + "_xmags_mp";
/marked as solved
Posts 1–2 of 2 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

None

Need help?