User:Dutchmega/code: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
Add the following under <code>protected</code> in npc_antlion.h | Add the following under <code>protected</code> in npc_antlion.h | ||
< | <pre> | ||
virtual bool AllowedToIgnite( void ) { return true; } | virtual bool AllowedToIgnite( void ) { return true; } | ||
</ | </pre> | ||
Well, now the damh thing burns but it doesn't visually respond to it. You can use the drown-animation: | Well, now the damh thing burns but it doesn't visually respond to it. You can use the drown-animation: | ||
Add | Add the following piece of code to the top of the function GatherConditions(): | ||
< | <pre> | ||
if( IsOnFire() ) { | if( IsOnFire() ) { | ||
SetCondition( COND_ANTLION_IN_WATER ); | SetCondition( COND_ANTLION_IN_WATER ); | ||
} | } | ||
</ | </pre> | ||
== UTIL_LoadTexture == | |||
Very handy function, "stolen" from the [[Plan_of_Attack|Plan Of Attack]] source | |||
<pre> | |||
int UTIL_LoadTexture(const char *szFile) | |||
{ | |||
#ifdef CLIENT_DLL | |||
char szStr[256]; | |||
// try to pull it | |||
int iID = vgui::surface()->DrawGetTextureId(szFile); | |||
// did we get it? | |||
if(iID >= 0) | |||
return iID; | |||
// does the file exist? | |||
Q_snprintf(szStr, sizeof(szStr), "materials/%s.vmt", szFile); | |||
if(!vgui::filesystem()->FileExists(szStr)) | |||
{ | |||
DevMsg("UTIL_LoadTexture: texture %s does not exist!\n", szFile); | |||
return -1; | |||
} | |||
// create the new texture | |||
iID = vgui::surface()->CreateNewTextureID(); | |||
vgui::surface()->DrawSetTextureFile(iID, szFile, true, false); | |||
return iID; | |||
#else | |||
return -1; | |||
#endif | |||
} | |||
</pre> | |||
== Disallow players connecting to a serer with a different version == | |||
Add the file <code>version.h</code> to your game_shared and add it to both projects. Content: | |||
<pre>#define VERSION "0.01"</pre> | |||
Then add to <code>cdll_client_int.cpp</code>: | |||
<pre>static ConVar cl_version ( "cl_version", VERSION, FCVAR_USERINFO|FCVAR_CLIENTDLL, "The version of this mod" );</pre> | |||
Then open <code>GameInterface.cpp</code> and find the function <code>ClientConnect()</code> | |||
Replace the contents of that function with this: | |||
<pre> | |||
// DM: Get the version of the client and compare it with the server's version | |||
const char* version = engine->GetClientConVarValue( engine->IndexOfEdict( pEdict ), "cl_version" ); | |||
if (stricmp(VERSION, version) == 0) { | |||
return g_pGameRules->ClientConnected( pEdict, pszName, pszAddress, reject, maxrejectlen ); | |||
// Aka true | |||
} | |||
else { | |||
char string [256]; | |||
Q_snprintf( string, sizeof(string), "The server runs a different version (%s)", VERSION); | |||
Q_strcpy( reject, string ); | |||
maxrejectlen = strlen(string); | |||
return false; | |||
} | |||
</pre> | |||
Just don't forget to change the define everytime you release a new version | |||
Revision as of 13:26, 28 April 2006
Making the antlion burn!
Add the following under protected in npc_antlion.h
virtual bool AllowedToIgnite( void ) { return true; }
Well, now the damh thing burns but it doesn't visually respond to it. You can use the drown-animation: Add the following piece of code to the top of the function GatherConditions():
if( IsOnFire() ) {
SetCondition( COND_ANTLION_IN_WATER );
}
UTIL_LoadTexture
Very handy function, "stolen" from the Plan Of Attack source
int UTIL_LoadTexture(const char *szFile)
{
#ifdef CLIENT_DLL
char szStr[256];
// try to pull it
int iID = vgui::surface()->DrawGetTextureId(szFile);
// did we get it?
if(iID >= 0)
return iID;
// does the file exist?
Q_snprintf(szStr, sizeof(szStr), "materials/%s.vmt", szFile);
if(!vgui::filesystem()->FileExists(szStr))
{
DevMsg("UTIL_LoadTexture: texture %s does not exist!\n", szFile);
return -1;
}
// create the new texture
iID = vgui::surface()->CreateNewTextureID();
vgui::surface()->DrawSetTextureFile(iID, szFile, true, false);
return iID;
#else
return -1;
#endif
}
Disallow players connecting to a serer with a different version
Add the file version.h to your game_shared and add it to both projects. Content:
#define VERSION "0.01"
Then add to cdll_client_int.cpp:
static ConVar cl_version ( "cl_version", VERSION, FCVAR_USERINFO|FCVAR_CLIENTDLL, "The version of this mod" );
Then open GameInterface.cpp and find the function ClientConnect()
Replace the contents of that function with this:
// DM: Get the version of the client and compare it with the server's version
const char* version = engine->GetClientConVarValue( engine->IndexOfEdict( pEdict ), "cl_version" );
if (stricmp(VERSION, version) == 0) {
return g_pGameRules->ClientConnected( pEdict, pszName, pszAddress, reject, maxrejectlen );
// Aka true
}
else {
char string [256];
Q_snprintf( string, sizeof(string), "The server runs a different version (%s)", VERSION);
Q_strcpy( reject, string );
maxrejectlen = strlen(string);
return false;
}
Just don't forget to change the define everytime you release a new version