8 CS(player).active_minigame =
NULL;
9 player.minigame_players =
NULL;
20 entity p = minigame_session.minigame_players;
22 if ( p.minigame_players == player )
24 if ( p.list_next ==
NULL )
29 minigame_session.minigame_event(minigame_session,
"part",player);
31 ftos(
etof(player)),
":",player.netname));
32 minigame_session.minigame_players = p.list_next;
38 for ( e = p.list_next; e !=
NULL; e = e.list_next )
40 if ( e.minigame_players == player )
42 minigame_session.minigame_event(minigame_session,
"part",player);
44 ftos(
etof(player)),
":",player.netname));
45 p.list_next = e.list_next;
56 #define FIELD(Flags, Type,Name) if ( sf & (Flags) ) Write##Type(MSG_ENTITY, this.Name); 57 #define MSLE(Name,Fields) \ 58 else if ( this.classname == #Name ) { \ 59 if ( sf & MINIG_SF_CREATE ) WriteString(MSG_ENTITY,this.owner.netname); \ 66 WriteHeader(MSG_ENTITY, ENT_CLIENT_MINIGAME);
81 if ( sf & MINIG_SF_CREATE )
87 else if ( this.
classname ==
"minigame_player" )
89 if ( sf & MINIG_SF_CREATE )
99 minigame_ent.minigame_event(minigame_ent,
"network_send",
this,sf);
121 for ( e = this.
owner.minigame_players; e !=
NULL; e = e.list_next )
122 if ( e.minigame_players == client )
131 if (
CS(player).active_minigame == minigame_session )
135 entity player_pointer =
new(minigame_player);
136 int mgteam = minigame_session.minigame_event(minigame_session,
"join",player,player_pointer);
140 player_pointer.owner = minigame_session;
141 player_pointer.minigame_players = player;
142 player_pointer.team = mgteam;
143 player_pointer.list_next = minigame_session.minigame_players;
144 minigame_session.minigame_players = player_pointer;
145 CS(player).active_minigame = minigame_session;
146 player.minigame_players = player_pointer;
157 else {
delete(player_pointer); }
158 GameLogEcho(
strcat(
":minigame:join",(mgteam?
"":
"fail"),
":",minigame_session.netname,
":",
159 ftos(
etof(player)),
":",player.netname));
172 entity minig =
new(minigame);
174 minig.descriptor = e;
175 minig.minigame_event = e.minigame_event;
176 minig.minigame_event(minig,
"start");
180 LOG_TRACE(
"Minigame ",minig.netname,
" rejected the first player join!");
208 if ( minig.netname == game_id )
218 entity minig =
CS(player).active_minigame;
220 if ( minig && minig.classname ==
"minigame" )
226 if ( minigame_session.owner )
227 minigame_session.owner.list_next = minigame_session.list_next;
231 minigame_session.minigame_event(minigame_session,
"end");
237 if ( e.minigame_autoclean )
244 for ( e = minigame_session.minigame_players; e !=
NULL; e = p )
251 strfree(minigame_session.netname);
252 delete(minigame_session);
266 return "Invalid minigame";
268 return "Invalid player";
269 if ( inviter == player )
270 return "You can't invite yourself";
271 if (
CS(player).active_minigame ==
CS(inviter).active_minigame )
272 return strcat(player.netname,
" is already playing");
274 Send_Notification(NOTIF_ONE, player, MSG_INFO, INFO_MINIGAME_INVITE,
275 CS(inviter).active_minigame.netname, inviter.netname );
278 ftos(
etof(player)),
":",player.netname));
288 for ( e =
CS(client).active_minigame.minigame_players; e; e = e.list_next )
289 if ( e.minigame_players == client )
311 sprint(caller,
"Minigames are not enabled!\n");
317 string minig_cmd =
argv(1);
318 if ( minig_cmd ==
"create" && argc > 2 )
322 sprint(caller,
"Created minigame session: ",minig.netname,
"\n");
324 sprint(caller,
"Cannot start minigame session!\n");
327 else if ( minig_cmd ==
"join" && argc > 2 )
331 sprint(caller,
"Joined: ",minig.netname,
"\n");
334 Send_Notification(NOTIF_ONE, caller, MSG_CENTER, CENTER_JOIN_PREVENT_MINIGAME);
335 sprint(caller,
"Cannot join given minigame session!\n");
339 else if ( minig_cmd ==
"list" )
341 FOREACH(Minigames,
true,
sprint(caller, it.netname,
" (", it.message,
") ",
"\n"));
344 else if ( minig_cmd ==
"list-sessions" )
348 sprint(caller,e.netname,
"\n");
351 else if ( minig_cmd ==
"end" || minig_cmd ==
"part" )
356 sprint(caller,
"Left minigame session\n");
359 sprint(caller,
"You aren't playing any minigame...\n");
362 else if ( minig_cmd ==
"invite" && argc > 2 )
370 sprint(caller,
"You have invited ",client.netname,
371 " to join your game of ",
CS(caller).active_minigame.descriptor.message,
"\n");
374 sprint(caller,
"Could not invite: ", error,
".\n");
377 sprint(caller,
"You aren't playing any minigame...\n");
385 if (
CS(caller).active_minigame.minigame_event(
CS(caller).active_minigame,
"cmd",e,arg_c,subcommand) )
389 else sprint(caller,
strcat(
"Wrong command:^1 ",command,
"\n"));
392 sprint(caller,
"\nUsage:^3 cmd minigame create <minigame>\n");
393 sprint(caller,
" Start a new minigame session\n");
394 sprint(caller,
"Usage:^3 cmd minigame join <session>\n");
395 sprint(caller,
" Join an exising minigame session\n");
396 sprint(caller,
"Usage:^3 cmd minigame list\n");
397 sprint(caller,
" List available minigames\n");
398 sprint(caller,
"Usage:^3 cmd minigame list-sessions\n");
399 sprint(caller,
" List available minigames sessions\n");
400 sprint(caller,
"Usage:^3 cmd minigame part|end\n");
401 sprint(caller,
" Leave the current minigame\n");
402 sprint(caller,
"Usage:^3 cmd minigame invite <player>\n");
403 sprint(caller,
" Invite the given player to join you in a minigame\n");
void minigame_resend(entity minigame)
entity GetIndexedEntity(int argc, float start_index)
entity join_minigame(entity player, string game_id)
Join an existing minigame session.
ClientState CS(Client this)
void part_minigame(entity player)
int msle_id(string class_name)
float VerifyClientEntity(entity client, float must_be_real, float must_be_bots)
const int MINIG_SF_UPDATE
bool autocvar_sv_minigames_observer
#define IS_REAL_CLIENT(v)
Force the player to spectator team.
void ClientCommand_minigame(entity caller, int request, int argc, string command)
#define MINIGAME_SIMPLELINKED_ENTITIES
How to create a minigame
bool MinigameImpulse(entity this, int imp)
bool minigame_CheckSend(entity this, entity client)
void minigame_rmplayer(entity minigame_session, entity player)
entity minigame_players
For minigame sessions: list of players For minigame_player: client entity.
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
entity minigame_get_descriptor(string id)
void player_clear_minigame(entity player)
void Player_SetForcedTeamIndex(entity player, int team_index)
Sets the index of the forced team of the given player.
float MOVETYPE_FLY_WORLDONLY
void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint)
putting a client as observer in the server
const int CMD_REQUEST_COMMAND
bool autocvar_sv_minigames
void GameLogEcho(string s)
string invite_minigame(entity inviter, entity player)
Invite a player to join in a minigame.
const int MINIG_SF_CREATE
Don't force any team.
int minigame_addplayer(entity minigame_session, entity player)
entity start_minigame(entity player, string minigame)
Create a new minigame session.
bool minigame_SendEntity(entity this, entity to, int sf)
entity descriptor
For minigame sessions: minigame descriptor object.
entity minigame_find_player(entity client)
#define FOREACH(list, cond, body)
void set_movetype(entity this, int mt)
void end_minigame(entity minigame_session)