Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
player matching

 
Post new topic   Reply to topic Printable version
 View previous topic  Where can i find dese bots? Post :: Post need ctf plugin assistance  View next topic  
Author Message
Anborn
Newbie


Joined: Dec 02 2002
Posts: 13
Offline

PostPosted: Sun Jan 12, 2003 12:34 pm    Post subject: player matching Reply to topic Reply with quote

I've added the following as a command for the MERV bot. captains[] is an array of *char. where i'm keeping the name of whoever is registered to be a captain. that is being recognized correctly as when a captains uses !remove <playername> it responds into the correct else section and when a non-captain uses the command it indicates as such by saying you don't have access.

Now, when it parses the playerlist to see if the name listed in the command (say for instance !remove Druid)... it will always come back to the "that player is not found" msg... even if the 2 Debug displays are the exact same for one of the players in the player list. Why wouldn't this when displayed the same way in the debug msgs ... kick into the spec command.

The code for the command is as follows... and a sample inzone output follows that.

Any help would be appreciated.



Code: Show/Hide
         else if (c->check("remove")) {
            // if the player isn't a capt
            if(p->name != captains[0] && p->name != captains[1]) {
               sendPrivate(p,"You are not a captain and don't have access to this command");
            }
            else {
               String s;
               s = c->final;
               int found=0;

               _listnode <Player> *parse = playerlist->head;
               while (parse && found==0) {
                  Player *r = parse->item;
                  sendRemotePrivate("Debug",r->name);
                  sendRemotePrivate("Debug",s);
                  if (r->name == s)   {
                     sendPrivate(r,"*setship 0");
                     sendPrivate(r,"*setfreq SPECFREQ");
                     found=1;
                  }
                  parse = parse->next;
               }

               if(found==0) sendPrivate(p,"That player wasn't found");
            }
         }




Anborn+> !remove B.Mccabe #24+
(Anbo)>Anborn+ <--- player in player list
(Anbo)>B.Mccabe #24+ <--- command parameter
(Anbo)>B.Mccabe #24+ <--- player in player list
(Anbo)>B.Mccabe #24+ <--- command parameter
B.Mccabe #> anbo
(Anbo)>Anbo <--- player in player list
(Anbo)>B.Mccabe #24+ <--- command parameter
Anbo> That player wasn't found
_________________
Anborn
-- SSHZ
Back to top
View users profile Send private message Add User to Ignore List
SOS
Server Help Squatter


Joined: Dec 02 2002
Posts: 329
Offline

PostPosted: Sun Jan 12, 2003 1:51 pm    Post subject: Reply to topic Reply with quote

Hmm... I would say

if (r->name == s) {

should be

if (s == r->name) {
_________________
3y3 4m l33t h4x0r
j0! 3y3 4m t4lking to j00!
fux0red 5cr1pt k1dd13.
-"l33t h41ku"
Back to top
View users profile Send private message Add User to Ignore List Send email
Anborn
Newbie


Joined: Dec 02 2002
Posts: 13
Offline

PostPosted: Mon Jan 13, 2003 12:35 am    Post subject: Reply to topic Reply with quote

SOS - thanks... that did it... forgive me as my last programming class was 4 years ago... but why don't they do the same thing?! time to hit the net to figure out stuff I should have actually learned while I was in school icon_smile.gif hehe.
Back to top
View users profile Send private message Add User to Ignore List
SOS
Server Help Squatter


Joined: Dec 02 2002
Posts: 329
Offline

PostPosted: Mon Jan 13, 2003 7:41 am    Post subject: Reply to topic Reply with quote

The == operator for the left operand is called. Just the way the language works.
In this case, the other way around would just compare the pointer to the char[] with the pointer to the String, which would always be false.
But since String has a == operator to check a char array, it works sa_tongue.gif

BTW, if you're going for faster strings and more features, CString is a much better class to use than Catid's String.
It's in atlstr.h or afxstr.h(I think) if using MFC.
Back to top
View users profile Send private message Add User to Ignore List Send email
Anborn
Newbie


Joined: Dec 02 2002
Posts: 13
Offline

PostPosted: Mon Jan 13, 2003 9:21 am    Post subject: Reply to topic Reply with quote

cool thanks SOS... muchos gracias once again icon_smile.gif
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 1060 page(s) served in previous 5 minutes.

phpBB Created this page in 0.522013 seconds : 30 queries executed (81.9%): GZIP compression disabled