Programming

Here you can get rid of your ideas for the map or the mod.

Programming

Postby medicine man » Saturday, 16. December 2017, 23:41:15

Place this in g_cmds.c
/*
*@ Cmd_currentTime_f
*/

Quelle Source : http://z4.invisionfree.com/ProgrammingAnDstuff/index.php?act=idx
extern int trap_RealTime ( qtime_t * qtime );
const char *aMonths[12] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
void Cmd_CurrentTime_f( gentity_t *ent ) {
qtime_t ct;
trap_RealTime(&ct);

trap_SendServerCommand(-1, va("chat \"%s^7: The current time is: ^3%02d:%02d:%02d (^7%02d %s %d^3) \n\"",
ent->client->pers.netname ,
ct.tm_hour,
ct.tm_min,
ct.tm_sec,
ct.tm_mday,
aMonths[ct.tm_mon],
1900+ct.tm_year ) );
}
Place this in g_local.h under g_cmds.c
void Cmd_CurrentTime_f( gentity_t *ent );

Place this in g_cmds.c void ClientCommand( int clientNum )
if (Q_stricmp (cmd, "time") == 0)
Cmd_CurrentTime_f (ent);

You need for windows the Microsoft Visual Studio 2005/2008/2010 or higher.
User avatar
medicine man
Administrator
 
Posts: 57
Joined: Wednesday, 14. May 2014, 09:05:03
Has thanked: 0 time
Have thanks: 0 time


Command cmdhelp

Postby medicine man » Friday, 29. December 2017, 22:03:25

this must be in g_local.h
void trycmdhelp (gentity_t *ent);

This section of code should be placed in g_cmds.c via void ClientCommand (int clientNum). Or you can write it in <your name.c>. Furthermore, you should to execute the command in void ClientCommand (int clientNum) place that.
else if (Q_stricmp (cmd, "cmdhelp") == 0 || Q_stricmp (cmd, "help") == 0 || Q_stricmp (cmd, "!?") == 0)
trycmdhelp (ent);

void trycmdhelp (gentity_t *ent){

int r = rand() % 3;
char cmd[MAX_TOKEN_CHARS];
FILE *f;
char s[1000];
char *contact;
trap_Argv( 0, cmd, sizeof( cmd ));
contact = "";

if (Q_stricmp(cmd, "cmdhelp") == 0 || Q_stricmp(cmd, "help") == 0 || Q_stricmp(cmd, "!?") == 0){
trap_SendServerCommand(ent-g_entities, va("print \"^0|--------------^7Available ^3S4NDMoD ULT7M4T3 Game-Commands:^0-------------|\n"));
trap_SendServerCommand(ent-g_entities, va("print \"^0|^7Allways put ^5/ ^7before command ^0|\n"));
trap_SendServerCommand(ent-g_entities, va("print \"^0|^1/^5<^1COMMAND^5> ^7Example for you ^1/^5cmdhelp ^0|\n"));
trap_SendServerCommand(ent-g_entities, va("print \"^0|--------------------------------------------------------------------|\n"));
f=S4ND_openf("cmd.txt","r");
if (r == 0){
contact = "@t MaxMusterMan@gmail.com";
trap_SendServerCommand(ent-g_entities, va("print \"^3No cmd.txt found Contact %s!\n",contact));
}else if (r == 1){
contact = "@t http://www.google.com";
trap_SendServerCommand(ent-g_entities, va("print \"^3No cmd.txt found Contact %s!\n",contact));
}else if (r == 2){
contact = "@t portal.php";
trap_SendServerCommand(ent-g_entities, va("print \"^3No cmd.txt found Contact %s!\n",contact));
}
else{
while (S4ND_fget(s,20,f)!=NULL){
trap_SendServerCommand(ent-g_entities, va("print\"^0|^3%s",s));
}
trap_SendServerCommand(ent-g_entities, va("print \"^0|^1Type: ^3?<Commandname> ^7?Help for more information^0|\n"));
trap_SendServerCommand(ent-g_entities, va("print \"^0|--------------------------------------------------------------------|\n"));
S4ND_closef(f);
}
return;
}
}

This Code is just a matter of copy and paste from qboolean ConsoleCommand( void )
in g_svcmd.c

/*
if (Q_stricmp(cmd, "bannedips") == 0){
f=fopen("banned.txt","r");
if (!f)
G_Printf("no banned.txt found\n");
else{
while (fgets(s,20,f)!=NULL){
G_Printf("%s",s);
}
fclose(f);
}
return qtrue;
}
*/
User avatar
medicine man
Administrator
 
Posts: 57
Joined: Wednesday, 14. May 2014, 09:05:03
Has thanked: 0 time
Have thanks: 0 time


Return to Mod's and Maps



cron