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 next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
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);

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


Re: Another SSGM Question [message #271872 is a reply to message #271871] Mon, 09 July 2007 01:14 Go to previous messageGo to next message
Hex is currently offline  Hex
Messages: 858
Registered: March 2004
Karma: 0
Colonel
you would be better off using something like



if (stricmp(Msg,"!GDISoldier") == 0) {
  if(Is_Mod(Get_Player_Name_By_ID(ID))
  Commands->yourcode
  } else {
  // can't use this command
  }
}
else if (stricmp(Msg,"!GDIShotGunner") == 0) {
  if(Is_Mod(Get_Player_Name_By_ID(ID))
  Commands->yourcode
  } else {
  // can't use this command
  }
}


goztow wrote on Tue, 11 May 2010 08:00

If we had to ban all who ever cheated or ever created a cheat (obj3cts and such) then I don't think there would be many members left here (sad fact).


reborn wrote on Fri, 29 January 2010 23:37

std is for pro's. Razz
Re: Another SSGM Question [message #271874 is a reply to message #271871] Mon, 09 July 2007 01:30 Go to previous messageGo to next message
Whitedragon is currently offline  Whitedragon
Messages: 832
Registered: February 2003
Location: California
Karma: 1
Colonel
You only need it once. And in the registrants the 0 should be a 1 since the commands require at least 1 parameter, the player's nick that it's being used on.

Black-Cell.net
Network Administrator (2003 - )

DragonServ, Renegade's first IRC interface bot
Creator and lead coder (2002 - )

Dragonade, Renegade's first server side modification
Lead coder (2005 - )
Re: Another SSGM Question [message #271876 is a reply to message #271871] Mon, 09 July 2007 01:42 Go to previous messageGo to next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
General (4 Stars)
1)ty now how aobut if i have to add another set of commands using a diffrenet txt file?

2)or is hex code better for ssgm?

3)
Quote:

And in the registrants the 0 should be a 1 since the commands require at least 1 parameter, the player's nick that it's being used on.



that part i dont get

[Updated on: Mon, 09 July 2007 01:43]

Report message to a moderator

Re: Another SSGM Question [message #271879 is a reply to message #271871] Mon, 09 July 2007 01:58 Go to previous messageGo to next message
Whitedragon is currently offline  Whitedragon
Messages: 832
Registered: February 2003
Location: California
Karma: 1
Colonel
You could make Is_Mod work for any text file:

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


if (Is_Mod(file,nick)) {



joe937465 wrote on Mon, 09 July 2007 03:56



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




That should be a 1.


Black-Cell.net
Network Administrator (2003 - )

DragonServ, Renegade's first IRC interface bot
Creator and lead coder (2002 - )

Dragonade, Renegade's first server side modification
Lead coder (2005 - )
Re: Another SSGM Question [message #271880 is a reply to message #271871] Mon, 09 July 2007 02:02 Go to previous messageGo to next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
General (4 Stars)
well idk if thats it u see there soem set of command only adminds can do
im thinkg admins.txt and soem commands the rest can do m,ods.txt

how can i make it do i add more of thse commands?

or use the code above and place a 2 instead of 1 for some codes and etc ect
Re: Another SSGM Question [message #271881 is a reply to message #271871] Mon, 09 July 2007 02:11 Go to previous messageGo to next message
Whitedragon is currently offline  Whitedragon
Messages: 832
Registered: February 2003
Location: California
Karma: 1
Colonel
I just showed you how to have multiple files, admins.txt, mods.txt, etc., and use the same Is_Mod for all of them.

Quote:


You could make Is_Mod work for any text file:

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




So

if (Is_Mod("admins.txt",Get_Player_Name_By_ID(ID))) {



The 0/1 has nothing to do with that.


Black-Cell.net
Network Administrator (2003 - )

DragonServ, Renegade's first IRC interface bot
Creator and lead coder (2002 - )

Dragonade, Renegade's first server side modification
Lead coder (2005 - )
Re: Another SSGM Question [message #271883 is a reply to message #271871] Mon, 09 July 2007 02:13 Go to previous messageGo to next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
General (4 Stars)
OO so add that code and in the command add that line to get ti to work? if so thats perfect........

and what does the 0/1 do anyways why did i have to change ti? lol

[Updated on: Mon, 09 July 2007 02:14]

Report message to a moderator

Re: Another SSGM Question [message #271892 is a reply to message #271874] Mon, 09 July 2007 03:57 Go to previous messageGo to next message
dead6re is currently offline  dead6re
Messages: 602
Registered: September 2003
Karma: 0
Colonel
Whitedragon wrote on Mon, 09 July 2007 04:30

And in the registrants the 0 should be a 1 since the commands require at least 1 parameter, the player's nick that it's being used on.



Let all your wishes be granted except one, so you will still have something to strieve for.
Re: Another SSGM Question [message #271894 is a reply to message #271871] Mon, 09 July 2007 04:03 Go to previous messageGo to next message
_SSnipe_ is currently offline  _SSnipe_
Messages: 4121
Registered: May 2007
Location: Riverside Southern Califo...
Karma: 0
General (4 Stars)
nice this stuff is starting to make since,,,,,,,,
Re: Another SSGM Question [message #271915 is a reply to message #271871] Mon, 09 July 2007 05:40 Go to previous message
Hex is currently offline  Hex
Messages: 858
Registered: March 2004
Karma: 0
Colonel
Since you have said you are using brenbot, you will need to read the levels

Quote:


[ADMINS]
admin1
admin2
admin3

[FULL_MODS]
mod1
mod2

[HALF_MODS]
hmod1
hmod2



goztow wrote on Tue, 11 May 2010 08:00

If we had to ban all who ever cheated or ever created a cheat (obj3cts and such) then I don't think there would be many members left here (sad fact).


reborn wrote on Fri, 29 January 2010 23:37

std is for pro's. Razz
Previous Topic: Reborn
Next Topic: coding
Goto Forum:
  


Current Time: Mon Nov 25 08:44:10 MST 2024

Total time taken to generate the page: 0.00812 seconds