Author |
Message |
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sat Jun 28, 2008 9:35 pm Post subject: mervbot and .40 |
|
|
|
|
if i recall correctly, mervbot uses the old vie subspace protocol, and requires vip to remain connected to a zone...
is there a way to write a plugin/recompile it so it can connect to a .40-required zone without vip?
ive seen some chatnet bots being used in zones like hyperspace, but they only have limited functionality...
also, making a simple prize mod last night, i encountered 2 problems:
signed int temp6 = 0;
sscanf(c->final, "%d", &temp6); |
^if -6 is entered, the default 0 is used... why cant %d handle signed numbers?
result: incapability to prize -greens
void whatever(int greennum, string playername)
...
//sendPrivate(playername,"*prize #" + (String)greennum); <--didnt work, not p
sendPublic("priv green");
_listnode <Player> *parse = playerlist->head;
while (parse)
{
Player *p = parse->item;
if (p->name==playername)
{
sendPrivate(p,"*prize #" + (String)greennum);
sendPrivate(p,"green pm");
sendPublic("priv green sent");
}
parse = parse->next;
} |
only sends 'priv green', after the delay, only AFTER someone else has pub'd...
'green pm' or 'priv green sent' is never recieved, nor the prize, even if the name is case sensitive...
everything else about the plugin works flawlessly.
to anyone that cares: i have begun to make merv plugins again...
even though i cant remember anything =) _________________ SSC Distension Owner
SSCU Trench Wars Developer
Last edited by Cheese on Sun Jun 29, 2008 12:49 am, edited 1 time in total |
|
Back to top |
|
|
L.C. Server Help Squatter
Age:33 Gender: Joined: Jan 03 2003 Posts: 574 Location: Missouri, US Offline
|
Posted: Sat Jun 28, 2008 11:33 pm Post subject: |
|
|
|
|
For this matter, MERVBot should be rewritten under Snrub's documents (and Starlight, for example). Though I cannot think of any benefits of doing this at the moment. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sun Jun 29, 2008 12:49 am Post subject: |
|
|
|
|
i was figuring the whole core would need to be modified...
i also found one of the problems:
if (p->name==playername)
even if Cheese was both pname and playername, it wasnt equal. any ideas? |
|
Back to top |
|
|
Bak ?ls -s 0 in
Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
|
Purge Episode I > Eposide III Jar-Jar is kool
Age:34 Gender: Joined: Sep 08 2004 Posts: 2018 Offline
|
Posted: Sun Jun 29, 2008 2:33 am Post subject: |
|
|
|
|
Use the function strcmp() to compare the contents of both strings. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sun Jun 29, 2008 2:57 am Post subject: |
|
|
|
|
well, i just fixed it before i read your posts X_x
i ghetto-fix'd it by:
if ((String)p->name==playername)
^_^
but i still cant figure out why sscanf() isnt returning negative numbers...
works well with positive, but does nothing with negatives. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Sun Jun 29, 2008 11:42 pm Post subject: |
|
|
|
|
You should use
if (strcmp(p->name, playername) == 0)
instead.
Also, try not to use both 'string' and 'String' stuff... In MervBot, I usually only use the 'String' class. _________________ (Insert a bunch of dead links here) |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Mon Jun 30, 2008 3:44 am Post subject: |
|
|
|
|
well, what if you could somehow spawn a bot into another ip/port using a dll plugin, which would have the cont .40 protocol,and somehow link the two bots together?
i always use 'String', the code here wasnt real, only for effect and demonstrative purposes.
i never really use strcmp, does it compare arrays to strings correctly?
and is it case sensitive?
'but i still cant figure out why sscanf() isnt returning negative numbers...
works well with positive, but does nothing with negatives.'
^this is still true, ive made 3 plugins in 3 nights, and this is the only glaring error to my otherwise spotless plugins... |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Mon Jun 30, 2008 9:51 am Post subject: |
|
|
|
|
http://www.cplusplus.com/reference/clibrary/cstring/strcmp.html
All your questions answered
Yes it is case sensitive (just like using == between 2 Strings)
I have a function that might be useful for you; I made it especially to search for a player in the player list, so it ignores case, and can work for partial matches:
Player* FindPlayerByName(char *name, bool exactmatch, _linkedlist <Player>* list)
{
_listnode <Player> *parse = list->head; //set to first link of the player linked list
Player* bestmatchplayer = NULL;
int bestmatchlength = 0;
String nametofind = name;
nametofind.lcase();
while (parse) //parse will be NULL when we reach the last link
{
Player *p = parse->item; //item is the actual data stored in the link
String pname = (String) p->name;
pname.lcase();
if (pname == nametofind)
return p;
if (!exactmatch)
{
int firstdifferent = FirstDifferentCharacter(nametofind, pname);
if (bestmatchlength < firstdifferent)
{
bestmatchlength = firstdifferent;
bestmatchplayer = p;
}
}
parse = parse->next; //set parse to the next link
}
return bestmatchplayer;
}
|
The playerlist is passed as parameter, but if you use this function inside the botInfo class, you could use playerlist and get rid of that parameter.
Your function would become something like:
void whatever(int greennum, String playername)
{
//Find the target player; use 'true' as 2nd parameter if you don't want partial matches (i.e. "sam" can return the player "Samapico")
Player * target = FindPlayerByName(playername, false, playerlist);
if (target != NULL)
{
sendPrivate(target, "*prize #" + String(greennum));
}
}
|
|
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Mon Jun 30, 2008 3:43 pm Post subject: |
|
|
|
|
but where is FirstDifferentCharacter()? =S |
|
Back to top |
|
|
k0zy Server Help Squatter
Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Mon Jun 30, 2008 4:22 pm Post subject: |
|
|
|
|
doh
lol
what he said |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
|
Back to top |
|
|
|