Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » !DisableBeacon <playername>  () 2 Votes
!DisableBeacon <playername> [message #335070] Fri, 13 June 2008 06:20 Go to previous message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma:
General (3 Stars)
In cnc_reborn there are some annoying places people can plant beacons. For the MP-Gaming server we have made those places "illegal" to plant, but some people either do not know about that rue, or try to d it anyway. Most people don't do it now, but some still do. For this reason I made a chat command for moderators in-game to use.
I decided to post it here because I know beacon spamming in renegade could sometimes be a problem, and sometimes people planted in tunnels which some server owners do not allow.
Also, it may shed some light to people who are struggling to get the GameObject * of another player who they are trying to get by typing there name into the chat hook (this was annoying me for an hour or two also, I thought it used 0 based indexing representing each word in the string, but I should of read the comments in the plug-in i guess).

Like "!kill ren00b" or something...

So here it is:


class DisarmBeaconChatCommand : public ChatCommandClass {
void Triggered(int ID,const TokenClass &Text,int ChatType) {
	if(Is_Mod(Get_Player_Name_By_ID(ID))){
		int plantercount = 0;
if (!Text[1].empty()) {


std::string player = Text[1].c_str();

GameObject *obj = Get_GameObj_By_Player_Name(player.c_str());

if(!obj){
Console_Input(StrFormat("ppage %d You typed an invalid player name (%s), try again (case sensitive)",ID,player.c_str()).c_str());
}
else{
GenericSLNode *x = BaseGameObjList->HeadNode;
while (x){
GameObject *o = (GameObject *)x->NodeData;
if (o && As_ScriptableGameObj(o)){
if (Is_Beacon(o)) {
GameObject *planter = Get_Beacon_Planter(o);
if(planter == obj){
	plantercount +=1;
Disarm_Beacons(Get_Player_ID(obj));
Console_Input(StrFormat("ppage %d You just disarmed %s's beacon",ID,player.c_str()).c_str());
Console_Input(StrFormat("ppage %d Your beacon was just disarmed by a moderator (%s)",Get_Player_ID(obj),Get_Player_Name_By_ID(ID)).c_str());
}
	}
}
x = x->NodeNext;
}
if(plantercount == 0){
Console_Input(StrFormat("ppage %d You tried to disarm %s's beacon, but he hasn't planted one.",ID,player.c_str()).c_str());
}
}
}
plantercount = 0;
	}
	else {
Console_Input(StrFormat("ppage %d You're not a mod, GTFO.",ID).c_str());
		}
}
};
ChatCommandRegistrant<DisarmBeaconChatCommand> DisarmBeaconChatCommandReg("!DisarmBeacon",CHATTYPE_ALL,1,GAMEMODE_ALL);


the is_mod function has been posted before by Roshambo I think, but here it is if you do not have it:

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;
}


Where any name in mods.txt placed in your server's root folder will be counted as a mod.



 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: 3D models rendered as grey cubes in LE
Next Topic: Renegade Resurrection 1.1 is out!
Goto Forum:
  


Current Time: Tue Dec 24 23:30:23 MST 2024

Total time taken to generate the page: 0.00747 seconds