Author |
Message |
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Fri Apr 04, 2008 8:17 pm Post subject: |
|
|
|
|
it's pretty much it... go check the Merv functions of get_tag and set_tag, might help you understanding.
When you get_tag, the code scrolls through all the tags you've set, and when the player AND the index matches, it returns you the current value of that tag (the data). If it doesn't find any tag for that player with that index, it returns 0 by default. _________________ (Insert a bunch of dead links here) |
|
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: Fri Apr 04, 2008 10:20 pm Post subject: |
|
|
|
|
Don't confuse #define with a standard definition like int i = 0. In the snippet I posted, #define INDEX 2 is saying that INDEX has 3 values; or using Bak's analogy, 3 pages. It is not the same as int INDEX = 3. |
|
Back to top |
|
|
Bak ?ls -s 0 in
Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Fri Apr 04, 2008 10:26 pm Post subject: |
|
|
|
|
wat? are you sure purge? |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Fri Apr 04, 2008 11:57 pm Post subject: |
|
|
|
|
uh... no... #define INDEX 2 means that anywhere you put INDEX in your code, it is replaced by "2" before anything is even compiled.
For example, if I need 3 tags, I usually do something like:
#define TAG_SOMETAG 0
#define TAG_ANOTHERTAG 1
#define TAG_THIRDTAG 2
And I use these as index values.
And what purge said isn't true... last I checked, the tags is a linkedlist, not an array. Each tag on the linked list is a struct with Player* p, int index and int data. |
|
Back to top |
|
|
Bak ?ls -s 0 in
Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Sat Apr 05, 2008 12:45 am Post subject: |
|
|
|
|
in Mervbot, you can use
WHEN_COWS_FLY
{
//statements
}
for something that will never happen...
If I remember right, there is:
#define WHEN_COWS_FLY if(false)
somewhere in the code |
|
Back to top |
|
|
Purge Episode I > Eposide III Jar-Jar is kool
Age:34 Gender: Joined: Sep 08 2004 Posts: 2018 Offline
|
Posted: Sat Apr 05, 2008 1:47 am Post subject: |
|
|
|
|
Meh, sorry about the bad info. This is why I'm premed and not computer anything. |
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
Posted: Sun Apr 06, 2008 2:15 pm Post subject: |
|
|
|
|
Ok i get the tags now and made a bot with them that works just how do you do a code that if any point during game that event happens, then exectute other code
this is the code when i tried to make the bot and it works just the bot realizes you beat the mission only you type something to him
also here the mission is to collect 30 bounty
// EASY MISSION BOUNTY HUNTER CODE
else if (c->check("easymission:1")) // start easy bounty hunter mission
{
if (get_tag(p,mission1)!=on)
{
sendPrivate(p,"You started an easy mission \"Bounty Hunter\" Type !abort:easy:1 anytime during the game to abort this mission");
set_tag(p, mission1, on);
}
else if (get_tag(p,mission1)==on)
{
sendPrivate(p,"You already started easy mission \"Bounty Hunter\" Type !abort:easy:1 to abort mission.");
}
}
else if ( get_tag(p,mission1)==on && p->bounty>=30 )
{
sendPrivate(p,"You beated easy mission \"Bounty Hunter\" Congratulations!");
sendPrivate(p,"*points 5000");
set_tag(p,mission1,off);
}
else if (c->check("abort:easy:1"))
{
if (get_tag(p,mission1)==on)
{
sendPrivate(p,"You aborted easy mission \"Bounty Hunter\"");
set_tag(p,mission1,off);
}
else if (get_tag(p,mission1)!=on)
{
sendPrivate(p,"You never started easy mission \"Bounty Hunter\"");
}
}
// END OF EASY MISSION BOUNTY HUNTER CODE |
also i got this in spawn.h #define mission1 1
#define on 1 // mission is on
#define off 0 // mission is off |
also to samapico:
yup ur right its in datatypes.h |
|
Back to top |
|
|
Purge Episode I > Eposide III Jar-Jar is kool
Age:34 Gender: Joined: Sep 08 2004 Posts: 2018 Offline
|
Posted: Sun Apr 06, 2008 8:19 pm Post subject: |
|
|
|
|
The bot only realizes the player won when he types in the command since that is the only place you are checking for a win. So you must check for a win in a player event in spawn.cpp like Player_Prize (I think). |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Sun Apr 06, 2008 11:05 pm Post subject: |
|
|
|
|
Quick suggestion for cleaner code:
if (get_tag(p,mission1)!=on)
{
sendPrivate(p,"You started an easy mission \"Bounty Hunter\" Type !abort:easy:1 anytime during the game to abort this mission");
set_tag(p, mission1, on);
}
else if (get_tag(p,mission1)==on)
sendPrivate(p,"You already started easy mission \"Bounty Hunter\" Type !abort:easy:1 to abort mission.");
} |
You defined the 'off' value, you might as well use it... and since you're doing the "else" part, you only need to get_tag once, since the tag only has 2 possible values.
if (get_tag(p,mission1)==off)
{
sendPrivate(p,"You started an easy mission \"Bounty Hunter\" Type !abort:easy:1 anytime during the game to abort this mission");
set_tag(p, mission1, on);
}
else
{
sendPrivate(p,"You already started easy mission \"Bounty Hunter\" Type !abort:easy:1 to abort mission.");
} |
And to fix your problem, you must do as Purge said. Typically, most of your plugin code should be in spawn.cpp, in the various events. The commands.cpp should only include stuff that are directly triggered by !commands, like turn on/off something, like you're doing with your mission. However, once the command is done, you have to rely on events to know what's going on.
You can also use global variables in spawn.cpp and command.cpp if you declare them in spawn.h, in the botInfo class declaration. |
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
Posted: Mon Apr 07, 2008 3:50 pm Post subject: |
|
|
|
|
ok thanks |
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
Posted: Mon Apr 07, 2008 5:40 pm Post subject: |
|
|
|
|
Also I am going to create a tag that deals with current time, and where would exactly i would put in spawn.ccp? ( i was guessing like playermove =\)
this is just kind of how it will look like
#include <ctime> // header
|
if (get_tag(p,0)==1)
{
time_t breaktime=time(0);
int freezetime = (int) breaktime;
if (breaktime==freezetime+300)
{
set_tag(p,0,0);
}
}
|
|
|
Back to top |
|
|
Bak ?ls -s 0 in
Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Mon Apr 07, 2008 11:22 pm Post subject: |
|
|
|
|
check how the get_tag function is done, it uses the same thing (except it's a while loop instead of a for loop).
Basically, "playerlist" is a linked list...
A linked list is made of "nodes"
Each node contains 3 important information:
A pointer to the previous node of the list
A pointer to the next node of the list (parse->next)
A pointer to the actual data (parse->item)
For example, in playerlist, the items are 'Player' structs.
So what that loop does, is initialize a pointer to the start of the list (playerlist->head). Once you've done what you wanted with that item, you advance to the next (parse = parse->next)
The stop condition of the loop is 'parse', which means as long as the pointer is not NULL, it will keep going. The last item of the list doesn't have any 'next' item, so at that point you will get the NULL value. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Mon Apr 07, 2008 11:24 pm Post subject: |
|
|
|
|
As for you EVENT_TICK question... there is only one EVENT_TICK event, however, you can have more than one countdowns going at once. By default, there are 4 countdowns set. Look in spawn.h you will find the initialization of them; looks like 'int countdown[4];' or something. You can put as many countdowns as you wish. You just have to adjust the code in the EVENT_TICK part. |
|
Back to top |
|
|
Bak ?ls -s 0 in
Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Tue Apr 08, 2008 12:40 am Post subject: |
|
|
|
|
why would you want more than one EVENT_TICK ?
I'd try to explain the for loop but samapico is pretty much right. It involves pointers and structures and templates, which aren't hard on their own but if you're trying to learn all of them at once it can be overwhelming. Suffice it to say there's a list of every Player* in the arena called playerlist, and that's how you go through it. |
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
Posted: Sun Apr 13, 2008 8:28 pm Post subject: |
|
|
|
|
wtf this doesnt compile right!
{
for (int i = 0; i < 4; ++i)
--countdown[i];
if (get_tag(p,breaktime)!=0)
{
int remainingtime = get_tag(p,breaktime);
set_tag(p,breaktime,remainingtime-1);
}
} | and get those errors 1>------ Build started: Project: default, Configuration: Debug Win32 ------
1>Compiling...
1>spawn.cpp
1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\src\player.cpp(108) : warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 9.0\vc\include\string.h(157) : see declaration of 'strncpy'
1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\src\player.cpp(109) : warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 9.0\vc\include\string.h(157) : see declaration of 'strncpy'
1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\spawn.cpp(11) : warning C4005: 'UNASSIGNED' : macro redefinition
1> c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\src\clientprot.h(14) : see previous definition of 'UNASSIGNED'
1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\spawn.cpp(59) : error C2065: 'p' : undeclared identifier
1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\spawn.cpp(61) : error C2065: 'p' : undeclared identifier
1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\spawn.cpp(62) : error C2065: 'p' : undeclared identifier
1>Build log was saved at "file://c:\Documents and Settings\Owner\Desktop\Programing\c++\DC missons\DCmissions\Debug\BuildLog.htm"
1>default - 3 error(s), 3 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
|
when i delete that code compiles just fine :\ |
|
Back to top |
|
|
Purge Episode I > Eposide III Jar-Jar is kool
Age:34 Gender: Joined: Sep 08 2004 Posts: 2018 Offline
|
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Sun Apr 13, 2008 11:16 pm Post subject: |
|
|
|
|
yeah... there is no 'p' in the EVENT_TICK part of the code. (C2065: 'p' : undeclared identifier) |
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
Posted: Mon Apr 14, 2008 3:54 pm Post subject: |
|
|
|
|
i declared that and still got same 3 errors also where could i find how to keep track of player kills? like bounty i know is p->bounty and there is EVENT player prize.. but is there a kill event? |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Mon Apr 14, 2008 5:16 pm Post subject: |
|
|
|
|
there is a death event... where there's a death, there's a kill.
And you can't just declare 'p' in EVENT_TICK... well you can, but it will be useless, you have to do what purge said, which is cycle through ALL the players every tick. |
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
|
Back to top |
|
|
|