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."); } } |