static cell AMX_NATIVE_CALL get_user_maxspeed(AMX *amx, cell *params) // Float:get_user_maxspeed(index) = 1 argument { // Gets user maxspeed. // params[1] = index // Check index CHECK_PLAYER(params[1]); // Fetch player pointer edict_t *pPlayer = MF_GetPlayerEdict(params[1]); return amx_ftoc(pPlayer->v.maxspeed); }
cell Call_Float_Void(AMX *amx, cell *params) { SETUP(1); #if defined(_WIN32) float ret=reinterpret_cast<float (__fastcall *)(void*, int)>(__func)(pv, 0); #elif defined(__linux__) || defined(__APPLE__) float ret=reinterpret_cast<float (*)(void *)>(__func)(pv); #endif *MF_GetAmxAddr(amx, params[3])=amx_ftoc(ret); return 1; }
static cell AMX_NATIVE_CALL n_floattan(AMX *amx,const cell *params) { /* * params[0] = number of bytes * params[1] = float operand 1 (angle) * params[2] = float operand 2 (radix) */ REAL fA = amx_ctof(params[1]); fA = ToRadians(fA, params[2]); fA = (float)tan(fA); (void)amx; return amx_ftoc(fA); }
PLUGIN_EXPORT bool PLUGIN_CALL OnPlayerWeaponShot(int playerid, int weaponid, int hittype, int hitid, float x, float y, float z) { bool retVal = true; if (hittype == BULLET_HIT_TYPE_PLAYER_OBJECT) { boost::unordered_map<int, Player>::iterator p = core->getData()->players.find(playerid); if (p != core->getData()->players.end()) { for (boost::unordered_map<int, int>::iterator i = p->second.internalObjects.begin(); i != p->second.internalObjects.end(); ++i) { if (i->second == hitid) { int objectid = i->first; for (std::set<AMX*>::iterator a = core->getData()->interfaces.begin(); a != core->getData()->interfaces.end(); ++a) { int amxIndex = 0; cell amxRetVal = 0; if (!amx_FindPublic(*a, "OnPlayerShootDynamicObject", &amxIndex)) { amx_Push(*a, amx_ftoc(z)); amx_Push(*a, amx_ftoc(y)); amx_Push(*a, amx_ftoc(x)); amx_Push(*a, static_cast<cell>(objectid)); amx_Push(*a, static_cast<cell>(weaponid)); amx_Push(*a, static_cast<cell>(playerid)); amx_Exec(*a, &amxRetVal, amxIndex); if (!amxRetVal) { retVal = false; } } } break; } } } } return retVal; }
static cell AMX_NATIVE_CALL n_floatpower(AMX *amx,const cell *params) { /* * params[0] = number of bytes * params[1] = float operand 1 (base) * params[2] = float operand 2 (exponent) */ REAL fA = amx_ctof(params[1]); REAL fB = amx_ctof(params[2]); fA = (REAL)pow(fA, fB); (void)amx; return amx_ftoc(fA); }
static cell AMX_NATIVE_CALL get_msg_arg_float(AMX *amx, cell *params) { size_t argn = static_cast<size_t>(params[1]); if (!inhook || argn > Msg.Params()) { LogError(amx, AMX_ERR_NATIVE, "Invalid message argument %d", argn); return 0; } REAL f = (REAL)Msg.GetParamFloat(argn); return amx_ftoc(f); }
//public QueryHandler(state, Handle:query, error[], errnum, data[], size) void MysqlThread::Execute() { cell data_addr; if (m_datalen) { data_addr = MF_PrepareCellArray(m_data, m_datalen); } else { static cell tmpdata[1] = {0}; data_addr = MF_PrepareCellArray(tmpdata, 1); } int state = 0; if (!m_qrInfo.connect_success) { state = -2; } else if (!m_qrInfo.query_success) { state = -1; } float diff = gpGlobals->time - m_qrInfo.queue_time; cell c_diff = amx_ftoc(diff); unsigned int hndl = MakeHandle(&m_qrInfo.amxinfo, Handle_Query, NullFunc); if (state != 0) { MF_ExecuteForward(m_fwd, (cell)state, (cell)hndl, m_qrInfo.amxinfo.error, m_qrInfo.amxinfo.info.errorcode, data_addr, m_datalen, c_diff); } else { MF_ExecuteForward(m_fwd, (cell)0, (cell)hndl, "", (cell)0, data_addr, m_datalen, c_diff); } FreeHandle(hndl); if (m_qrInfo.amxinfo.pQuery) { m_qrInfo.amxinfo.pQuery->FreeHandle(); m_qrInfo.amxinfo.pQuery = NULL; } delete [] m_qrInfo.amxinfo.opt_ptr; m_qrInfo.amxinfo.opt_ptr = NULL; }
cell Call_Float_Float(AMX *amx, cell *params) { SETUP(2); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3])); #if defined(_WIN32) float ret=reinterpret_cast<float (__fastcall *)(void *, int, float)>(__func)(pv, 0, f3); #elif defined(__linux__) || defined(__APPLE__) float ret=reinterpret_cast<float (*)(void *, float)>(__func)(pv, f3); #endif *MF_GetAmxAddr(amx, params[4])=amx_ftoc(ret); return 1; }
static cell AMX_NATIVE_CALL trace_line(AMX *amx, cell *params) { int iEnt = params[1]; cell *cStart = MF_GetAmxAddr(amx, params[2]); cell *cEnd = MF_GetAmxAddr(amx, params[3]); REAL fStartX = amx_ctof(cStart[0]); REAL fStartY = amx_ctof(cStart[1]); REAL fStartZ = amx_ctof(cStart[2]); REAL fEndX = amx_ctof(cEnd[0]); REAL fEndY = amx_ctof(cEnd[1]); REAL fEndZ = amx_ctof(cEnd[2]); cell *vRet = MF_GetAmxAddr(amx, params[4]); Vector vStart = Vector(fStartX, fStartY, fStartZ); Vector vEnd = Vector(fEndX, fEndY, fEndZ); TraceResult tr; if (iEnt == -1) TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &tr); else TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iEnt), &tr); edict_t *pHit = tr.pHit; vRet[0] = amx_ftoc(tr.vecEndPos.x); vRet[1] = amx_ftoc(tr.vecEndPos.y); vRet[2] = amx_ftoc(tr.vecEndPos.z); if (FNullEnt(pHit)) return 0; return ENTINDEX(pHit); }
static cell AMX_NATIVE_CALL entity_range(AMX *amx, cell *params) { int idxa = params[1]; int idxb = params[2]; CHECK_ENTITY(idxa); CHECK_ENTITY(idxb); edict_t *pEntA = INDEXENT2(idxa); edict_t *pEntB = INDEXENT2(idxb); REAL fRet = (pEntA->v.origin - pEntB->v.origin).Length(); return amx_ftoc(fRet); }
static cell AMX_NATIVE_CALL n_float(AMX *amx,const cell *params) { /* * params[0] = number of bytes * params[1] = long value to convert to a float */ REAL fValue; (void)amx; /* Convert to a float. Calls the compilers long to float conversion. */ fValue = (REAL) params[1]; /* Return the cell. */ return amx_ftoc(fValue); }
uint32_t CGamemodeManager::OnPlayerTakeDamage( cell playerID, cell attackerID, float damageAmount, cell weaponid, cell bodypart ) { int idx; cell ret = 0; if(!amx_FindPublic(&gmAMX, "OnPlayerTakeDamage", &idx)) { amx_Push(&gmAMX, bodypart ); amx_Push(&gmAMX, weaponid ); amx_Push(&gmAMX, amx_ftoc( damageAmount ) ); amx_Push(&gmAMX, attackerID ); amx_Push(&gmAMX, playerID); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
SAMPGDK_EXPORT int SAMPGDK_CALL CreateObject(int modelid, float x, float y, float z, float rX, float rY, float rZ, float DrawDistance) { static AMX_NATIVE native = Natives::GetNativeWarn("CreateObject"); cell params[] = { 8 * 4, modelid, amx_ftoc(x), amx_ftoc(y), amx_ftoc(z), amx_ftoc(rX), amx_ftoc(rY), amx_ftoc(rZ), amx_ftoc(DrawDistance) }; return FakeAmx::CallNative(native, params); }
SAMPGDK_EXPORT int SAMPGDK_CALL CreateObject(int modelid, float x, float y, float z, float rX, float rY, float rZ, float DrawDistance) { static AMX_NATIVE native = Wrapper::GetInstance()->GetNative("CreateObject"); cell params[] = { 8 * 4, modelid, amx_ftoc(x), amx_ftoc(y), amx_ftoc(z), amx_ftoc(rX), amx_ftoc(rY), amx_ftoc(rZ), amx_ftoc(DrawDistance) }; return native(&::fakeAmx, params); }
SAMPGDK_NATIVE(int, MoveObject(int objectid, float X, float Y, float Z, float Speed, float RotX, float RotY, float RotZ)) { static AMX_NATIVE native = sampgdk::Natives::GetNativeWarn("MoveObject"); cell params[] = { 8 * sizeof(cell), objectid, amx_ftoc(X), amx_ftoc(Y), amx_ftoc(Z), amx_ftoc(Speed), amx_ftoc(RotX), amx_ftoc(RotY), amx_ftoc(RotZ) }; return sampgdk::FakeAmx::CallNative(native, params); }
SAMPGDK_NATIVE(int, CreateObject(int modelid, float x, float y, float z, float rX, float rY, float rZ, float DrawDistance)) { static AMX_NATIVE native = sampgdk::Natives::GetNativeWarn("CreateObject"); cell params[] = { 8 * sizeof(cell), modelid, amx_ftoc(x), amx_ftoc(y), amx_ftoc(z), amx_ftoc(rX), amx_ftoc(rY), amx_ftoc(rZ), amx_ftoc(DrawDistance) }; return sampgdk::FakeAmx::CallNative(native, params); }
SAMPGDK_EXPORT bool SAMPGDK_CALL SetPlayerAttachedObject(int playerid, int index, int modelid, int bone, float fOffsetX, float fOffsetY, float fOffsetZ, float fRotX, float fRotY, float fRotZ, float fScaleX, float fScaleY, float fScaleZ) { static AMX_NATIVE native = Wrapper::GetInstance()->GetNative("SetPlayerAttachedObject"); cell params[] = { 13 * 4, playerid, index, modelid, bone, amx_ftoc(fOffsetX), amx_ftoc(fOffsetY), amx_ftoc(fOffsetZ), amx_ftoc(fRotX), amx_ftoc(fRotY), amx_ftoc(fRotZ), amx_ftoc(fScaleX), amx_ftoc(fScaleY), amx_ftoc(fScaleZ) }; return native(&::fakeAmx, params) != 0; }
SAMPGDK_NATIVE(int, MovePlayerObject(int playerid, int objectid, float x, float y, float z, float Speed, float RotX, float RotY, float RotZ)) { static AMX_NATIVE native = sampgdk::Natives::GetNativeWarn("MovePlayerObject"); cell params[] = { 9 * sizeof(cell), playerid, objectid, amx_ftoc(x), amx_ftoc(y), amx_ftoc(z), amx_ftoc(Speed), amx_ftoc(RotX), amx_ftoc(RotY), amx_ftoc(RotZ) }; return sampgdk::FakeAmx::CallNative(native, params); }
void COrm::Variable::SetValue(const char *val) { switch (m_Type) { case COrm::Variable::Type::INT: ConvertStrToData(val, (*m_VariableAddr)); break; case COrm::Variable::Type::FLOAT: { float dest = 0.0f; if (ConvertStrToData(val, dest)) (*m_VariableAddr) = amx_ftoc(dest); } break; case COrm::Variable::Type::STRING: amx_SetString(m_VariableAddr, val != nullptr ? val : "NULL", 0, 0, m_VarMaxLen); break; } }
cell Call_Float_Float_Cbase(AMX* amx, cell* params) { SETUP(3); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3])); int id4=*MF_GetAmxAddr(amx, params[4]); CHECK_ENTITY(id4); void *p4 = TypeConversion.id_to_cbase(id4); #if defined(_WIN32) float ret = reinterpret_cast<float(__fastcall *)(void*, int, float, void*)>(__func)(pv, 0, f3, p4); #elif defined(__linux__) || defined(__APPLE__) float ret = reinterpret_cast<float (*)(void*, float, void*)>(__func)(pv, f3, p4); #endif *MF_GetAmxAddr(amx, params[5]) = amx_ftoc(ret); return 1; }
static cell AMX_NATIVE_CALL n_floatlog(AMX *amx,const cell *params) { /* * params[0] = number of bytes * params[1] = float operand 1 (value) * params[2] = float operand 2 (base) */ REAL fValue = amx_ctof(params[1]); REAL fBase = amx_ctof(params[2]); (void)amx; if (fValue <= 0.0 || fBase <= 0) return amx_RaiseError(amx, AMX_ERR_DOMAIN); if (fBase == 10.0) // ??? epsilon fValue = (REAL)log10(fValue); else fValue = (REAL)(log(fValue) / log(fBase)); return amx_ftoc(fValue); }
int MoveObject(int objectid, float X, float Y, float Z, float Speed, float RotX, float RotY, float RotZ) { static AMX_NATIVE native = Wrapper::GetInstance().GetNative("MoveObject"); cell params[] = { 8 * 4, objectid, amx_ftoc(X), amx_ftoc(Y), amx_ftoc(Z), amx_ftoc(Speed), amx_ftoc(RotX), amx_ftoc(RotY), amx_ftoc(RotZ) }; return native(&::fakeAmx, params); }
SAMPGDK_EXPORT int SAMPGDK_CALL MoveObject(int objectid, float X, float Y, float Z, float Speed, float RotX, float RotY, float RotZ) { static AMX_NATIVE native = Natives::GetNativeWarn("MoveObject"); cell params[] = { 8 * 4, objectid, amx_ftoc(X), amx_ftoc(Y), amx_ftoc(Z), amx_ftoc(Speed), amx_ftoc(RotX), amx_ftoc(RotY), amx_ftoc(RotZ) }; return FakeAmx::CallNative(native, params); }
SAMPGDK_EXPORT bool SAMPGDK_CALL SetPlayerRaceCheckpoint(int playerid, int type, float x, float y, float z, float nextx, float nexty, float nextz, float size) { static AMX_NATIVE native = Wrapper::GetInstance()->GetNative("SetPlayerRaceCheckpoint"); cell params[] = { 9 * 4, playerid, type, amx_ftoc(x), amx_ftoc(y), amx_ftoc(z), amx_ftoc(nextx), amx_ftoc(nexty), amx_ftoc(nextz), amx_ftoc(size) }; return native(&::fakeAmx, params) != 0; }
int MovePlayerObject(int playerid, int objectid, float x, float y, float z, float Speed, float RotX, float RotY, float RotZ) { static AMX_NATIVE native = Wrapper::GetInstance().GetNative("MovePlayerObject"); cell params[] = { 9 * 4, playerid, objectid, amx_ftoc(x), amx_ftoc(y), amx_ftoc(z), amx_ftoc(Speed), amx_ftoc(RotX), amx_ftoc(RotY), amx_ftoc(RotZ) }; return native(&::fakeAmx, params); }
int CreatePlayerObject(int playerid, int modelid, float x, float y, float z, float rX, float rY, float rZ, float DrawDistance) { static AMX_NATIVE native = Wrapper::GetInstance().GetNative("CreatePlayerObject"); cell params[] = { 9 * 4, playerid, modelid, amx_ftoc(x), amx_ftoc(y), amx_ftoc(z), amx_ftoc(rX), amx_ftoc(rY), amx_ftoc(rZ), amx_ftoc(DrawDistance) }; return native(&::fakeAmx, params); }
SAMPGDK_EXPORT int SAMPGDK_CALL MovePlayerObject(int playerid, int objectid, float x, float y, float z, float Speed, float RotX, float RotY, float RotZ) { static AMX_NATIVE native = Natives::GetNativeWarn("MovePlayerObject"); cell params[] = { 9 * 4, playerid, objectid, amx_ftoc(x), amx_ftoc(y), amx_ftoc(z), amx_ftoc(Speed), amx_ftoc(RotX), amx_ftoc(RotY), amx_ftoc(RotZ) }; return FakeAmx::CallNative(native, params); }
cell Call_Int_pVector_pVector_Cbase_pFloat(AMX *amx, cell *params) { SETUP(4); Vector v3; Vector v4; float *fl3=(float *)MF_GetAmxAddr(amx, params[3]); float *fl4=(float *)MF_GetAmxAddr(amx, params[4]); v3.x=fl3[0]; v3.y=fl3[1]; v3.z=fl3[2]; v4.x=fl4[0]; v4.y=fl4[1]; v4.z=fl4[2]; int id5=*MF_GetAmxAddr(amx, params[5]); CHECK_ENTITY(id5); void *p5 = TypeConversion.id_to_cbase(id5); float f6; #if defined(_WIN32) int ret=reinterpret_cast<int (__fastcall *)(void *, int, Vector*, Vector*, void*, float*)>(__func)(pv, 0, &v3, &v4, p5, &f6); #elif defined(__linux__) || defined(__APPLE__) int ret=reinterpret_cast<int (*)(void *, Vector*, Vector*, void*, float*)>(__func)(pv, &v3, &v4, p5, &f6); #endif fl3[0]=v3.x; fl3[1]=v3.y; fl3[2]=v3.z; fl4[0]=v4.x; fl4[1]=v4.y; fl4[2]=v4.z; *MF_GetAmxAddr(amx, params[6]) = amx_ftoc(f6); return ret; }
static cell AMX_NATIVE_CALL get_pdata_float(AMX *amx, cell *params) { int index=params[1]; CHECK_ENTITY(index); int iOffset=params[2]; CHECK_OFFSET(iOffset); #if defined( __linux__ ) iOffset += params[3]; #elif defined( __APPLE__ ) // Use Linux offset in older plugins if (params[0] / sizeof(cell) == 3) iOffset += params[3]; else iOffset += params[4]; #endif return amx_ftoc(get_pdata<float>(TypeConversion.id_to_edict(index), iOffset * 4)); // *4 because macro is char-based, while native is int-based }
SAMPGDK_NATIVE(bool, AttachObjectToPlayer(int objectid, int playerid, float fOffsetX, float fOffsetY, float fOffsetZ, float fRotX, float fRotY, float fRotZ)) { static AMX_NATIVE native = sampgdk::Natives::GetNativeWarn("AttachObjectToPlayer"); cell params[] = { 8 * sizeof(cell), objectid, playerid, amx_ftoc(fOffsetX), amx_ftoc(fOffsetY), amx_ftoc(fOffsetZ), amx_ftoc(fRotX), amx_ftoc(fRotY), amx_ftoc(fRotZ) }; return sampgdk::FakeAmx::CallNativeBool(native, params); }