Rectangular Room Max/Min Calculator

For scripting examples for learning how to use AMXX.
User avatar
Archive-Poster
Posts: 1229
Gender:
United States of America

Rectangular Room Max/Min Calculator

Post by Archive-Poster »

This is a PHP script that simply calcuates the Max's and Min's of a rectangular room. It's for lazy people like myself. The algorithm is ridiculously simple. You may find it useful, though.

Note: I didn't add error checking, so, if you make any mistakes, it's on you.

Example usage in an AMXX plugin:

Code: Select all

#include <amxmodx>
#include <fakemeta>

public plugin_init()
{
    register_plugin( "Max/Min Usage Example" , "1.0" , "v3x" )

    register_clcmd( "say /test" , "ClCmd_SayTest" )
}

new Float:g_fMaxs[3] = { -279.0 , -635.0 , -78.0 }
new Float:g_fMins[3] = { -728.0 , -1005.0 , -174.0 }

public ClCmd_SayTest( id )
{
    if( !is_user_alive( id ) )
        return PLUGIN_CONTINUE

    new Float:fOrigin[3]
    pev( id , pev_origin , fOrigin )

    if(
    fOrigin[0] <= g_fMaxs[0] &&
    fOrigin[1] <= g_fMaxs[1] &&    
    fOrigin[2] <= g_fMaxs[2] &&
    fOrigin[0] >= g_fMins[0] &&
    fOrigin[1] >= g_fMins[1] &&
    fOrigin[2] >= g_fMins[2] )
    {
        client_print( id , print_chat , "You are within the rectangle" )
    }
    else
    {
        client_print( id , print_chat , "You are not within the rectangle" )
    }

    return PLUGIN_CONTINUE
} 
Attachments
max_min_example.sma.zip
(607 Bytes) Downloaded 16 times

Who is online

Users browsing this forum: No registered users and 1 guest