Jump to content
SubSpace Forum Network

Recommended Posts

Posted
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...
Posted (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 B)

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 by D1st0rt
Posted
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)
Posted

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 identifier

e:\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 identifier

e:\mervbot\src\backup\spawn.cpp(78) : error C2653: 'ios' : is not a class or namespace name

e:\mervbot\src\backup\spawn.cpp(78) : error C2065: 'app' : undeclared identifier

e:\mervbot\src\backup\spawn.cpp(79) : error C2065: 'endl' : undeclared identifier

e:\mervbot\src\backup\spawn.cpp(79) : warning C4552: '<<' : operator has no effect; expected operator with side-effect

e:\mervbot\src\backup\spawn.cpp(mega_shok.gif) : warning C4552: '<<' : operator has no effect; expected operator with side-effect

e:\mervbot\src\backup\spawn.cpp(81) : warning C4552: '<<' : operator has no effect; expected operator with side-effect

e:\mervbot\src\backup\spawn.cpp(82) : warning C4552: '<<' : operator has no effect; expected operator with side-effect

e:\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 type

Error executing cl.exe.

 

 

now wtf?

i have the #include but still not working.....

 

HELP!?

Posted
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
Posted

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 :name

KillPoints :0

FlagPoints :0

TotalPoints :0

Wins :0

Losses :0

 

-------------------------------------------------

[04/16/06 16:34:55]

 

Name :name

KillPoints :0

FlagPoints :0

TotalPoints :0

Wins :0

Losses :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 :name

KillPoints :0

FlagPoints :0

TotalPoints :0

Wins :0

Losses :0

  • 2 weeks later...
Posted

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"

Posted

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_Move

Just 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. smile.gif and don't ask me how... look in the source files... catid is nice with his comments smile.gif

Posted

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!

Posted

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 !@#$%^&*"

  • 5 weeks later...
Posted

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.)

Posted

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'

Posted
ehm? i duno xD yes im a coder but never seen that error. blum.gif -=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.
Guest
This topic is now closed to further replies.
×
×
  • Create New...