Command and Conquer: Renegade Official Forums - RDF feed
type: channel
description: C&C: Renegade --> Dying since 2003™, resurrected in 2024!
items: old tokenclass
items: Re: old tokenclass

old tokenclass
type: item
description: 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(),""); } } }
creator: robbyke
date: 2011-10-04T20:56:08-00:00

Re: old tokenclass
type: item
description: Couldn't find any references to "TokenClass" in 3.4.4's code, it must be an SSGM plugin or something similar.
creator: Jerad2142
date: 2011-10-04T21:04:05-00:00

Re: old tokenclass
type: item
description: yea it actually is off ssgm itself its where chatcommand stuff is located too
creator: robbyke
date: 2011-10-04T21:26:36-00:00

Re: old tokenclass
type: item
description: 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) { …
creator: Jerad2142
date: 2011-10-04T21:31:56-00:00

Re: old tokenclass
type: item
description: 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::
creator: robbyke
date: 2011-10-04T21:43:26-00:00

Re: old tokenclass
type: item
description: 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.
creator: Jerad2142
date: 2011-10-04T22:13:49-00:00

Re: old tokenclass
type: item
description: 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 /* Renegade Scripts.dll SSGM chat command classes and functions Copyright 2007 Whitedragon(MDB), Jonathan Wilson This file is part of the Renegade scripts.dll The Renegade scripts.dll is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. See the file COPYING for more details. In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. Only the source code to the module(s) containing the licenced code has to be released. */ #include "General.h" #ifndef COMMANDS_H #define COMMANDS_H #define CHATTYPE_PUBLIC 0 #define CHATTYPE_TEAM 1 #define CHATTYPE_ALL 2 #define GAMEMODE_ALL 0 #define GAMEMODE_AOW 1 #define GAMEMODE_CTF 2 #define GAMEMODE_SNIPING 3 #define GAMEMODE_500SNIPING 4 #define GAMEMODE_INFANTRY 5 class TokenClass { private: DynamicVectorClass<StringClass> Tokens; int vecsize; void Build(const StringClass &Text,int Pos) { Tokens.Clear(); vecsize = 0; char *Tokenz = new char[Text.Get_Length()+1]; sprintf(Tokenz,"%s",Text); char *p = strtok(Tokenz," "); StringClass Temp2,All; if (!Pos) { Tokens.Add(Text); } else { int i = 0; while (i < Pos) { p = strtok(0," "); ++i; } } while (p) { Temp2 = p; Tokens.Add(Temp2); p = strtok(0," "); ++vecsize; if (Pos) { All += Temp2; if (p) All += StringClass(" "); } } if (Pos) { Tokens.Insert(0,All); } delete[…
creator: robbyke
date: 2011-10-05T06:35:06-00:00

Re: old tokenclass
type: item
description: use the 4.0 chat hook.
creator: Gen_Blacky
date: 2011-10-05T17:14:02-00:00

Re: old tokenclass
type: item
description: 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 /* Renegade Scripts.dll KamBot Plugin Code Copyright 2009 Michael Kovacs This file is part of the Renegade scripts.dll The Renegade scripts.dll is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. See the file COPYING for more details. In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence. Only the source code to the module(s) containing the licenced code has to be released. */ #include "General.h" class KamBotChatCommand : public ChatCommandClass { void Triggered(int ID,const TokenClass &Text, int ChatType) { StringClass Msg; Msg.Format("CMSGP %d 0,255,0 %s v%s by %s",ID,PluginName,PluginVersion,PluginAuthor); Console_Input(Msg); Msg.Format("CMSGP %d 0,255,0 ================================================== ",ID); Console_Input(Msg); Msg.Format("CMSGP %d 0,255,0 !characters !defences, !powerups, !vpowerups, !weapons, !vtach, !detach, !metach",ID); Console_Input(Msg); } }; ChatCommandRegistrant<KamBotChatCommand> KamBotChatCommandReg("!kambot;!extra;!extras;!misc;!help",CHATTYPE_ALL,0,GAMEMODE_ALL); /*------------------O--------------------------------------------------------O | __ ___ .______ | CHARACTERS | | | |/ / | _ \ O--------------------------------------------------------O | | ' / | |_) | | - List of purchasable characters and their costs | | | < | _ < | | | | . \ | |_) | | | | |__|\__\ |______/ | | | | | \-------------------O-----------------------------------------…
creator: robbyke
date: 2011-10-05T17:22:05-00:00

Re: old tokenclass
type: item
description: 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
creator: snazy2000
date: 2011-10-06T06:35:58-00:00

Re: old tokenclass
type: item
description: 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
creator: robbyke
date: 2011-10-07T00:25:26-00:00