basic nav height query

This commit is contained in:
Robin Appelman 2020-05-02 16:55:41 +02:00
commit 94d7095a06
5 changed files with 158 additions and 6 deletions

31
plugin/example.sp Normal file
View file

@ -0,0 +1,31 @@
#include <sourcenav>
new SourceNav:sourceNav = null;
public void OnPluginStart() {
new String:map[128];
GetCurrentMap(map, sizeof(map));
new String:nav[128];
Format(nav, sizeof(nav), "tf/maps/%s.nav", map);
PrintToServer("Loading %s", nav);
sourceNav = new SourceNav(nav);
RegServerCmd("sm_nav_query", Query, "Query the nav file at x/y point");
}
public Action:Query(args) {
new String:x_str[128];
GetCmdArg(1, x_str, sizeof(x_str));
new String:y_str[128];
GetCmdArg(2, y_str, sizeof(y_str));
float x = StringToFloat(x_str);
float y = StringToFloat(y_str);
PrintToServer("x: %f, y: %f", x, y);
float z = sourceNav.query(x, y, 0.0);
PrintToServer("Z: %f", z);
return Plugin_Handled;
}