Phasor  01.00.10.059
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces | Functions
PhasorAPI

All functions Phasor provides are described here. More...

Namespaces

namespace  halo
 
namespace  odl
 

Functions

void l_alias_search (PHASOR_API_ARGS)
 Executes sv_alias_search and provides a callback for returning results.
 
void l_alias_hash (PHASOR_API_ARGS)
 Executes sv_alias_hash and provides a callback for returning results.
 
void odl::setData (halo::damage_script_options *opts_, halo::s_damage_info *dmg, const halo::ident &receiver)
 
void odl::reset ()
 
void l_odl_causer (PHASOR_API_ARGS)
 Sets the casuer of the damage to the specified object.
 
void l_odl_receiver (PHASOR_API_ARGS)
 Sets the receiver of the damage to the specified object.
 
void l_odl_tag (PHASOR_API_ARGS)
 Can be used to change the type of damage which is being applied.
 
void l_odl_multiplier (PHASOR_API_ARGS)
 Can be used to change the amount of damage being done.
 
void l_odl_flags (PHASOR_API_ARGS)
 Read/Write data to the flags used in damage lookup.
 
void l_getobject (PHASOR_API_ARGS)
 Get the memory address for the specified object.
 
void l_getobjectcoords (PHASOR_API_ARGS)
 Get the specified object's location in the map.
 
void l_objectaddrtoplayer (PHASOR_API_ARGS)
 Find which player the specified memory address belongs to.
 
void l_objectidtoplayer (PHASOR_API_ARGS)
 Find which player the specified object id belongs to.
 
void l_createobject (PHASOR_API_ARGS)
 Creates an ingame object.
 
void l_destroyobject (PHASOR_API_ARGS)
 Destroys the specified objects.
 
void l_assignweapon (PHASOR_API_ARGS)
 Gives and equips the specified weapon to the specified player.
 
void l_entervehicle (PHASOR_API_ARGS)
 Forces the specified player into the specified vehicle.
 
void l_isinvehicle (PHASOR_API_ARGS)
 Checks whether the specified player is in a vehicle.
 
void l_exitvehicle (PHASOR_API_ARGS)
 Forces the specified player to leave their current vehicle.
 
void l_movobjectcoords (PHASOR_API_ARGS)
 Moves the specified object to the specified coordinates.
 
void l_gettagid (PHASOR_API_ARGS)
 Gets the map id of the specified tag.
 
void l_gettaginfo (PHASOR_API_ARGS)
 Gets the tag type and tag name of the specified tag (map) id.
 
void l_gettagaddress (PHASOR_API_ARGS)
 Gets the specified tag's memory address.
 
void l_applydmg (PHASOR_API_ARGS)
 Applies damage to the specified object.
 
void l_applydmgtag (PHASOR_API_ARGS)
 Applies a damage tag to the specified object.
 
void l_halointersect (PHASOR_API_ARGS)
 Checks if the specified vector intersects anything.
 
void l_readbit (PHASOR_API_ARGS)
 Reads a bit from the specified memory address.
 
void l_readbyte (PHASOR_API_ARGS)
 Reads a byte from the specified memory address.
 
void l_readchar (PHASOR_API_ARGS)
 Reads a char from the specified memory address.
 
void l_readword (PHASOR_API_ARGS)
 Reads a word from the specified memory address.
 
void l_readshort (PHASOR_API_ARGS)
 Reads a short from the specified memory address.
 
void l_readdword (PHASOR_API_ARGS)
 Reads a dword from the specified memory address.
 
void l_readint (PHASOR_API_ARGS)
 Reads an int from the specified memory address.
 
void l_readfloat (PHASOR_API_ARGS)
 Reads a float from the specified memory address.
 
void l_readdouble (PHASOR_API_ARGS)
 Reads a double from the specified memory address.
 
void l_readstring (PHASOR_API_ARGS)
 Reads a string from the specified memory address.
 
void l_readwidestring (PHASOR_API_ARGS)
 Reads a wide string from the specified memory address.
 
void l_writebit (PHASOR_API_ARGS)
 Writes a bit to the specified memory address.
 
void l_writebyte (PHASOR_API_ARGS)
 Writes a byte to the specified memory address.
 
void l_writechar (PHASOR_API_ARGS)
 Writes a char to the specified memory address.
 
void l_writeword (PHASOR_API_ARGS)
 Writes a word to the specified memory address.
 
void l_writeshort (PHASOR_API_ARGS)
 Writes a short to the specified memory address.
 
void l_writedword (PHASOR_API_ARGS)
 Writes a dword to the specified memory address.
 
void l_writeint (PHASOR_API_ARGS)
 Writes an int to the specified memory address.
 
void l_writefloat (PHASOR_API_ARGS)
 Writes a float to the specified memory address.
 
void l_writedouble (PHASOR_API_ARGS)
 Writes a double to the specified memory address.
 
void l_writestring (PHASOR_API_ARGS)
 Writes a string to the specified memory address.
 
void l_writewidestring (PHASOR_API_ARGS)
 Writes a wide string to the specified memory address.
 
void l_getticks (PHASOR_API_ARGS)
 Get the current cpu ticks.
 
void l_getrandomnumber (PHASOR_API_ARGS)
 Generate a random number in the given range.
 
void l_changeteam (PHASOR_API_ARGS)
 Changes the specified player's team.
 
void l_kill (PHASOR_API_ARGS)
 Kill the specified player.
 
void l_applycamo (PHASOR_API_ARGS)
 Gives the specified player active camo for a specified duration.
 
void l_svcmd (PHASOR_API_ARGS)
 Executes a server command.
 
void l_svcmdplayer (PHASOR_API_ARGS)
 Executes a server command as the specified player.
 
void l_updateammo (PHASOR_API_ARGS)
 Forcibly sync the specified weapon's ammo counts.
 
void l_setammo (PHASOR_API_ARGS)
 Set a weapon's ammo and forcibly sync.
 
void l_setspeed (PHASOR_API_ARGS)
 Set the specified player's speed.
 
void l_getprofilepath (PHASOR_API_ARGS)
 Gets halo's data directory (where banned.txt is stored)
 
void l_getservername (PHASOR_API_ARGS)
 Gets the server's current name.
 
void l_hprintf (PHASOR_API_ARGS)
 Outputs a string to the server console.
 
void l_say (PHASOR_API_ARGS)
 Sends a chat message to the entire server.
 
void l_privatesay (PHASOR_API_ARGS)
 Sends a chat message to the specified player.
 
void l_sendconsoletext (PHASOR_API_ARGS)
 Sends the specified player a console message.
 
void l_respond (PHASOR_API_ARGS)
 Responds to the person executing the current command.
 
void l_log_msg (PHASOR_API_ARGS)
 Sends output to the specified logging stream.
 
void l_resolveplayer (PHASOR_API_ARGS)
 Resolve a player's memory id to their rcon id.
 
void l_rresolveplayer (PHASOR_API_ARGS)
 Resolve a player's rcon id to their memory id.
 
void l_getplayer (PHASOR_API_ARGS)
 Get the specified player's memory data.
 
void l_getip (PHASOR_API_ARGS)
 Get the specified player's ip address.
 
void l_getport (PHASOR_API_ARGS)
 Get the specified player's network port.
 
void l_getteam (PHASOR_API_ARGS)
 Get the specified player's team.
 
void l_getname (PHASOR_API_ARGS)
 Get the specified player's name.
 
void l_gethash (PHASOR_API_ARGS)
 Get the specified player's hash.
 
void l_getteamsize (PHASOR_API_ARGS)
 Get the number of players on the specified team.
 
void l_getplayerobjectid (PHASOR_API_ARGS)
 Get the specified player's object id.
 
void l_isadmin (PHASOR_API_ARGS)
 Checks if the specified player is an admin.
 
void l_getadminlvl (PHASOR_API_ARGS)
 Returns the admins level, or nil if not an admin.
 
void l_setadmin (PHASOR_API_ARGS)
 Sets the specified player as an admin for the duration of the current game, or until the player leaves.
 
void l_raiseerror (PHASOR_API_ARGS)
 Raises an error to Phasor's scripting subsystem.
 
void l_registertimer (PHASOR_API_ARGS)
 Registers a timer which is called when it expires.
 
void l_removetimer (PHASOR_API_ARGS)
 Removes a currently registered timer.
 
void l_tokenizestring (PHASOR_API_ARGS)
 Tokenizes (splits) an input string at specified delimiters.
 
void l_tokenizecmdstring (PHASOR_API_ARGS)
 Tokenizes (splits) an input string into distinct words, which are either separated by a space or enclosed in " ".
 

Detailed Description

All functions Phasor provides are described here.

Ignore the l_ infront of function names, that's just how I name them within my code. You don't use that when calling the functions.

CHANGES:

Note: When I say "raise an error" it means that an error will be raised, and this error will be treated in the same way as other Lua errors. The calling function will get blacklisted.

Deprecated (removed) functions:

Changed functions:

Further

For more detailed information about the changes to specific groups of functions you should see Files/PhasorAPI and view the relevant file:

alias_script.h haloobjects.h memory.h misc.h misc_halo.h output.h playerinfo.h scripttimers.h string.h

Function Documentation

void l_alias_hash ( PHASOR_API_ARGS  )

Executes sv_alias_hash and provides a callback for returning results.

Parameters
hashThe hash to search for.
callbackThe name of a function to call when results are ready.
Returns
Boolean indicating if the query can be executed.

Example usage:

function alias_callback(results)
for hash, names in pairs(results) do
for k, name in pairs(names) do
hprintf(hash .. " " .. name)
end
end
end
-- search for all names matching the hash
alias_hash("put some hash here", "alias_callback")
void l_alias_search ( PHASOR_API_ARGS  )

Executes sv_alias_search and provides a callback for returning results.

Parameters
queryThe player to search for, see sv_alias_search for details.
callbackThe name of a function to call when results are ready.
Returns
Boolean indicating if the query can be executed.

Example usage:

function alias_hash_callback(results)
for hash, names in pairs(results) do
for k, name in pairs(names) do
hprintf(hash .. " " .. name)
end
end
end
-- search for all names starting with New
alias_search("New%", "alias_hash_callback")
void l_applycamo ( PHASOR_API_ARGS  )

Gives the specified player active camo for a specified duration.

Parameters
playerThe player's memory id
durationDuration of the camo, in seconds.

Example usage:

applycamo(player, 30) -- invis for 30 seconds
void l_applydmg ( PHASOR_API_ARGS  )

Applies damage to the specified object.

Parameters
receiverobject id of the object which will receive the damage.
multiplierreal number indicating how much damage to apply.
[causer]object id of the object to attribute the damage to.
[flags]damage flags to use (see odl_flags)
Remarks
flags is a bitfield, the same as described in odl_flags. However, applydmg requires the actual flags value - you don't set each bit, like in odl_flags. So, to calculate the actual value use the following eqn: local flags = 2^0 + 2^2 + 2^5 That will activate bits 0, 2 and 5, which indicates vehicle hits, instant kill and ignore shields.

Example usage:

-- damage player 0, give credit to player 1 and ignore shields
applydmg(getplayerobjectid(0), 2.0, getplayerobjectid(1), 4)
void l_applydmgtag ( PHASOR_API_ARGS  )

Applies a damage tag to the specified object.

Parameters
receiverobject id of the object which will receive the damage.
dmg_tagtag id of the damage tag to apply.
[multiplier]real number indicating the damage multiplier (default 1.0)
[causer]object id of the object to attribute the damage to.
[flags]damage flags to use (see odl_flags)
Remarks
You cannot set the hit location (might add this later). I think it will default to a body shot.

Example usage:

-- apply a pistol shot to player 0
local pistol_dmg_id = gettagid("jpt!", "weapons\\pistol\\bullet")
applydmgtag(getplayerobjectid(0), pistol_dmg_id)
void l_assignweapon ( PHASOR_API_ARGS  )

Gives and equips the specified weapon to the specified player.

Parameters
playerThe player to assign the weapon to.
weapIdThe id of the weapon to assign.
Returns
Boolean indicating whether or not the assignment was successful.

Example usage:

assignweapon(player, weaponid)
void l_changeteam ( PHASOR_API_ARGS  )

Changes the specified player's team.

Parameters
playerThe player's memory id.
forcekillBoolean indicating whether or not to kill the player.
[team]The player's new team (optional)

Example usage:

changeteam(player, true)
Remarks
If you don't specify the player's new team, their new team is the logical NOT of their current team. ie red -> blue, blue -> red.
void l_createobject ( PHASOR_API_ARGS  )

Creates an ingame object.

Parameters
tag_idThe id of the tag describing the object to create.
parentIdThe object id to assign as the new one's parent.
respawnTimeNumber of seconds to wait before respawning the object.
do_respawnBoolean indicating whether or not the object should respawn.
xThe object's x coordinate.
yThe object's y coordinate.
zThe object's z coordinate.
Returns
The created object's id or nil on failure.
Remarks
  • If you don't what a parent, set parentId to 0. You won't care about this most of the time.
  • do_respawn indicates whether or not the object should respawn (go to spawn coordinates) or whether it should be destroyed.
  • do_respawn is ignored when creating equipment or weapons. They are always destroyed.

Example usage:

function OnNewGame(map)
assault_rifle_id = LookupTag("weap", "weapons\\assault rifle\\assault rifle")
end
... (somewhere else in the code) ...
objid = createobject(assault_rifle_id, 0, 10, false, 1,2,3)
if (objid == nil) then hprintf("failed to make object") end
void l_destroyobject ( PHASOR_API_ARGS  )

Destroys the specified objects.

Parameters
objidThe id of the object to destroy.
Remarks
if objid is not a valid object id, an error is raised.

Example usage:

destroyobject(objid)
void l_entervehicle ( PHASOR_API_ARGS  )

Forces the specified player into the specified vehicle.

Parameters
playerThe player to make enter the vehicle.
vehicleidThe object id of the vehicle the player is to enter.
seatThe seat the player should enter.
Remarks
Possible seat values:
  • 0 Driver
  • 1 Passenger
  • 2 Gunner

Example usage:

entervehicle(player, vehicleid, 0)
void l_exitvehicle ( PHASOR_API_ARGS  )

Forces the specified player to leave their current vehicle.

Parameters
playerThe player to eject from their vehicle.

Example usage:

exitvehicle(player)
void l_getadminlvl ( PHASOR_API_ARGS  )

Returns the admins level, or nil if not an admin.

Parameters
playerThe player's memory id.
Returns
integer representing the player's level, or nil if not admin.

Example usage:

local admin_lvl = getadminlvl(0)
if (admin_lvl ~= nil) then
hprintf("{0} is admin at level " .. admin_lvl)
end
void l_gethash ( PHASOR_API_ARGS  )

Get the specified player's hash.

Parameters
playerThe player's memory id.
Returns
The player's hash.

Example usage:

local hash = gethash(player)
void l_getip ( PHASOR_API_ARGS  )

Get the specified player's ip address.

Parameters
playerThe player's memory id.
Returns
The player's ip address

Example usage:

local ip = getip(3)
void l_getname ( PHASOR_API_ARGS  )

Get the specified player's name.

Parameters
playerThe player's memory id.

Example usage:

local name = getname(0)
void l_getobject ( PHASOR_API_ARGS  )

Get the memory address for the specified object.

Parameters
object_idThe object's id
Returns
The objects memory id, or nil if the specified id is invalid.

Example usage:

local m_object = getobject(object_id)
if (m_object ~= nil) then
-- object is valid
end
void l_getobjectcoords ( PHASOR_API_ARGS  )

Get the specified object's location in the map.

Parameters
object_idThe object's id
Returns
x,y,z The object's x, y and z coordinates.

Example usage:

local x,y,z = getobjectcoords(object_id)
void l_getplayer ( PHASOR_API_ARGS  )

Get the specified player's memory data.

Parameters
playerThe player's memory id.
Returns
The address of the player's memory info

Example usage:

local m_player = getplayer(0)
void l_getplayerobjectid ( PHASOR_API_ARGS  )

Get the specified player's object id.

Parameters
playerThe player's memory id.
Returns
The player's object id or nil if they are dead.

Example usage:

local player_obj_id = getplayerobjectid(0) -- get player 0's object id
Remarks
If the player is currently dead, nil is returned.
void l_getport ( PHASOR_API_ARGS  )

Get the specified player's network port.

Parameters
playerThe player's memory id.
Returns
The player's network port

Example usage:

local ip = getip(0)
local port = getport(0)
hprintf("Player with ip:port " .. ip .. ":" .. port)

Example output:

Player with ip:port 127.0.0.1:2302
void l_getprofilepath ( PHASOR_API_ARGS  )

Gets halo's data directory (where banned.txt is stored)

Returns
The profile directory

Example usage:

local profilepath = getprofilepath()
void l_getrandomnumber ( PHASOR_API_ARGS  )

Generate a random number in the given range.

Parameters
minThe minimum value to generate (inclusive)
maxThe maximum value to generate (exclusive)
Returns
The number generated

Example usage:

local ticks = getrandomnumber(0, 10) -- between 0 and 10
void l_getservername ( PHASOR_API_ARGS  )

Gets the server's current name.

Returns
The server's name

Exampe usage:

local servername = getservername()
hprintf(servername)
void l_gettagaddress ( PHASOR_API_ARGS  )

Gets the specified tag's memory address.

Parameters
tagidThe id of the tag whose address is to be found.
Returns
The tag's memory address
Remarks
This is similar to lookuptag which has been deprecated.

Example usage:

local tag_data = gettagaddress(ar_tag_id)
void l_gettagid ( PHASOR_API_ARGS  )

Gets the map id of the specified tag.

Parameters
tagTypeThe type of the tag
tagNameThe name of the tag
Returns
The tag's map id or nil if not found.
Remarks
You should lookup all tags (via this function) in OnNewGame and store the results globally. Looking up tags based on their name is slow.

Example usage:

function OnNewGame(map)
global ar_tag_id = gettagid("weap", "weapons\\assault rifle\\assault rifle")
end
void l_gettaginfo ( PHASOR_API_ARGS  )

Gets the tag type and tag name of the specified tag (map) id.

Parameters
tagidThe tag id to lookup.
Returns
tag_name, tag_type
Remarks
You shouldn't compare tag names, look up the ones you want in OnNewGame

Example usage:

local tag_name, tag_type = gettaginfo(some_tag_id)
void l_getteam ( PHASOR_API_ARGS  )

Get the specified player's team.

Parameters
playerThe player's memory id.
Returns
The player's current team.

Example usage:

local team = getteam(5)
void l_getteamsize ( PHASOR_API_ARGS  )

Get the number of players on the specified team.

Parameters
teamThe team to check (0 - red, 1 - blue)
Returns
The number of players on the specified team

Example usage:

local redsize = getteamsize(0) -- get size of red team
local bluesize = getteamsize(1) -- get size of blue team
void l_getticks ( PHASOR_API_ARGS  )

Get the current cpu ticks.

Returns
The current cpu ticks

Example usage:

local ticks = gettick()
void l_halointersect ( PHASOR_API_ARGS  )

Checks if the specified vector intersects anything.

Parameters
distthe direction vector is multiplied by this value, the intersection test stops after the result of this product.
xx coordinate for start of ray.
yy coordinate for start of ray.
zz coordinate for start of ray.
vxx direction for ray.
vyy direction for ray.
vzz direction for ray.
[objid]id of object to ignore during collision tests
Returns
hit,x,y,z,obj
Remarks
If you are firing a ray from a player's perspective, you should supply the optional argument objid as the player's object id. This will ensure they are ignored from collision tests, and the ray will not intersect with them (otherwise it will be trapped in their head).
hit is set if the ray intersects with something (wall, obj etc)
x,, is the hit location.
obj is the object id of the first object hit, or nil if none.

Example usage:

local player_objid = getplayerobjectid(player)
if (player_objid ~= nil) then
local m_object = getobject(player_objid)
local vx = readfloat(m_object + 0x230)
local vy = readfloat(m_object + 0x234)
local vz = readfloat(m_object + 0x238)
local px, py, pz = getobjectcoords(player_objid)
-- We want to fire the ray from the player's head
-- So we need to find the standing/crouch height for the map
-- You should move this little bit of code into OnNewGame and
-- save the values.
local bipd_id = readdword(m_object)
local bipd_tag = gettagaddress(bipd_id)
local bipd_data = readdword(bipd_tag + 0x14)
local standing_height = readfloat(bipd_data + 0x400)
local crouch_height = readfloat(bipd_data + 0x404)
local crouch_state = readfloat(m_object + 0x50c)
if (crouch_state == 0) then pz = pz + standing_height
else pz = pz + (crouch_height * crouch_state) end
local hit,x,y,z,objid = halointersect(1000, px, py, pz, vx, vy, vz, player_objid)
if (hit == true) then
hprintf(string.format("The hit location is (%.2f, %.2f, %.2f)", x,y,z))
if (objid ~= nil) then
hprintf(string.format("The player is looking at object %08X", objid))
end
else
hprintf("no hit")
end
end
void l_hprintf ( PHASOR_API_ARGS  )

Outputs a string to the server console.

Parameters
strThe string to print.

Example usage:

hprintf("This will be printed to the console.")
void l_isadmin ( PHASOR_API_ARGS  )

Checks if the specified player is an admin.

Parameters
playerThe player's memory id.
Returns
boolean indicating whether or not the player is an admin.

Example usage:

local is_player_admin = isadmin(0)
void l_isinvehicle ( PHASOR_API_ARGS  )

Checks whether the specified player is in a vehicle.

Parameters
playerThe player to check.
Returns
Boolean indicating whether or not the player is in a vehicle.

Example usage:

local in_vehicle = isinvehicle(player)
if (in_vehicle) then hprintf("in vehicle")
else hprintf("not in vehicle")
end
void l_kill ( PHASOR_API_ARGS  )

Kill the specified player.

Parameters
playerThe player's memory id.

Example usage:

kill(player)
void l_log_msg ( PHASOR_API_ARGS  )

Sends output to the specified logging stream.

Parameters
idThe id of the logging stream to write to.
strThe message to log.

Valid log ids are as follows:

1 - Game log
2 - Phasor log
3 - Rcon log
4 - Script log

Example usage:

log_msg(1, "{4} won the game!")

The above example will output "<name of player 4> won the game!" to the game log. If player 4 is called Oxide then "Oxide won the game" would be saved.

void l_movobjectcoords ( PHASOR_API_ARGS  )

Moves the specified object to the specified coordinates.

Parameters
objidThe id of the object to move.
xThe x coordinate to move the object to.
yThe y coordinate to move the object to.
zThe z coordinate to move the object to.
Remarks
This function will also reset the object's flags to indicate that it is not stationary. This causes gravity to work as expected. If this is no the behaviour you want, then do writebit(m_obj + 0x10, 5, 1)

Example usage:

local playerobjid = getplayerobjectid(player)
if (playerobjid ~= nil) then
movobjectcoords(playerobjid, 5, 10, 15)
end
void l_objectaddrtoplayer ( PHASOR_API_ARGS  )

Find which player the specified memory address belongs to.

Parameters
m_objectThe object's memory address
Returns
memory_id The player's memory id, or nil if not found.

Example usage:

local player = objectaddrtoplayer(m_object)
if (player ~= nil) then
hprintf("object belongs to " .. player)
end
Remarks
This only works for player objects, not objects created by the player, ie bullets.
void l_objectidtoplayer ( PHASOR_API_ARGS  )

Find which player the specified object id belongs to.

Parameters
m_objectIdThe object's id
Returns
memory_id The player's memory id, or nil if not found.

Example usage:

local player = objectidtoplayer(objid)
if (player ~= nil) then
hprintf("object belongs to " .. player)
end
Remarks
This only works for player objects, not objects created by the player, ie bullets.
void l_odl_causer ( PHASOR_API_ARGS  )

Sets the casuer of the damage to the specified object.

Parameters
idobject id to attribute damage to. Can be 0xFFFFFFFF to specify that no object is causing the damage.

Example usage:

odl_causer(getplayerobjectid(0))
void l_odl_flags ( PHASOR_API_ARGS  )

Read/Write data to the flags used in damage lookup.

Parameters
bit_offsetThe offset (starting at 0) to access.
[new_value]The new value for the specified bit.
Returns
The value of the bit, if new_value is not specified, or nil otherwise.
Remarks
Here are some bit offsets I found:
0 - Hits on player's vehicle don't do damage, only player hits do.
2 - Instant kill.
5 - Ignore shields.

Example usage:

local instant_kill = odl_flags(2)
-- or alternatively, to set it...
odl_flags(2, 1)
void l_odl_multiplier ( PHASOR_API_ARGS  )

Can be used to change the amount of damage being done.

Parameters
dmgA real number representing the damage multiplier.
Remarks
To block damage return false in OnDamageLookup, don't use a modifier of 0.

Example usage:

odl_multiplier(10.0)
void l_odl_receiver ( PHASOR_API_ARGS  )

Sets the receiver of the damage to the specified object.

Parameters
idobject id to attribute damage to.

Example usage:

odl_receiver(getplayerobjectid(1))
void l_odl_tag ( PHASOR_API_ARGS  )

Can be used to change the type of damage which is being applied.

Parameters
idobject id of the damage tag to apply.
Remarks
Will raise an error if id is not a damage (jpt!) tag.

Example usage:

odl_tag(gettagid("jpt!", "globals\\falling"))
void l_privatesay ( PHASOR_API_ARGS  )

Sends a chat message to the specified player.

Parameters
player_idThe memory id of the player to message.
strThe message to send.
[prepend]boolean indicating whether or not to prepend ** SERVER ** (default true)

Example usage:

privatesay(1, "Hello") -- message player with id 1
privatesay(1, "Hello", false) -- don't include ** SERVER **
void l_raiseerror ( PHASOR_API_ARGS  )

Raises an error to Phasor's scripting subsystem.

Parameters
descA string describing the error you are raising.
Remarks
This function doesn't return and the script function that calls it will be considered in-error. It produces equivalent behaviour to any other scripting errors.

Example usage:

function OnScriptLoad(processid, game, persistent)
if (persistent == true) then
raiseerror("this script doesn't support persistance.")
end
end
void l_readbit ( PHASOR_API_ARGS  )

Reads a bit from the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
bit_offsetWhich bit to read (starting at 0)
Returns
The specified bit (ie 1 or 0)

Example usage:

local b = readbit(0x12345678, 3, 2) -- read the 3rd bit at 0x12345678 + 3
local b = readbit(0x12345678, 2) -- read the 3rd bit at 0x12345678
void l_readbyte ( PHASOR_API_ARGS  )

Reads a byte from the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
Returns
The byte read.

Example usage:

local b = readbyte(0x12345678, 3) -- read the byte at 0x12345678 + 3
local b = readbyte(0x12345678) -- read the byte at 0x12345678
void l_readchar ( PHASOR_API_ARGS  )

Reads a char from the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
Returns
The char read.

Example usage:

local b = readchar(0x12345678, 3) -- read the char at 0x12345678 + 3
local b = readchar(0x12345678) -- read the char at 0x12345678
void l_readdouble ( PHASOR_API_ARGS  )

Reads a double from the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
Returns
The double read

Example usage:

local b = readdouble(0x12345678, 3) -- read the double at 0x12345678 + 3
local b = readdouble(0x12345678) -- read the double at 0x12345678
void l_readdword ( PHASOR_API_ARGS  )

Reads a dword from the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
Returns
The dword read

Example usage:

local b = readdword(0x12345678, 3) -- read the dword at 0x12345678 + 3
local b = readdword(0x12345678) -- read the dword at 0x12345678
void l_readfloat ( PHASOR_API_ARGS  )

Reads a float from the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
Returns
The word read

Example usage:

local b = readfloat(0x12345678, 3) -- read the float at 0x12345678 + 3
local b = readfloat(0x12345678) -- read the float at 0x12345678
void l_readint ( PHASOR_API_ARGS  )

Reads an int from the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
Returns
The integer read

Example usage:

local b = readint(0x12345678, 3) -- read the int at 0x12345678 + 3
local b = readint(0x12345678) -- read the int at 0x12345678
void l_readshort ( PHASOR_API_ARGS  )

Reads a short from the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
Returns
The short read

Example usage:

local b = readshort(0x12345678, 3) -- read the short at 0x12345678 + 3
local b = readshort(0x12345678) -- read the short at 0x12345678
void l_readstring ( PHASOR_API_ARGS  )

Reads a string from the specified memory address.

Parameters
addressThe memory address to read from.
[length]The number of characters to read.
void l_readwidestring ( PHASOR_API_ARGS  )

Reads a wide string from the specified memory address.

Parameters
addressThe memory address to read from.
[length]The number of wide characters to read.
Remarks
A wide string is one where each character is two bytes wide. Lua can't handle wide strings so Phasor will convert to a narrow string before returning.
void l_readword ( PHASOR_API_ARGS  )

Reads a word from the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
Returns
The word read

Example usage:

local b = readword(0x12345678, 3) -- read the word at 0x12345678 + 3
local b = readword(0x12345678) -- read the word at 0x12345678
void l_registertimer ( PHASOR_API_ARGS  )

Registers a timer which is called when it expires.

Parameters
delayThe delay (in milliseconds) to wait before calling callback.
callbackA string representing the function to call once the delay expires.
[userdata]A variable you want passed to the callback.
Returns
The created timer's id, which can be used in removetimer
Remarks
  • registertimer works slightly differently that it did before. You can only specify one userdata value, however tables are supported.
  • The callback function always receives three parameters: id, call_count and userdata. id is the timer's id (same value registertimer returns), call_count is the number of times this timer has been called (starting at 1) and userdata is the value passed to registertimer.
  • The callback should return true if you want to renew the timer.

Example usage:

registertimer(1000, "MyTimerCallback", {"hello", 1, 2,3})
function MyTimerCallback(id, call_count, userdata)
hprintf(userdata[1])
return true -- renew the timer
end
void l_removetimer ( PHASOR_API_ARGS  )

Removes a currently registered timer.

Parameters
idThe id of the timer to remove.
Remarks
  • id can be invalid, in which case the call is ignored (no errors are raised)
  • If you want to remove a timer from its callback, return false. Don't use removetimer.

Example usage:

removetimer(timer_id)
void l_resolveplayer ( PHASOR_API_ARGS  )

Resolve a player's memory id to their rcon id.

Parameters
playerThe memory id of the player to resolve
Returns
The player's rcon id

Example usage:

local player_rconid = resolveplayer(0)
void l_respond ( PHASOR_API_ARGS  )

Responds to the person executing the current command.

If the server console is executing it, this function acts like hprintf.

If a player is executing it (via rcon), this function acts like sendconsoletext.

Parameters
strThe message to send.

Example usage:

respond("Your command was successfully executed.")
void l_rresolveplayer ( PHASOR_API_ARGS  )

Resolve a player's rcon id to their memory id.

Parameters
playerThe rcon id of the player to resolve.
Returns
The player's memory id

Example usage:

local player_memid = rresolveplayer(0)
void l_say ( PHASOR_API_ARGS  )

Sends a chat message to the entire server.

Parameters
strThe message to send.
[prepend]boolean indicating whether or not to prepend ** SERVER ** (default true)

Example usage:

say("This is a single line message.")
say("This is the first line of another.\nThis is the second.\nAnd so on")
say("Don't include ** SERVER **", false)
void l_sendconsoletext ( PHASOR_API_ARGS  )

Sends the specified player a console message.

Parameters
player_idThe memory id of the player to message.
strThe message to send.

Example usage:

sendconsoletext(4, "Your command was successful.")
void l_setadmin ( PHASOR_API_ARGS  )

Sets the specified player as an admin for the duration of the current game, or until the player leaves.

Parameters
playerThe player's memory id.

Example usage:

setadmin(0) -- player 0 is now an admin
if (isadmin(0) == true) then
-- this will always be true
end
void l_setammo ( PHASOR_API_ARGS  )

Set a weapon's ammo and forcibly sync.

Parameters
weaponIdThe memory id of the weapon to sync.
clip_ammoHow many rounds the weapon's clip should have.
pack_ammoHow many rounds the weapon has unloaded (not in clip)

Example usage:

setammo(m_weaponId, 50, 200) -- 50 clip, 200 pack
void l_setspeed ( PHASOR_API_ARGS  )

Set the specified player's speed.

Parameters
playerThe player's memory id
speedThe player's new speed (1.0 is default)

Example usage:

setspeed(player, 5) -- 5x speed
void l_svcmd ( PHASOR_API_ARGS  )

Executes a server command.

Parameters
cmdThe command to execute
[result]Boolean indicating whether or not a result is wanted (see remarks)

Example usage:

svcmd("sv_ban " .. resolveplayer(player))
local output = svcmd("sv_mapcycle", true)
for k,v in ipairs(output) do
hprintf("result: " .. v)
end
Remarks
Be careful when using player ids! Memory ids should not be used when referring to a player. resolveplayer should be used to convert a memory id into an rcon id.
If result is true then all text that would be sent to the executing player will be logged. Once the command has completed it will be returned to you as a table.
void l_svcmdplayer ( PHASOR_API_ARGS  )

Executes a server command as the specified player.

Parameters
cmdThe command to execute
playermemory id of the player to execute as.
[result]Boolean indicating whether or not a result is wanted (see remarks)

Example usage:

svcmdplayer("sv_ban " .. resolveplayer(player), 0)
local output = svcmd("sv_mapcycle", 0, true)
for k,v in ipairs(output) do
hprintf("result: " .. v)
end
Remarks
Be careful when using player ids! Memory ids should not be used when referring to a player. resolveplayer should be used to convert a memory id into an rcon id.
If result is true then all text that would be sent to the executing player will be logged. Once the command has completed it will be returned to you as a table.
void l_tokenizecmdstring ( PHASOR_API_ARGS  )

Tokenizes (splits) an input string into distinct words, which are either separated by a space or enclosed in " ".

Parameters
strThe string to tokenize
Returns
A table consisting of the split strings.

Example usage:

local tokens = tokenizecmdstring("Split at space \"but not while in quotes\" ok?")
-- print the tokens
for k,v in ipairs(tokens) do
hprintf("Token " .. k .. " is " .. v)
end

Output:

Token 1 is Split
Token 2 is at
Token 3 is space
Token 4 is but not while in quotes
Token 5 is ok?
void l_tokenizestring ( PHASOR_API_ARGS  )

Tokenizes (splits) an input string at specified delimiters.

Parameters
strThe string to tokenize
delimA string of characters to split at.
Returns
A table consisting of the split strings.

Example usage:

local tokens = tokenizestring("Split at each space,and,comma", " ,")
-- print the tokens
for k,v in ipairs(tokens) do
hprintf("Token " .. k .. " is " .. v)
end

Output:

Token 1 is Split
Token 2 is at
Token 3 is each
Token 4 is space
Token 5 is and
Token 6 is comma
void l_updateammo ( PHASOR_API_ARGS  )

Forcibly sync the specified weapon's ammo counts.

Parameters
weaponIdThe memory id of the weapon to sync.

Example usage:

updateammo(m_weaponId) -- update the weapon's ammo
void l_writebit ( PHASOR_API_ARGS  )

Writes a bit to the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
bit_offsetWhich bit to write (starting at 0)
dataThe value to write (1 or 0)

Example usage:

writebit(0x12345678, 3, 1, 0) -- write 0 to the 2nd bit at 0x12345678 + 3
writebit(0x12345678, 1, 0) -- write 0 to the 2nd bit at 0x12345678
Remarks
bit_offset starts at 0 for the least significant bit
void l_writebyte ( PHASOR_API_ARGS  )

Writes a byte to the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
dataThe data to write

Example usage:

writebyte(0x12345678, 3, 50) -- write 50 to 0x12345678 + 3
writebyte(0x12345678, 50) -- write 50 to 0x12345678
void l_writechar ( PHASOR_API_ARGS  )

Writes a char to the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
dataThe data to write

Example usage:

writechar(0x12345678, 3, -41) -- write -41 to 0x12345678 + 3
writechar(0x12345678, -41) -- write -41 to 0x12345678
void l_writedouble ( PHASOR_API_ARGS  )

Writes a double to the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
dataThe data to write

Example usage:

writedouble(0x12345678, 3, 1.5) -- write 1.5 to 0x12345678 + 3
writedouble(0x12345678, 1.5) -- write 1.5 to 0x12345678
void l_writedword ( PHASOR_API_ARGS  )

Writes a dword to the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
dataThe data to write

Example usage:

writedword(0x12345678, 3, 0xbadf00d) -- write 0xbadf00d to 0x12345678 + 3
writedword(0x12345678, 50) -- write 50 to 0x12345678
void l_writefloat ( PHASOR_API_ARGS  )

Writes a float to the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
dataThe data to write

Example usage:

writefloat(0x12345678, 3, 1.5) -- write 1.5 to 0x12345678 + 3
writefloat(0x12345678, 1.5) -- write 1.5 to 0x12345678
void l_writeint ( PHASOR_API_ARGS  )

Writes an int to the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
dataThe data to write

Example usage:

writeint(0x12345678, 3, -501) -- write -501 to 0x12345678 + 3
writeint(0x12345678, 50) -- write 50 to 0x12345678
void l_writeshort ( PHASOR_API_ARGS  )

Writes a short to the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
dataThe data to write

Example usage:

writeshort(0x12345678, 3, 50) -- write 50 to 0x12345678 + 3
writeshort(0x12345678, 50) -- write 50 to 0x12345678
void l_writestring ( PHASOR_API_ARGS  )

Writes a string to the specified memory address.

Parameters
addressThe address to write to.
strThe string to write.

Example usage:

writestring(0x12345678, "write this string.")
void l_writewidestring ( PHASOR_API_ARGS  )

Writes a wide string to the specified memory address.

Parameters
addressThe address to write to.
strThe string to write.

Example usage:

writewidestring(0x12345678, "write this string.")
Remarks
Lua doesn't support wide strings, so Phasor will convert the provided narrow string to wide before writing it.
void l_writeword ( PHASOR_API_ARGS  )

Writes a word to the specified memory address.

Parameters
base_addressThe base address to use.
[address_offset]The offset relative to base_address.
dataThe data to write

Example usage:

writeword(0x12345678, 3, 50) -- write 50 to 0x12345678 + 3
writeword(0x12345678, 50) -- write 50 to 0x12345678
void odl::reset ( )
void odl::setData ( halo::damage_script_options opts_,
halo::s_damage_info dmg,
const halo::ident receiver 
)