Please PLEASE note that it's not very well explained right now. And every command is currently a say command.
.findvec finds the vector of an object, relative to another object. So, if you do: ".findvec origin me 128 128 128" it will list EVERY entity within a 256x256x256 cube, with the center of the cube being you.
But if you do ".findvec velocity me 128 128 128" while running, it will find pretty much every entity moving +/- 128 in each vector.
.findstr or .findsz (I allow both) CAN AND WILL crash the game unless you are searching for netname. Findstr can search for up to 4 different arguments, and the first match wins. Ergo:
If my name is set to "Anpheus" and I say ".findstr net Blargh Anf An Anpheus", the function will say that it matched "An"
That said. Be very careful with .findstr, because for some reason I cannot currently tell, it crashes on targetname, target, global, class... I dont know about others.
Adding variables is pretty easy too, so feel free. Just remember to reply with any updates to the function itself.
It was originally created for vector manipulation, hence the poor name of the function that I am too lazy to change.
Code:
public entityvector(id) {
new iData[65]
new Cmd[9] // .get* and .set* (i.e.: .setvec)
// ( vec : vector quantity ) ( bit : bitwise integer ) ( int : integer )
// ( flo : rational number ) ( sz str : string array )
new Var[16] // Variable (i.e.: origin, velocity, movetype)
new strArg[3][32] // .set variables (X,Y,Z coordinates, numbers, etc)
new strid[32], entid // Target. In .findstr it acts as a stringArg.
new i, x, count, y // Loop vars
new argtype // For entity_*_* this is the name of the variable.
//Vars! Vars! Vars!
new Float:iVec[3], Float:oVec[3], Float:idvec[3], iInt, isbit, BitVals[32][32]
if (read_argc() > 2) {
read_argv(1,Cmd,7)
read_argv(2,Var,15)
read_argv(3,strid,31)
read_argv(4,strArg[0],31)
read_argv(5,strArg[1],31)
read_argv(6,strArg[2],31)
} else {
read_argv(1,iData,64)
remove_quotes(iData)
parse(iData,Cmd,8,Var,15,strid,31,strArg[0],31,strArg[1],31,strArg[2],31)
}
if ( Cmd[0] != '.' )
return PLUGIN_CONTINUE
if ( !equali(Cmd,".finds",6) && !equali(Cmd,".help") ) {
if ( equali(strid,"look") || equali(strid,"target") ) {
get_user_aiming (id,entid,x)
} else if ( equali(strid,"me") || equali(strid,"self") ) {
entid = id
} else {
entid = str_to_num(strid)
}
if ( !is_valid_ent(entid) ) { //Invalid entity
client_print(id, print_chat, "[AMXX-EntModX] Not a valid target.^n")
return PLUGIN_HANDLED
}
if ( entid < 33 && access(entid, ADMIN_LEVEL_B) && id != entid ) { //Player entity with immunity
client_print(id, print_chat, "[AMXX-EntModX] User has immunity.")
return PLUGIN_HANDLED
}
}
if ( equali(Cmd,".help") ) {
client_print(id, print_chat, "Go to console for information on AMXX EntmodX")
if ( equali(Var,"") ) {
client_print(id, print_console, "To set or get a value, in chat type .get or .set followed by a type, and a ")
client_print(id, print_console, "The types are listed with: abbreviation & full name : description.")
client_print(id, print_console, "vec & vector ^t: Any value with more than one variable. i.e.: X,Y,Z coordinates")
client_print(id, print_console, "bit & bitwise ^t: An integer containing true/false statements. i.e.: Movebit 6 = 'godmode'")
client_print(id, print_console, "int & integer ^t: A simple integer, any whole number -2147483648 to 2147483647.")
client_print(id, print_console, "flo & float ^t: A rational or real number, i.e.: 0.05, 3.1415, 9.0")
client_print(id, print_console, "sz & str & string ^t: A string is text, i.e.: ^"Anpheus^", ^"Hello world^"")
}
}
if ( containi(Cmd,"vec") + 1 ) {
/*** VECTOR QUANTITIES *** COMMANDS: .get .set .find ******/
if ( equali(Var,"origin") ) {
argtype = EV_VEC_origin
} else if ( equali(Var,"vel") ) {
argtype = EV_VEC_velocity
} else if ( equali(Var,"clbasevel") ) {
argtype = EV_VEC_clbasevelocity
} else if ( equali(Var,"movedir") ) {
argtype = EV_VEC_movedir
} else if ( equali(Var,"angle") ) {
argtype = EV_VEC_angles
} else if ( equali(Var,"avel") ) {
argtype = EV_VEC_avelocity
} else if ( equali(Var,"mins") ) {
argtype = EV_VEC_mins
} else if ( equali(Var,"maxs") ) {
argtype = EV_VEC_maxs
} else if ( equali(Var,"rend") || equali(Var,"color") ) {
argtype = EV_VEC_rendercolor
} else {
client_print(id, print_chat, "[AMXX-EntModX] The variable %s is invalid. Command: %s",Var, Cmd)
return PLUGIN_HANDLED
}
if ( equali(Cmd,".get",4) ) {
entity_get_vector( entid, argtype, iVec )
client_print(id, print_chat, "[AMXX-EntModX] Command %s %s has been used on Entity %d, Vars: (%f,%f,%f)",Cmd,Var,entid,iVec[0],iVec[1],iVec[2])
} else if ( equali(Cmd,".set",4) ) {
for ( i = 0; i < 3; i++ )
oVec[i] = floatstr( strArg[i] )
entity_get_vector( entid, argtype, iVec )
if ( Cmd[5] == '+' ) {
for ( i = 0; i < 3; i++ )
oVec[i] += iVec[i]
} else if ( Cmd[5] == '-' ) {
for ( i = 0; i < 3; i++ )
oVec[i] -= iVec[i]
} else if ( Cmd[5] == '*' ) {
for ( i = 0; i < 3; i++ )
oVec[i] *= iVec[i]
} else if ( Cmd[5] == '/' ) {
for ( i = 0; i < 3; i++ )
oVec[i] /= iVec[i]
}
entity_set_vector( entid, argtype, oVec )
client_print(id, print_chat, "[AMXX-EntModX] Command %s %s has been used on Entity %d, Vars: (%f,%f,%f)",Cmd,Var,entid,oVec[0],oVec[1],oVec[2])
} else if ( equali(Cmd,".find",5) ) {
entity_get_vector( entid, argtype, idvec )
for ( i = 0; i < 3; i++ )
oVec[i] = floatstr( strArg[i] )
for ( i = 1; count <= 64 && i < entity_count(); i++ ) {
if ( !is_valid_ent(i) || id == i ) continue
entity_get_vector( i, argtype, iVec )
x = 0
for ( x = 0; x < 3; x++ ) {
if (x == 4) break
if ( floatabs(iVec[x] - idvec[x]) > oVec[x] ) {
x = -1
break
}
}
if ( x != -1 ) {
num_to_str(i, strid, 3)
client_print(id, print_console, "[AMXX-EntModX] Entity %d matches (%f,%f,%f)", i, idvec[0] + oVec[0], idvec[1] + oVec[1], idvec[2] + oVec[2])
count++
}
}
}
} else if ( containi(Cmd,"bit") + 1 ) {
/*** INTEGER QUANTITIES *** COMMANDS: .getbit .setbit ******/
if ( equali(Var,"moveb",5) ) {
argtype = EV_INT_movetype
BitVals[0] = "FLY"
BitVals[1] = "SWIM"
BitVals[2] = "CONVEYO"
BitVals[3] = "CLIENT"
BitVals[4] = "INWATER"
BitVals[5] = "MONSTER"
BitVals[6] = "GODMODE"
BitVals[7] = "NOTARGE"
BitVals[8] = "SKIPLOC"
BitVals[9] = "ONGROUN"
BitVals[10] = "PARTIAL"
BitVals[11] = "WATERJU"
BitVals[12] = "FROZEN "
BitVals[13] = "FAKECLI"
BitVals[14] = "DUCKING"
BitVals[15] = "FLOAT "
BitVals[16] = "GRAPHED"
BitVals[17] = "IMMUNE_"
BitVals[18] = "IMMUNE_"
BitVals[19] = "IMMUNE_"
BitVals[20] = "PROXY "
BitVals[21] = "ALWAYST"
BitVals[22] = "BASEVEL"
BitVals[23] = "MONSTER"
BitVals[24] = "ONTRAIN"
BitVals[25] = "WORLDBR"
BitVals[26] = "SPECTAT"
BitVals[29] = "CUSTOME"
BitVals[30] = "KILLME "
BitVals[31] = "DORMANT"
} else if ( equali(Var,"button",6) ) {
argtype = EV_INT_button
BitVals[0] = "ATTACK"
BitVals[1] = "JUMP"
BitVals[2] = "DUCK"
BitVals[3] = "FORWARD"
BitVals[4] = "BACK"
BitVals[5] = "USE"
BitVals[6] = "CANCEL"
BitVals[7] = "LEFT"
BitVals[8] = "RIGHT"
BitVals[9] = "MOVELEF"
BitVals[10] = "MOVERIG"
BitVals[11] = "ATTACK2"
BitVals[12] = "RUN"
BitVals[13] = "RELOAD"
BitVals[14] = "ALT1"
BitVals[15] = "SCORE"
} else {
client_print(id, print_chat, "Please specify an integer-type variable.")
return PLUGIN_HANDLED
}
isbit = 1
if ( isbit && equali(Cmd,".setbit") ) {
if ( strlen(strArg[0]) > 0 ) {
for (i = 0; i <= 32 && strlen(BitVals[i]) > 0; i++) {
if ( !containi(BitVals[i],strArg[0]) ) {
isbit <<= i
break
}
}
if ( isbit == 33 ) {
client_print(id, print_chat, "[AMXX-EntModX] The bit name was not found. Command: %s %s, Bitname: %s",Cmd,Var,strArg[0])
return PLUGIN_HANDLED
}
} else {
isbit <<= str_to_num(strArg[0])
}
iInt = entity_get_int(entid, argtype)
if ( equali(strArg[1],"on") || str_to_num(strArg[1]) == 1 ) {
iInt |= isbit
} else {
iInt &= ~isbit
}
num_to_str(iInt, strArg[2], 31)
entity_set_int(entid, argtype, iInt)
client_print(id, print_chat, "[AMXX-EntModX] Command %s %s has been used on Entity %d bit %s set to %s.",Cmd,Var,entid,strArg[0],strArg[1])
} else if ( equali(Cmd,".getbit") ) {
if ( strlen(strArg[0]) > 0 ) {
for (i = 0; i <= 33 && strlen(BitVals[i]) > 0; i++) {
if ( !containi(BitVals[i],strArg[0]) ) {
isbit = i
break
}
}
if ( isbit == 33 ) {
client_print(id, print_chat, "[AMXX-EntModX] The bit name was not found. Command: %s %s, Bitname: %s",Cmd,Var,strArg[0])
return PLUGIN_HANDLED
}
} else {
isbit = str_to_num(strArg[0])
}
iInt = (entity_get_int(entid, argtype) >>> isbit) % 2
client_print(id, print_chat, "[AMXX-EntModX] Command %s %s has been used on Entity %d bit %s is set to %d.",Cmd,Var,entid,strArg[0],iInt)
}
} else if ( containi(Cmd,"int") + 1 ) {
if ( equali(Var,"weap",4) ) {
argtype = EV_INT_weapons
} else if ( equali(Var,"solid",5) ) {
argtype = EV_INT_solid
} else if ( equali(Var,"move",4) ) {
argtype = EV_INT_movetype
} else if ( equali(Var,"light",5) ) {
argtype = EV_INT_light_level
} else if ( equali(Var,"renderm",7) || equali(Var,"mode") ) {
argtype = EV_INT_rendermode
} else if ( equali(Var,"renderf",7) || equali(Var,"fx") ) {
argtype = EV_INT_renderfx
} else if ( equali(Var,"imp",3) ) {
argtype = EV_INT_impulse
} else {
client_print(id, print_chat, "[AMXX-EntModX] The variable %s is invalid. Command: %s",Var, Cmd)
return PLUGIN_HANDLED
}
if ( equali(Cmd,".setint") ) {
iInt = str_to_num(strArg[0])
num_to_str(iInt, BitVals[0], 31)
client_print(id, print_chat, BitVals[0])
entity_set_int(entid, argtype, iInt)
client_print(id, print_chat, "[AMXX-EntModX] Command %s %s has been used on Entity %d, integer set to %d",Cmd,Var,entid,iInt)
} else if ( equali(Cmd,".getint") ) {
iInt = entity_get_int(entid, argtype)
client_print(id, print_chat, "[AMXX-EntModX] Command %s %s has been used on Entity %d, integer is %d",Cmd,Var,entid,iInt)
}
} else if ( containi(Cmd,"flo") + 1 ) {
if ( equali(Var,"grav",4) ) {
argtype = EV_FL_gravity
} else if ( equali(Var,"fric",4) ) {
argtype = EV_FL_friction
} else if ( equali(Var,"health") || equali(Var,"hp") ) {
argtype = EV_FL_health
} else if ( equali(Var,"hpmax") || equali(Var,"healthmax") ) {
argtype = EV_FL_max_health
} else if ( equali(Var,"ap") || equali(Var,"armor") ) {
argtype = EV_FL_armorvalue
} else if ( equali(Var,"aptype") || equali(Var,"armortype") ) {
argtype = EV_FL_armortype
} else if ( equali(Var,"fov") ) {
argtype = EV_FL_fov
} else if ( equali(Var,"speed") ) {
argtype = EV_FL_speed
} else if ( equali(Var,"maxspeed") ) {
argtype = EV_FL_maxspeed
} else if ( equali(Var,"render",6) ) {
argtype = EV_FL_renderamt
} else {
client_print(id, print_chat, "[AMXX-EntModX] The variable %s is invalid. Command: %s",Var, Cmd)
return PLUGIN_HANDLED
}
if ( equali(Cmd,".setflo") ) {
iVec[0] = floatstr(strArg[0])
entity_set_float(entid, argtype, iVec[0])
client_print(id, print_chat, "[AMXX-EntModX] Command %s %s has been used on Entity %d, float set to %f",Cmd,Var,entid,iVec[0])
} else if ( equali(Cmd,".getflo") ) {
iVec[0] = entity_get_float(entid, argtype)
client_print(id, print_chat, "[AMXX-EntModX] Command %s %s has been used on Entity %d, float is %f",Cmd,Var,entid,iVec[0])
} else {
client_print(id, print_chat, "[AMXX-EntModX] The Command %s is invalid.",Cmd)
}
} else if ( containi(Cmd,"sz") + 1 || containi(Cmd,"str") + 1 ) {
if ( equali(Var,"class",5) ) {
argtype = EV_SZ_classname
} else if ( equali(Var,"global",6) ) {
argtype = EV_SZ_globalname
} else if ( equali(Var,"model",6) ) {
argtype = EV_SZ_model
} else if ( equali(Var,"target") ) {
argtype = EV_SZ_target
} else if ( equali(Var,"targetn",7) ) {
argtype = EV_SZ_targetname
} else if ( equali(Var,"net",3) ) {
argtype = EV_SZ_netname
} else {
client_print(id, print_chat, "[AMXX-EntModX] The variable %s is invalid. Command: %s",Var, Cmd)
return PLUGIN_HANDLED
}
if ( equali(Cmd,".set",4) ) {
entity_set_string(entid, argtype, strArg[0])
client_print(id, print_chat, "[AMXX-EntModX] Command %s %s has been used on Entity %d, string set to %s",Cmd,Var,entid,strArg[0])
} else if ( equali(Cmd,".get",4) ) {
entity_get_string(entid, argtype, strArg[0],31)
client_print(id, print_chat, "[AMXX-EntModX] Command %s %s has been used on Entity %d, string is %s",Cmd,Var,entid,strArg[0])
} else if ( equali(Cmd,".find",5) ) {
for ( x = 0; x < 3 && !equali(strArg[x],""); x++ ) {}
if ( x == 0 && equali(strid,"") ) {
client_print(id, print_chat, "[AMXX-EntModX] Remember to enter a string. Command: %s %s",Cmd, Var)
return PLUGIN_HANDLED
}
if ( equali(strid,"") ) {
isbit = 0
} else {
isbit = 1
}
client_print(id, print_console, "[AMXX-EntModX] Search begun, searching for strings ^"%s^" ^"%s^" ^"%s^" ^"%s^" in %d entities in variable %s.", strid, strArg[0], strArg[1], strArg[2], entity_count(), Var)
for ( i = 1; i <= entity_count() && count < 32; i++ ) {
if ( !is_valid_ent(i) )
continue
entity_get_string(i, argtype, BitVals[0], 31)
if ( BitVals[0][0] == 0 || BitVals[0][0] == ' ' )
continue
entid = 0
if ( isbit ) if ( containi(BitVals[0], strid) + 1 ) entid = 4
for ( y = 0; y < x && !entid; y++ )
if ( containi(BitVals[0], strArg[y]) + 1 )
entid = y + 1
if ( entid ) {
if ( entid < 4 ) {
BitVals[1] = strArg[y - 1]
} else {
BitVals[1] = strid
}
count++
client_print(id, print_console, "[AMXX-EntModX] Entity #%d has matched command ^"%s %s^" EntStr: ^"%s^", Query Matched: ^"%s^"",i,Cmd,Var,BitVals[0],BitVals[1])
}
client_print(id, print_chat, "[AMXX-EntModX] Search completed, found %d entities searching for strings %s %s %s %s in %d entities in variable %s", count, strid, strArg[0], strArg[1], strArg[2], entity_count(), Var)
}
if ( count & 32 ) client_print(id, print_console, "[AMXX-EntModX] The search contained one or more ambiguous strings and more than 32 entities were found.")
} else {
client_print(id, print_chat, "[AMXX-EntModX] The Command %s is invalid.",Cmd)
}
}
return PLUGIN_HANDLED
}