Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Another SSGM Question
Another SSGM Question [message #271871] Mon, 09 July 2007 00:56 Go to previous message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma:
General (4 Stars)
i hope this makes since i had the problem of mutiple people using commands Gamemodding aka RoShamBo help me out with this code

bool Is_Mod(const char *Name)
{
     fstream file("mods.txt", ios::in);
     string tmp;
     while(file >> tmp)
     { 
         if(strcmp(Name, tmp.c_str()) == 0)
          {
               return 1;
         }
     }
     return 0;
}

class exampleChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
         if(Is_Mod(Get_Player_Name_By_ID(ID))
         {
             Commands->(do something)
         }
         else
         {
                 //this player isn't a mod
         }

};




now my problem is i have about 25 new commands and my question is
out of those 25 commands most of them will have to use a diffrenet txt file then he said above
now heres the question

do i have to have that same code like above for every single code i make?
or do i type that code one time then put my command sunder it?

likere heres example this is what i have now


bool Is_Mod(const char *Name)
{
     fstream file("mods.txt", ios::in);
     string tmp;
     while(file >> tmp)
     { 
         if(strcmp(Name, tmp.c_str()) == 0)
          {
               return 1;
         }
     }
     return 0;
}
class GDISoldierChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
         if(Is_Mod(Get_Player_Name_By_ID(ID))
         {
        GameObject *obj = Get_GameObj_By_Player_Name(Text[0].c_str());
		Commands->Set_Model(obj,"c_ag_gdi_mg");
         }
         else
         {
                 //You Do Not Have Permission To Do This Command
         }

};
ChatCommandRegistrant<GDISoldierChatCommand> GDIEngieCommandReg("!GDISoldier",CHATTYPE_ALL,0,GAMEMODE_ALL);

//******************************************************************************

class GDIShotGunnerChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
         if(Is_Mod(Get_Player_Name_By_ID(ID))
         {
        GameObject *obj = Get_GameObj_By_Player_Name(Text[0].c_str());
		Commands->Set_Model(obj,"c_ag_gdi_rk");
         }
         else
         {
                 //You Do Not Have Permission To Do This Command
         }

};
ChatCommandRegistrant<GDIShotGunnerChatCommand> GDIShotGunnerCommandReg("!GDIShotGunner",CHATTYPE_ALL,0,GAMEMODE_ALL);

//******************************************************************************

class GDIGernaderCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
         if(Is_Mod(Get_Player_Name_By_ID(ID))
         {
        GameObject *obj = Get_GameObj_By_Player_Name(Text[0].c_str());
		Commands->Set_Model(obj,"c_ag_gdi_rk");
         }
         else
         {
                 //You Do Not Have Permission To Do This Command
         }

};
ChatCommandRegistrant<GDIGernaderChatCommand> GDIGernaderCommandReg("!GDIGernader",CHATTYPE_ALL,0,GAMEMODE_ALL);

//******************************************************************************

class GDIEngieChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
         if(Is_Mod(Get_Player_Name_By_ID(ID))
         {
        GameObject *obj = Get_GameObj_By_Player_Name(Text[0].c_str());
		Commands->Set_Model(obj,"c_ag_gdi_en");
         }
         else
         {
                 //You Do Not Have Permission To Do This Command
         }

};
ChatCommandRegistrant<GDIEngieChatCommand> GDIEngieCommandReg("!GDIEngie",CHATTYPE_ALL,0,GAMEMODE_ALL);

//******************************************************************************

class GDIChainGunnerChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
         if(Is_Mod(Get_Player_Name_By_ID(ID))
         {
        GameObject *obj = Get_GameObj_By_Player_Name(Text[0].c_str());
		Commands->Set_Model(obj,"c_ag_gdi_mgo");
         }
         else
         {
                 //You Do Not Have Permission To Do This Command
         }

};
ChatCommandRegistrant<GDIChainGunnerChatCommand> GDIChainGunnerCommandReg("!GDIChainGunner",CHATTYPE_ALL,0,GAMEMODE_ALL);



or do i have to put it like this with the code above each command


bool Is_Mod(const char *Name)
{
     fstream file("mods.txt", ios::in);
     string tmp;
     while(file >> tmp)
     { 
         if(strcmp(Name, tmp.c_str()) == 0)
          {
               return 1;
         }
     }
     return 0;
}


class GDISoldierChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
         if(Is_Mod(Get_Player_Name_By_ID(ID))
         {
        GameObject *obj = Get_GameObj_By_Player_Name(Text[0].c_str());
		Commands->Set_Model(obj,"c_ag_gdi_mg");
         }
         else
         {
                 //You Do Not Have Permission To Do This Command
         }

};
ChatCommandRegistrant<GDISoldierChatCommand> GDIEngieCommandReg("!GDISoldier",CHATTYPE_ALL,0,GAMEMODE_ALL);

//******************************************************************************

bool Is_Mod(const char *Name)
{
     fstream file("mods.txt", ios::in);
     string tmp;
     while(file >> tmp)
     { 
         if(strcmp(Name, tmp.c_str()) == 0)
          {
               return 1;
         }
     }
     return 0;
}


class GDIShotGunnerChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
         if(Is_Mod(Get_Player_Name_By_ID(ID))
         {
        GameObject *obj = Get_GameObj_By_Player_Name(Text[0].c_str());
		Commands->Set_Model(obj,"c_ag_gdi_rk");
         }
         else
         {
                 //You Do Not Have Permission To Do This Command
         }

};
ChatCommandRegistrant<GDIShotGunnerChatCommand> GDIShotGunnerCommandReg("!GDIShotGunner",CHATTYPE_ALL,0,GAMEMODE_ALL);

//******************************************************************************

bool Is_Mod(const char *Name)
{
     fstream file("mods.txt", ios::in);
     string tmp;
     while(file >> tmp)
     { 
         if(strcmp(Name, tmp.c_str()) == 0)
          {
               return 1;
         }
     }
     return 0;
}


class GDIGernaderCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
         if(Is_Mod(Get_Player_Name_By_ID(ID))
         {
        GameObject *obj = Get_GameObj_By_Player_Name(Text[0].c_str());
		Commands->Set_Model(obj,"c_ag_gdi_rk");
         }
         else
         {
                 //You Do Not Have Permission To Do This Command
         }

};
ChatCommandRegistrant<GDIGernaderChatCommand> GDIGernaderCommandReg("!GDIGernader",CHATTYPE_ALL,0,GAMEMODE_ALL);

//******************************************************************************

bool Is_Mod(const char *Name)
{
     fstream file("mods.txt", ios::in);
     string tmp;
     while(file >> tmp)
     { 
         if(strcmp(Name, tmp.c_str()) == 0)
          {
               return 1;
         }
     }
     return 0;
}


class GDIEngieChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
         if(Is_Mod(Get_Player_Name_By_ID(ID))
         {
        GameObject *obj = Get_GameObj_By_Player_Name(Text[0].c_str());
		Commands->Set_Model(obj,"c_ag_gdi_en");
         }
         else
         {
                 //You Do Not Have Permission To Do This Command
         }

};
ChatCommandRegistrant<GDIEngieChatCommand> GDIEngieCommandReg("!GDIEngie",CHATTYPE_ALL,0,GAMEMODE_ALL);

//******************************************************************************

bool Is_Mod(const char *Name)
{
     fstream file("mods.txt", ios::in);
     string tmp;
     while(file >> tmp)
     { 
         if(strcmp(Name, tmp.c_str()) == 0)
          {
               return 1;
         }
     }
     return 0;
}


class GDIChainGunnerChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType) {
         if(Is_Mod(Get_Player_Name_By_ID(ID))
         {
        GameObject *obj = Get_GameObj_By_Player_Name(Text[0].c_str());
		Commands->Set_Model(obj,"c_ag_gdi_mgo");
         }
         else
         {
                 //You Do Not Have Permission To Do This Command
         }

};
ChatCommandRegistrant<GDIChainGunnerChatCommand> GDIChainGunnerCommandReg("!GDIChainGunner",CHATTYPE_ALL,0,GAMEMODE_ALL);

//******************************************************************************


 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Reborn
Next Topic: coding
Goto Forum:
  


Current Time: Mon Nov 25 10:31:25 MST 2024

Total time taken to generate the page: 0.01491 seconds