Witchie NL Posted April 15, 2006 Report Posted April 15, 2006 ok becouse i have liek 4 topics which i need help in for bots (ohh im so stupid) ill open this 1 which ill awnser my questions in.... this way you people dont get to many aged topics...
Witchie NL Posted April 15, 2006 Author Report Posted April 15, 2006 (edited) ok my first question to start with is how to write a certain text in an .txt my code so far:case EVENT_Tick: { for (int i = 0; i < 4; ++i) --countdown[i]; if (countdown[0] == 0) { tell(makeEcho("Saving current scores!")); _listnode <Player> *parse = playerlist->head; /// cycle through the playerlist while (parse) /// while cycling... { Player *p = parse->item; /// make sure it's a player... { int killpoints = p->score.killPoints; int flagpoints = p->score.flagPoints; int totalpoints = flagpoints + killpoints; int losses = p->score.losses; int wins = p->score.wins; sendChannel("---" + String(p->name) + "---"); sendChannel("wins :" + String(wins)); sendChannel("losses :" + String(losses)); sendChannel("killpoints :" + String(killpoints)); sendChannel("flagpoints :" + String(flagpoints)); sendChannel("totalpoints :" + String(totalpoints)); sendChannel(" "); } parse = parse->next; /// set link to next player } countdown[0] = 60; } } break; yes it works now i dont need to let the bot say it in a channel but let it put it in a text do!@#$%^&*ent.... and if that player already has be decleared in the textdoc change it and if the player doenst excist in the text do!@#$%^&*ent yet then put it underneath it... meaning of this plugin: backing up the score's in case !@#$%^&* mod's or higher *scorereset the arena! if this is easyer this may also be posible...:that it stores:: kills:#### losses:#### killpoints:#### flagpoints:#### totalpoints:#### Edited: happy samapico? Edited April 16, 2006 by D1st0rt
»D1st0rt Posted April 16, 2006 Report Posted April 16, 2006 http://wiki.minegoboom.com/index.php/MERVB...Output_to_files The Wiki is always a good place to start
Witchie NL Posted April 16, 2006 Author Report Posted April 16, 2006 hmmmm i know i always look there but my problem is that im a dutch !@#$%^&* which doesnt understand (...) from that but ill try again (i always try to learn things from other plugins)
Witchie NL Posted April 16, 2006 Author Report Posted April 16, 2006 ok i think im now serious stupid or did i found a problem! code:case EVENT_Tick: { for (int i = 0; i < 4; ++i) --countdown[i]; if (countdown[0] == 0) { tell(makeEcho("Saving current scores!")); _listnode <Player> *parse = playerlist->head; /// cycle through the playerlist while (parse) /// while cycling... { Player *p = parse->item; /// make sure it's a player... { int killpoints = p->score.killPoints; int flagpoints = p->score.flagPoints; int totalpoints = flagpoints + killpoints; int losses = p->score.losses; int wins = p->score.wins; ofstream file("backup.txt", ios::app); // app = put all data at end of file file << name << endl; file << killpoints << endl; // squad1 = char[20] file << flagpoints << endl; file << totalpoints << endl; // squad2 = char[20] file << " " << endl; file.close(); } parse = parse->next; /// set link to next player } countdown[0] = 60; } } break; errors:e:\mervbot\src\backup\spawn.cpp(78) : error C2065: 'ofstream' : undeclared identifiere:\mervbot\src\backup\spawn.cpp(78) : error C2146: syntax error : missing ';' before identifier 'file'e:\mervbot\src\backup\spawn.cpp(78) : error C2065: 'file' : undeclared identifiere:\mervbot\src\backup\spawn.cpp(78) : error C2653: 'ios' : is not a class or namespace namee:\mervbot\src\backup\spawn.cpp(78) : error C2065: 'app' : undeclared identifiere:\mervbot\src\backup\spawn.cpp(79) : error C2065: 'endl' : undeclared identifiere:\mervbot\src\backup\spawn.cpp(79) : warning C4552: '<<' : operator has no effect; expected operator with side-effecte:\mervbot\src\backup\spawn.cpp() : warning C4552: '<<' : operator has no effect; expected operator with side-effecte:\mervbot\src\backup\spawn.cpp(81) : warning C4552: '<<' : operator has no effect; expected operator with side-effecte:\mervbot\src\backup\spawn.cpp(82) : warning C4552: '<<' : operator has no effect; expected operator with side-effecte:\mervbot\src\backup\spawn.cpp(83) : error C2297: '<<' : illegal, right operand has type 'char [2]'e:\mervbot\src\backup\spawn.cpp(84) : error C2228: left of '.close' must have class/struct/union typeError executing cl.exe. now wtf?i have the #include but still not working..... HELP!?
Witchie NL Posted April 16, 2006 Author Report Posted April 16, 2006 !@#$%^&* just when i think i cant get any more stupid i just proof myself i can edit: removed my MOST stupid action i ever made!
Tex Posted April 16, 2006 Report Posted April 16, 2006 Instead of having all those variables you could just typecast them as Strings when you are saving them into the file, except that totalpoints one, You could make it more efficient
Witchie NL Posted April 16, 2006 Author Report Posted April 16, 2006 yeah i will... ok i need to do 1 more thing! i need to let my bot delete the previous saved text code i have so far:case EVENT_Tick: { for (int i = 0; i < 4; ++i) --countdown[i]; char u[100]; /// obtaining current time! time_t t=time(NULL); /// obtaining current time! tm *tmp = localtime(&t); /// obtaining current time! strftime(u,99,"%c",tmp); /// obtaining current time! if (countdown[0] == 0) { tell(makeEcho("Saving current scores!")); /// print <tekst> in the mervbot terminal _listnode <Player> *parse = playerlist->head; /// cycle through the playerlist while (parse) /// while cycling... { Player *p = parse->item; /// make sure it's a player... { int killpoints = p->score.killPoints; int flagpoints = p->score.flagPoints; int totalpoints = flagpoints + killpoints; int losses = p->score.losses; int wins = p->score.wins; ofstream file("backup.txt", ios::app); file << "Name :" << p->name << endl; file << "KillPoints :" << killpoints << endl; // squad1 = char[20] file << "FlagPoints :" << flagpoints << endl; file << "TotalPoints :" << totalpoints << endl; // squad2 = char[20] file << "Wins :" << wins << endl; file << "Losses :" << losses << endl << endl; file.close(); } parse = parse->next; /// set link to next player } countdown[0] = 20; } if (countdown[1] == 1) { ofstream file("backup.txt", ios::app); file << "-------------------------------------------------" << endl; file << "[" << u << "]" << endl << endl; countdown[1] = 20; } } break;(the current time function is in a seperate countdown coz it else stops looping the scroll through playerlist loop after the 1st loop (stops after storing 1 players stats)) now it saves: -------------------------------------------------[04/16/06 16:34:35] Name :nameKillPoints :0FlagPoints :0TotalPoints :0Wins :0Losses :0 -------------------------------------------------[04/16/06 16:34:55] Name :nameKillPoints :0FlagPoints :0TotalPoints :0Wins :0Losses :0 but it needs to delete the previous stats it has saved so youll just get and keep this: -------------------------------------------------[04/16/06 16:34:35] Name :nameKillPoints :0FlagPoints :0TotalPoints :0Wins :0Losses :0
Witchie NL Posted April 25, 2006 Author Report Posted April 25, 2006 YAJ! got a new question!(i do keep you guyz buzzy do i?) question:how does the "last carried" part work i heared that there was a way to determine who was the last person who carried a ball... but just How can you do that do you use:case EVENT_BallMove: { PBall *ball = (PBall*)event.p[0]; } break; or do you use:case EVENT_SoccerGoal: { int team = *(int*)&event.p[0]; int reward = *(int*)&event.p[1]; } break; Or something else?PLEASE HELP ME! WEEEEEEEEEEEEEEEEEEEE by the time im finished with this topic this is a whole tuturial of "how to write a MERVbot plugin"
Tex Posted April 26, 2006 Report Posted April 26, 2006 Just delete the files and start a new one if you are not saving it?Or are you saving it? If so, you have to copy the lines you want to let's say... strings and then delete the file, then copy them back in. Atleast, that is the way I do it... whoa whoa And use Ball_MoveJust check to see if the ball is moving, and put that person's name in a string... and that should give you the last person, or the current person holding the ball. and don't ask me how... look in the source files... catid is nice with his comments
Witchie Posted April 30, 2006 Report Posted April 30, 2006 ok i got a question which isnt discribed anywhere... you got the CMPSTART part:if (CMPSTART("<piece of the mess> ", msg)) that reads if the message starts with a certain part.is there also a tag for the end of the message or a part from the sentence. for instance if i say:Witchie NL> your mother is !@#$%^&*ing ugly you have something like:if (CMPPART("mother ", msg)) it reply's with: yeah your mother is that to!
Drake7707 Posted May 1, 2006 Report Posted May 1, 2006 http://www.bgsu.edu/departments/compsci/docs/string.html use pattern matching
Witchie Posted May 2, 2006 Report Posted May 2, 2006 SOS strstr() is: if the whole message is whats between the () then do ... not: if a part of the message is:
Witchie Posted May 3, 2006 Report Posted May 3, 2006 not to hard if you think about it. strstr() is used if it needs to check if a whole line is whats between the (): the message is: !@#$%^&*if the code is: strstr("!@#$%^&*", #); sendPublic("you said !@#$%^&*");it reply's with you said !@#$%^&* if the message is "!@#$%^&* YOU" it doesnt awnser coz strstr only gets true if the line between the () is she same as the message it needs to listen to. if you use CMPSTART instead of strstr then CMPSTART checks if the message starts with a certain word.if the line between the () is: "!@#$%^&*" it does reply with "you said !@#$%^&*"
X`terrania Posted May 3, 2006 Report Posted May 3, 2006 I have no idea what you just said... . . . SOS, even if his english is !@#$%^&*, Dav+'s is the worst!
»Purge Posted May 4, 2006 Report Posted May 4, 2006 ...Or you can just use if (CMPSTR("!@#$%^&*", msg)) in the EVENT_Chat case of spawn.cpp...
»SOS Posted May 4, 2006 Report Posted May 4, 2006 I'm quite sure you're wrong Witchie, but I don't care enough to check
Witchie Posted May 4, 2006 Report Posted May 4, 2006 my english isnt !@#$%^&*, but im dutch so i cant explain it realy well.. (i think that is the problem)...LOL
Witchie NL Posted June 4, 2006 Author Report Posted June 4, 2006 Ok another question (to lazy to go to minegoboom forum) How can you determine where a player is?Coz i couldent find the src of warp.dll or warpz.dll or something like that ill ask it here. (it needs to do same thing as that plugin with a few more options, thats why i customize it.)
Witchie NL Posted June 5, 2006 Author Report Posted June 5, 2006 ok ignore this question. But dont ignore the next:Where can i find a "working" source from TM_Baw.dll? the 1 that is included on catid's page doesnt compile.8 times: TM Baw\spawn.cpp(188) : error C2362: initialization of 'i2' is skipped by 'goto InvalidEntry'TM Baw\spawn.cpp(169) : see declaration of 'i2'
»SOS Posted June 5, 2006 Report Posted June 5, 2006 Fix the errors if you're a coder worth anything! -_-They are very easy to fix. The error message says it all.
Witchie NL Posted June 5, 2006 Author Report Posted June 5, 2006 ehm? i duno xD yes im a coder but never seen that error. -=thinks he needs to be ashemed, am i right?=- (or can it be coz i use MVC++ 6 instead of 7.0 where its originaly made in.
Recommended Posts