Skip to content

Commit

Permalink
feat(*): add gameserver priority param (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrappachc authored Nov 4, 2021
1 parent 9d1d67b commit 244b324
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion scripting/connector.sp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ConVar tf2pickupOrgApiAddress = null;
ConVar tf2pickupOrgSecret = null;
ConVar tf2pickupOrgVoiceChannelName = null;
ConVar tf2pickupOrgPriority = null;
Handle timer = null;

public Plugin myinfo =
Expand All @@ -27,6 +28,7 @@ public void OnPluginStart()
tf2pickupOrgSecret.AddChangeHook(OnApiAddressOrSecretChange);

tf2pickupOrgVoiceChannelName = CreateConVar("sm_tf2pickuporg_voice_channel_name", "", "gameserver voice channel name");
tf2pickupOrgPriority = CreateConVar("sm_tf2pickuporg_priority", "1", "gameserver priority", _, true, -9999.99, true, 9999.99);

RegServerCmd("sm_tf2pickuporg_heartbeat", CommandHeartbeat);
}
Expand Down Expand Up @@ -93,10 +95,13 @@ public Action HeartbeatGameServer(Handle timerHandle)
tf2pickupOrgVoiceChannelName.GetString(voiceChannelName, sizeof(voiceChannelName));
System2_URLEncode(voiceChannelName, sizeof(voiceChannelName), voiceChannelName);

int priority = tf2pickupOrgPriority.IntValue;

System2HTTPRequest request = new System2HTTPRequest(HeartbeatHttpCallback, "%s/game-servers/", apiAddress);
request.SetHeader("Authorization", "secret %s", secret);
request.SetHeader("Content-Type", "application/x-www-form-urlencoded");
request.SetData("address=%s&port=%s&name=%s&rconPassword=%s&voiceChannelName=%s", address, port, name, rconPassword, voiceChannelName);
request.SetData("address=%s&port=%s&name=%s&rconPassword=%s&voiceChannelName=%s&priority=%d",
address, port, name, rconPassword, voiceChannelName, priority);
request.SetUserAgent("tf2pickup.org connector plugin/%s", PLUGIN_VERSION);
request.POST();
delete request;
Expand Down

0 comments on commit 244b324

Please sign in to comment.