Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » old tokenclass
old tokenclass [message #456811] Tue, 04 October 2011 13:56 Go to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
I got sick of searching so ill just ask what happened to tokenclass and if it hasnt been replaced with something else, any ideas how to solve this
its about adding multiple scripts with or without parameters to an object.

				if (stricmp(Scripts,"")!=0 && stricmp(ScriptParams,"")!=0)
				{
					TokenClass ScriptsParse= TokenClass(Scripts,0);
					TokenClass ScriptParamsParse= TokenClass(ScriptParams,0);
					for(int i=0;i<ScriptsParse.size()+1;i++)
					{
						if (stricmp(ScriptParamsParse[i].c_str(),"!")!=0)
						{
							Attach_Script_Once(obj,ScriptsParse[i].c_str(),ScriptParamsParse[i].c_str());
						}
						else
						{
							Attach_Script_Once(obj,ScriptsParse[i].c_str(),"");
						}
					}
				}


Owner of kambot TT server

kambot.freeforums.org
Re: old tokenclass [message #456812 is a reply to message #456811] Tue, 04 October 2011 14:04 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Couldn't find any references to "TokenClass" in 3.4.4's code, it must be an SSGM plugin or something similar.

Re: old tokenclass [message #456814 is a reply to message #456811] Tue, 04 October 2011 14:26 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
yea it actually is off ssgm itself its where chatcommand stuff is located too

Owner of kambot TT server

kambot.freeforums.org
Re: old tokenclass [message #456815 is a reply to message #456814] Tue, 04 October 2011 14:31 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Copied directly from ssgm, if you wanted to use it without ssgm you should rename its calls so you don't end up stepping on someone elses' toes.
class TokenClass {
private:
	std::vector<std::string> Tokens;
	int vecsize;
	void Build(const std::string &Text,int Pos) {
		Tokens.clear();
		vecsize = 0;
		char *Tokenz = new char[Text.size()+1];
		sprintf(Tokenz,"%s",Text.c_str());
		char *p = strtok(Tokenz," ");
		std::string Temp2,All;
		if (!Pos) {
			Tokens.push_back(Text);
		}
		else {
			int i = 0;
			while (i < Pos) {
				p = strtok(0," ");
				++i;
			}
		}
		while (p) {
			Temp2 = p;
			Tokens.push_back(Temp2);
			p = strtok(0," ");
			++vecsize;
			if (Pos) {
				All += Temp2;
				if (p) All += std::string(" ");
			}
		}
		if (Pos) {
			Tokens.insert(Tokens.begin(),All);
		}
		delete[] Tokenz;
	}

	public:

	TokenClass(const TokenClass &Copy) {
		Tokens = Copy.Tokens;
		vecsize = Copy.vecsize;
	}
	TokenClass() { }
	TokenClass(const std::string &Text,int Pos = 0) {
		Build(Text,Pos);
	}

	TokenClass& operator=(const TokenClass &Copy) {
		Tokens = Copy.Tokens;
		vecsize = Copy.vecsize;
		return *this;
	}

	TokenClass& operator=(const std::string &Text) {
		Build(Text,0);
		return *this;
	}

	inline std::string operator[](int Pos) const {
		if (vecsize < Pos) {
			return "";
		}
		return Tokens[Pos];
	}

	std::string operator()(int Start,int End = 0) const {
		if (vecsize < Start || vecsize < End) {
			return "";
		}
		std::string Ret;
		if (!End) {
			End = Tokens.size();
		}
		int i = Start;
		while (i <= End && i <= vecsize) {
			Ret += Tokens[i];
			++i;
			if (i <= End) Ret += std::string(" ");
		}
		return Ret;
	}

	inline int size() const {
		return vecsize;
	}

	inline void erase(int Pos) {
		if (vecsize < Pos) return;
		Tokens.erase(Tokens.begin()+Pos);
		vecsize--;
	}

	inline void replace(int Pos,const std::string &Rep) {
		if (vecsize < Pos || !Pos) return;
		Tokens[Pos] = Rep;;
	}

	inline void eraseglobal(int Pos) {
		if (vecsize < Pos) return;
		std::string Temp = Tokens[0];
		Temp.replace(Temp.find(Tokens[Pos]),Tokens[Pos].size()+1,"");
		Tokens[0] = Temp;
		erase(Pos);
	}

	inline void Add(const std::string &Text,int Pos = 0) {
		if (!Pos) {
			Tokens.push_back(Text);
			++vecsize;
		}
		else if (vecsize < Pos) {
			return;
		}
		else {
			Tokens.insert(Tokens.begin()+Pos,Text);
			++vecsize;
		}
	}
};


Re: old tokenclass [message #456818 is a reply to message #456811] Tue, 04 October 2011 14:43 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
i could only wish it was that easy it gives tons of compiler errors with std class shit and all wich gives me even more problems i rather follow the guidelines and dont use std::

Owner of kambot TT server

kambot.freeforums.org
Re: old tokenclass [message #456822 is a reply to message #456818] Tue, 04 October 2011 15:13 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Are you running 4.0?

If not just add
using namespace std;

to the top of the file, you don't have to use the std stuff but the token class did and probably always did, and thus needs to.


[Updated on: Tue, 04 October 2011 15:20]

Report message to a moderator

Re: old tokenclass [message #456840 is a reply to message #456811] Tue, 04 October 2011 23:35 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
im running 4.0 im trying to convert my mod to 4.0 but lots of functions are different or dissappeared

ive been trying to convert the old command class but ive noticed that the new vector class doesnt has a function to determine its bgin. now im not dumb (i hope) and begin = 0. so i just use 0 but on the internet i found that if my vector is empty ill get an exeption bcause vector[0] is invalid

this is what ive become after converting

Chatcommandclass.h
Toggle Spoiler

Chatcommandclass.cpp
Toggle Spoiler


ive just copied those out of the old ssgm and edited them


Owner of kambot TT server

kambot.freeforums.org

[Updated on: Wed, 05 October 2011 01:40]

Report message to a moderator

Re: old tokenclass [message #456882 is a reply to message #456811] Wed, 05 October 2011 10:14 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
use the 4.0 chat hook.

http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: old tokenclass [message #456886 is a reply to message #456882] Wed, 05 October 2011 10:22 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
im gonna use this its used in more then 50 commands aint gonna reamke em all i aint sick ^^

Gen_Blacky wrote on Wed, 05 October 2011 19:14

use the 4.0 chat hook.


this is every command i have and as far as i see chathook just hooks into chat everytime something is written i have to find out myself what is written etc.
Toggle Spoiler

to bad for me nothin works i guess i can start remaking everythin maybe ill get done one day...


Owner of kambot TT server

kambot.freeforums.org

[Updated on: Wed, 05 October 2011 15:10]

Report message to a moderator

Re: old tokenclass [message #456944 is a reply to message #456886] Wed, 05 October 2011 23:35 Go to previous messageGo to next message
snazy2000 is currently offline  snazy2000
Messages: 67
Registered: December 2007
Karma: 0
Recruit
It wouldnt take you that long to convert them to 4.0 ive got fk loads more than that do do and i did them in about 2 hours ish Smile
Re: old tokenclass [message #457021 is a reply to message #456811] Thu, 06 October 2011 17:25 Go to previous message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
yea i did it during electronics class was bring ass hell and converting was easy as soon as i found out how it took me longer then 2 hours tho

Owner of kambot TT server

kambot.freeforums.org
Previous Topic: JFW Script list?
Next Topic: Find_My_Vehicle
Goto Forum:
  


Current Time: Tue May 28 21:23:42 MST 2024

Total time taken to generate the page: 0.01398 seconds