Server Help

ASSS Questions - freqowners with feedback

Bak - Thu Jan 06, 2005 2:04 pm
Post subject: freqowners with feedback
Here's a modules that will (hopefully) replace the current freqowners one.

It's almost identical except it provides feedback whenever you use the commands, so you know why player x isn't being kicked off your freq. There's also a ?getowner command that will print the current owners of your freq, or make you an owner if there aren't any (should the case ever arise).

EDIT: fixed a bug with ?getowner
Anonymous - Mon Jan 17, 2005 3:36 am
Post subject:
awww, i dont know how to compile C icon_sad.gif o well..
Solo Ace - Mon Jan 17, 2005 7:05 am
Post subject:
I haven't looked much into the ASSS documentation on ASSS Wiki, but I think the last time I checked it Smong wrote some article on compiling C modules.
My guide is currently offline, otherwise I'd give you that too.
CypherJF - Mon Jan 17, 2005 7:34 am
Post subject:
For chambah's sake, the doctor recommend that he not compile anything writen in c that deals with asss. lol
i88gerbils - Mon Jan 17, 2005 10:35 am
Post subject:
Could you produce a diff output? Hmm, maybe I'll just do that myself...

Here it is:
Code: Show/Hide

--- src/freqowners-old.c   2005-01-08 20:09:11.000000000 -0500
+++ src/freqowners.c   2005-01-17 10:37:51.000000000 -0500
@@ -1,7 +1,7 @@

/* dist: public */

-#include "asss.h"
+#include "../../asss.h"


/* the delay (in ticks) between a ?freqkick and its effect */
@@ -10,7 +10,8 @@
/* commands */
local void Cgiveowner(const char *, const char *, Player *, const Target *);
local void Cfreqkick(const char *, const char *, Player *, const Target *);
-local helptext_t giveowner_help, freqkick_help;
+local void Cgetowner(const char *tc, const char *params, Player *p, const Target *target);
+local helptext_t giveowner_help, freqkick_help, getowner_help;

/* callbacks */
local void MyPA(Player *p, int action, Arena *arena);
@@ -54,6 +55,7 @@

      cmd->AddCommand("giveowner", Cgiveowner, ALLARENAS, giveowner_help);
      cmd->AddCommand("freqkick", Cfreqkick, ALLARENAS, freqkick_help);
+      cmd->AddCommand("getowner", Cgetowner, ALLARENAS, getowner_help);

      return MM_OK;
   }
@@ -61,6 +63,8 @@
   {
      cmd->RemoveCommand("giveowner", Cgiveowner, ALLARENAS);
      cmd->RemoveCommand("freqkick", Cfreqkick, ALLARENAS);
+      cmd->RemoveCommand("getowner", Cgetowner, ALLARENAS);
+
      mm->UnregCallback(CB_PLAYERACTION, MyPA, ALLARENAS);
      mm->UnregCallback(CB_FREQCHANGE, MyFreqCh, ALLARENAS);
      mm->UnregCallback(CB_SHIPCHANGE, MyShipCh, ALLARENAS);
@@ -120,12 +124,92 @@
void Cgiveowner(const char *tc, const char *params, Player *p, const Target *target)
{
   if (target->type != T_PLAYER)
-      return;
+   {
+      chat->SendMessage(p, "You must send this command to a player.");
+   }
+   else if (!OWNSFREQ(p))
+   {
+      chat->SendMessage(p, "You are not the owner of your freq.");
+   }
+   else if (!(p->arena == target->u.p->arena && p->p_freq == target->u.p->p_freq))
+   {
+      chat->SendMessage(p, "That player is not on your freq.");
+   }
+   else if (OWNSFREQ(target->u.p))
+   {
+      chat->SendMessage(p, "That player is already an owner of your freq.");
+   }
+   else
+   {
+      Player *t = target->u.p;
+      OWNSFREQ(t) = 1;
+      chat->SendMessage(p, "You have granted ownership to %s",t->name);
+      chat->SendMessage(t, "%s has granted you ownership of your freq.",p->name);
+   }
+}
+
+local helptext_t getowner_help =
+"Module: freqowners\n"
+"Targets: none\n"
+"Args: none\n"
+"Makes you become owner of your freq, if your freq doesn't have an owner already.\n";
+

-   if (OWNSFREQ(p) &&
-       p->arena == target->u.p->arena &&
-       p->p_freq == target->u.p->p_freq)
-      OWNSFREQ(target->u.p) = 1;
+void Cgetowner(const char *tc, const char *params, Player *p, const Target *target)
+{
+   Player *t = target->u.p;
+   ConfigHandle ch = p->arena->cfg;
+
+   if (cfg->GetInt(ch, "Team", "AllowFreqOwners", 1) &&
+       p->p_freq >= cfg->GetInt(ch, "Team", "PrivFreqStart", 100) &&
+        p->p_freq != p->arena->specfreq)
+   {
+      Player *pl;
+      Link *link;
+      int found = 0;
+
+      pd->Lock();
+      
+      FOR_EACH_PLAYER(pl)
+      {
+         if (pl->arena == p->arena && p->p_freq == pl->p_freq) // same team
+         {
+            if (OWNSFREQ(pl))
+            {
+               found = 1;
+               break;
+            }
+         }
+      }
+      pd->Unlock();
+
+      if (found == 0)
+      {
+         OWNSFREQ(pl) = 1;
+
+         chat->SendMessage(p,"You are now the owner of your freq.");
+      }
+      else
+      {
+         chat->SendMessage(p, "The owner(s) are:");
+
+         pd->Lock();
+         
+         FOR_EACH_PLAYER(pl)
+         {
+            if (pl->arena == p->arena && p->p_freq == pl->p_freq) // same team
+            {
+               if (OWNSFREQ(pl))
+               {
+                  chat->SendMessage(p, "%s",pl->name);
+               }
+            }
+         }
+         pd->Unlock();
+      }
+   }
+   else
+      chat->SendMessage(p,"Your freq can not have an owner.");
}


@@ -140,14 +224,69 @@
void Cfreqkick(const char *tc, const char *params, Player *p, const Target *target)
{
   Player *t = target->u.p;
+   ConfigHandle ch = p->arena->cfg;

-   if (target->type != T_PLAYER)
-      return;
+   if (cfg->GetInt(ch, "Team", "AllowFreqOwners", 1) &&
+       p->p_freq >= cfg->GetInt(ch, "Team", "PrivFreqStart", 100) &&
+        p->p_freq != p->arena->specfreq)
+   {

-   if (OWNSFREQ(p) && !OWNSFREQ(t) &&
-       p->arena == t->arena &&
-       p->p_freq == t->p_freq)
-      ml->SetTimer(kick_timer, KICKDELAY, 0, t, t);
+      if (target->type != T_PLAYER)
+      {
+         chat->SendMessage(p, "You must message the command to a player on your freq.");
+      }
+      else if (OWNSFREQ(p))
+      {
+         if (p->arena == t->arena && p->p_freq == t->p_freq)
+         {
+            if(!OWNSFREQ(t))
+            {
+               chat->SendMessage(p, "%s will be kicked off in a moment.",t->name);
+               ml->SetTimer(kick_timer, KICKDELAY, 0, t, t);
+            }
+            else
+               chat->SendMessage(p, "You can not kick other freq owners off your freq.");
+         }
+         else
+         {
+            chat->SendMessage(p, "That player is not on your freq.");
+         }
+      }
+      else
+      {
+         Player *pl;
+         Link *link;
+         int found = 0;
+         
+         chat->SendMessage(p, "You are not the owner of your freq. The owner(s) are:");
+
+         pd->Lock();
+         
+         FOR_EACH_PLAYER(pl)
+         {
+            if (pl->arena == p->arena && p->p_freq == pl->p_freq) // same team
+            {
+               if (OWNSFREQ(pl))
+               {
+                  chat->SendMessage(p, "%s",pl->name);
+                  found = 1;
+               }
+            }
+         }
+         pd->Unlock();
+
+         if (found == 0)
+         {
+            chat->SendMessage(p,"nobody");
+            chat->SendMessage(p,"To become the owner of your freq use ?getowner");
+         }
+      
+      }
+   }
+   else
+   {
+      chat->SendMessage(p,"Your freq can not have an owner.");
+   }
}


@@ -188,7 +327,7 @@
      }
      else if (hasowner)
         chat->SendMessage(p, "This freq has an owner. You should be aware "
-               "that you can be kicked off any time.");
+               "that you can be kicked off any time. If the owner leaves you can use ?getowner to become the new owner.");
   }
}

D1st0rt - Mon Jan 17, 2005 10:39 am
Post subject:
I just use the Dev-C++ project to compile
Solo Ace - Mon Jan 17, 2005 12:23 pm
Post subject:
What kind of "format" (or whatever it is) is that, and what is it for?
i88gerbils - Mon Jan 17, 2005 12:50 pm
Post subject:
diff?
Solo Ace - Mon Jan 17, 2005 2:04 pm
Post subject:
Ah, thanks. icon_smile.gif

Hm, why are you putting two links together in one word? sa_tongue.gif I'd miss one of them easily.
Mine GO BOOM - Mon Jan 17, 2005 2:07 pm
Post subject:
If you are using Windows, I'd recommend installing UnxUtils. Saves you a lot of hassle over installing Cygwin just for good command line programs. Plus, pclip and gclip are kickass extras.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group