Hello.
Could someone help me editing this script, so it doesnt get only the origin of the player who used the command cup_nearestmarker, but it shows the nearest markers of the all alive players. Here are the code i think you will need to help me
Code:
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_concmd("cup_nearestmarker", FUNC_CMD_NEARESTMARKER, ADMIN_CUP_MARKERS, helpNearestCupMarker);
}
new const msgPrefix[] = "[KZ CUP]";
//new const msgNoMarkers[] = "% sUnable to start a cup. There are not enough cup markers.";
new const msgNoMarkersA[] = "%s There are no cup markers.";
new const msgSetMarker[] = "%s Set cup marker %d at position: %f, %f, %f";
new const msgRemovedMarker[] = "%s Removed cup marker #%d from position: %f, %f, %f";
new const msgNearestMarker[] = "Nearest marker: %d";
//////////////////////////////////////////////////
// cmd_markers_nearest( id )
//////////////////////////////////////////////////
/**
(admin cmd) Display the nearest marker.
Access Level: ADMIN_CUP_MARKERS
*/
public cmd_markers_nearest( id )
{
if (access(id, ADMIN_CUP_RACE))
{
new markernum = get_nearest_marker(id);
if (markernum > 0) // print nearest marker (if set)
{
client_print(id, print_chat, msgNearestMarker, msgPrefix, markernum);
} else {
client_print(id, print_chat, msgNoMarkersA, msgPrefix);
}
}
return PLUGIN_HANDLED;
}
//////////////////////////////////////////////////
// get_player_origin
//////////////////////////////////////////////////
/**
Get a client's origin; value is returned in origin[] parameter.
*/
get_player_origin( id, Float:origin[3] )
{
// get player's origin as a Float; move position down to floor
entity_get_vector( id, EV_VEC_origin, origin );
origin[2] -= 30;
// raise the origin position up if player is ducking
if (entity_get_int(id, EV_INT_flags) & FL_DUCKING)
{
origin[2] += 18;
}
}
//////////////////////////////////////////////////
// get_nearest_marker( id )
//////////////////////////////////////////////////
/**
Return the marker nearest to the client.
*/
get_nearest_marker( id )
{
new num = 0;
if (gMarkerCount > 0)
{
// get players origin
new Float:vOrigin[3];
entity_get_vector(id, EV_VEC_origin, vOrigin);
// create and set dist variable to distance to 1st marker pos
new Float:dist = 0.0;
new Float:nearest = vector_distance(vOrigin, gfMarkerPos[0]);
num = 1;
// loop through all marker positions looking for nearest marker
for (new i = 1; i < gMarkerCount; i++)
{
dist = vector_distance(vOrigin, gfMarkerPos[i]);
if (dist < nearest)
{
nearest = dist;
num = i + 1;
}
}
}
return num;
}
So when player uses command cup_nearestmarker it shows Player1 [marker number] player2 [markernumber] player3 [markernumber] etc.