void CCallbackManager::OnPlayerStatsAndWeaponsUpdate(WORD playerid) { int idx = -1; cell ret = 1; for (std::vector<AMX*>::const_iterator iter = m_vecAMX.begin(); iter != m_vecAMX.end(); ++iter) { if (!amx_FindPublic(*iter, "OnPlayerStatsAndWeaponsUpdate", &idx)) { amx_Push(*iter, static_cast<cell>(playerid)); amx_Exec(*iter, &ret, idx); } } }
void CNetwork::OnClientDeath(cell attacker, cell receiver) { CBasePlayer *pPlayer = new CBasePlayer; attacker = pPlayer->GetInternalIDFromNFID(attacker); receiver = pPlayer->GetInternalIDFromNFID(receiver); printf("OnClientDeath(%d, %d) has been called.\n", pPlayer->GetNFIDFromInternalID(attacker), pPlayer->GetNFIDFromInternalID(receiver)); int idx; cell ret = 0; if (!amx_FindPublic(&inimod_amx, "OnClientDeath", &idx)) { amx_Push(&inimod_amx, receiver); amx_Push(&inimod_amx, attacker); amx_Exec(&inimod_amx, &ret, idx); } delete pPlayer; return; }
uint32_t CGamemodeManager::OnObjectMoved(cell objectid) { if (!gmIsInit) return 0; int idx; cell ret = 0; if (!amx_FindPublic(&gmAMX, "OnObjectMoved", &idx)) { amx_Push(&gmAMX, objectid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
uint32_t CGamemodeManager::OnPlayerClickPlayerTextDraw(cell playerID, cell textDrawID) { int idx; cell ret = 0; if (!amx_FindPublic(&gmAMX, "OnPlayerClickPlayerTextDraw", &idx)) { amx_Push(&gmAMX, textDrawID); amx_Push(&gmAMX, playerID); amx_Exec(&gmAMX, &ret, idx); if (ret) return 1; } return (uint32_t) ret; }
uint32_t CGamemodeManager::OnVehicleDamageStatusUpdate(cell vehicleid, cell playerid) { if (!gmIsInit) return 0; int idx; cell ret = 0; if(!amx_FindPublic(&gmAMX, "OnVehicleDamageStatusUpdate", &idx)) { amx_Push(&gmAMX, playerid); amx_Push(&gmAMX, vehicleid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
uint32_t CGamemodeManager::OnPlayerStreamIn(cell playerid, cell forplayerid) { if (!gmIsInit) return 0; int idx; cell ret = 1; if(!amx_FindPublic(&gmAMX, "OnPlayerStreamIn", &idx)) { amx_Push(&gmAMX, forplayerid); amx_Push(&gmAMX, playerid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
uint32_t CGamemodeManager::OnEnterExitModShop(cell playerid, cell enterexit, cell uint32_teriorid) { if (!gmIsInit) return 0; int idx; cell ret = 1; if (!amx_FindPublic(&gmAMX, "OnEnterExitModShop", &idx)) { amx_Push(&gmAMX, uint32_teriorid); amx_Push(&gmAMX, enterexit); amx_Push(&gmAMX, playerid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
uint32_t CGamemodeManager::OnVehicleStreamOut(cell vehicleid, cell forplayerid) { if (!gmIsInit) return 0; int idx; cell ret = 1; if(!amx_FindPublic(&gmAMX, "OnVehicleStreamOut", &idx)) { amx_Push(&gmAMX, forplayerid); amx_Push(&gmAMX, vehicleid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
uint32_t CGamemodeManager::OnVehiclePaintjob(cell playerid, cell vehicleid, cell pauint32_tjobid) { if (!gmIsInit) return 0; int idx; cell ret = 1; if (!amx_FindPublic(&gmAMX, "OnVehiclePaintjob", &idx)) { amx_Push(&gmAMX, pauint32_tjobid); amx_Push(&gmAMX, vehicleid); amx_Push(&gmAMX, playerid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
uint32_t CGamemodeManager::OnPlayerSelectedMenuRow(cell playerid, cell row) { if (!gmIsInit) return 0; int idx; cell ret = 0; if (!amx_FindPublic(&gmAMX, "OnPlayerSelectedMenuRow", &idx)) { amx_Push(&gmAMX, row); amx_Push(&gmAMX, playerid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
void CNetwork::UnloadScript() { int val; if (!amx_FindPublic(&inimod_amx, "OnGameModeExit", &val)) amx_Exec(&inimod_amx, (cell*)&val, val); if (GMLoaded) { aux_FreeProgram(&inimod_amx); amx_TimeCleanup(&inimod_amx); //amx_FileCleanup(&inimod_amx); amx_StringCleanup(&inimod_amx); amx_FloatCleanup(&inimod_amx); amx_CoreCleanup(&inimod_amx); } GMLoaded = false; }
uint32_t CGamemodeManager::OnPlayerPickedUpPickup(cell playerid, cell pickupid) { if (!gmIsInit) return 0; int idx; cell ret = 0; if (!amx_FindPublic(&gmAMX, "OnPlayerPickUpPickup", &idx)) { amx_Push(&gmAMX, pickupid); amx_Push(&gmAMX, playerid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
uint32_t CGamemodeManager::OnVehicleDeath(cell vehicleid, cell killerid) { if (!gmIsInit) return 0; int idx; cell ret = 0; if (!amx_FindPublic(&gmAMX, "OnVehicleDeath", &idx)) { amx_Push(&gmAMX, killerid); amx_Push(&gmAMX, vehicleid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
// forward MyCallback(resultId, dataId); int Script::Callback(const char* callbackName, int resultId, int dataId) { int callbackIndex = 0; if (!strlen(callbackName) || amx_FindPublic(runtime_, callbackName, &callbackIndex) != AMX_ERR_NONE) return 0; cell returnValue; // Push the two arguments to the user's callback, in reversed order. amx_Push(runtime_, dataId); amx_Push(runtime_, resultId); // Execute and get the return value. amx_Exec(runtime_, &returnValue, callbackIndex); return returnValue; }
uint32_t CGamemodeManager::OnVehicleRespray(cell playerid, cell vehicleid, cell color1, cell color2) { if (!gmIsInit) return 0; int idx; cell ret = 1; if (!amx_FindPublic(&gmAMX, "OnVehicleRespray", &idx)) { amx_Push(&gmAMX, color2); amx_Push(&gmAMX, color1); amx_Push(&gmAMX, vehicleid); amx_Push(&gmAMX, playerid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
uint32_t CGamemodeManager::OnUnoccupiedVehicleUpdate(cell vehicleid, cell playerid, cell passenger_seat) { if (!gmIsInit) return 0; int idx; cell ret = 0; if(!amx_FindPublic(&gmAMX, "OnUnoccupiedVehicleUpdate", &idx)) { amx_Push(&gmAMX, passenger_seat); amx_Push(&gmAMX, playerid ); amx_Push(&gmAMX, vehicleid ); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
uint32_t CGamemodeManager::OnPlayerEnterCheckpoint(cell playerid) { if (!gmIsInit) return 0; int idx; cell ret = 0; if(!__NetGame->playerPool->GetSlotState((_PlayerID)playerid)) return 0; if (!amx_FindPublic(&gmAMX, "OnPlayerEnterCheckpoint", &idx)) { amx_Push(&gmAMX, playerid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
uint32_t CGamemodeManager::OnPlayerDeath(cell playerid, cell killerid, cell reason) { if (!gmIsInit) return 0; int idx; cell ret = 0; if (!amx_FindPublic(&gmAMX, "OnPlayerDeath", &idx)) { amx_Push(&gmAMX, reason); amx_Push(&gmAMX, killerid); amx_Push(&gmAMX, playerid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
security_tokens_t get_security_tokens() { security_tokens_t rezult; for (amxs_t::const_iterator it = amxs.begin(), end = amxs.end(); end != it; ++it) { cell retval; int index; if (AMX_ERR_NONE == amx_FindPublic(*it, "check_freemode_module", &index)) { if (AMX_ERR_NONE == amx_Exec(*it, &retval, index)) { rezult.push_back(retval); continue; } } // Ошибочный код rezult.push_back(0); } return rezult; }
static int AMXAPI amx_FindPublicHookProc(AMX *amx, const char *name, int *index) { amx_FindPublicHook.Remove(); int error = amx_FindPublic(amx, name, index); if (amx == gamemode) { if (error != AMX_ERR_NONE) { *index = AMX_EXEC_GDK; error = AMX_ERR_NONE; } currentPublic = name; } amx_FindPublicHook.Reinstall(); return error; }
uint32_t CGamemodeManager::OnPlayerClickMap( cell playerID, float posX, float posY, float posZ ) { int idx; cell ret = 0; if(!amx_FindPublic(&gmAMX, "OnPlayerClickMap", &idx)) { amx_Push(&gmAMX, amx_ftoc( posZ ) ); amx_Push(&gmAMX, amx_ftoc( posY ) ); amx_Push(&gmAMX, amx_ftoc( posX ) ); amx_Push(&gmAMX, playerID); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
void CNetwork::OnClientEquip(cell playerid) { CBasePlayer *pPlayer = new CBasePlayer(); playerid = pPlayer->GetInternalIDFromNFID(playerid); printf("OnClientEquip(%d) has been called.\n", playerid); int idx; cell ret = 0; //amx push would go below here.. (So we can push the OnClientConnect data to the loaded AMX script later) if (!amx_FindPublic(&inimod_amx, "OnClientEquip", &idx)) { amx_Push(&inimod_amx, playerid); amx_Exec(&inimod_amx, &ret, idx); } if((long)ret == 1) { printf("ret returned %d\n", ret); } delete pPlayer; }
void CScriptTimers::Process(uint32_t time) { for (std::map<uint32_t, timerData*>::iterator it = timersMap.begin(); it != timersMap.end(); it++) { it->second->remainingTime -= time; if (it->second->remainingTime <= 0) { std::map<uint32_t, timerData*>::iterator _it = ++it; it--; if (!it->second->timerKilled) { if (__NetGame->gamemodeManager) { int idx; AMX* amx = it->second->timerAMX; if (amx && !amx_FindPublic(amx, it->second->funcName, &idx)) { cell ret; int count = it->second->paramCount; int i = 0; if (count > 0) { cell* pars = (cell*)it->second->timerParams; while (i < count) { amx_Push(amx, pars[i]); i++; } } amx_Exec(amx, &ret, idx); } } } if (it->second->timerRepeat) { it->second->remainingTime = it->second->totalTime; } else { FreeTimerMemory(it->second); Delete(it->first); } it = _it; } if (it == timersMap.end()) break; } }
void CCallbackManager::OnPlayerPauseStateChange(WORD playerid, bool pausestate) { int idx = -1; cell ret = 1; for(std::vector<AMX*>::const_iterator iter = m_vecAMX.begin(); iter != m_vecAMX.end(); ++iter) { if(!amx_FindPublic(*iter, "OnPlayerPauseStateChange", &idx)) { amx_Push(*iter, static_cast<cell>(pausestate)); amx_Push(*iter, static_cast<cell>(playerid)); amx_Exec(*iter, &ret, idx); if (!ret) return; } } }
void CScriptHttp::Process() { int amxIdx; cell ret = 0; for(uint8_t i = 0; i < 200; i++) { if(this->workers[i].responseCode == 3) { if(!this->workers[i].unk_noCallback) { if(this->workers[i].httpAMX) { if (!amx_FindPublic(this->workers[i].httpAMX, this->workers[i].amxCallback, &amxIdx) ) { cell amx_addr, *phys_addr; cell response; if(this->workers[i].httpClient->response) { amx_PushString(this->workers[i].httpAMX, &amx_addr, &phys_addr, "\0", 0, 0); response = this->workers[i].httpClient->response; } else { amx_PushString(this->workers[i].httpAMX, &amx_addr, &phys_addr, this->workers[i].data, 0, 0); response = this->workers[i].httpClient->unkDword005; } amx_Push(this->workers[i].httpAMX, response); amx_Push(this->workers[i].httpAMX, this->workers[i].threadId); amx_Exec(this->workers[i].httpAMX, &ret, amxIdx); amx_Release(this->workers[i].httpAMX, amx_addr); } } } // if(this->workers[i].httpClient) SAFE_DELETE(this->workers[i].httpClient); memset(&(this->workers[i]), 0, 0x2848); this->workers[i].unkdword = 0; this->workers[i].type = 0; } } }
void CCallbackManager::OnPlayerLeavePlayerGangZone(WORD playerid, WORD zoneid) { int idx = -1; cell ret = 1; for(std::vector<AMX*>::const_iterator iter = m_vecAMX.begin(); iter != m_vecAMX.end(); ++iter) { if(!amx_FindPublic(*iter, "OnPlayerLeavePlayerGangZone", &idx)) { amx_Push(*iter, static_cast<cell>(zoneid)); amx_Push(*iter, static_cast<cell>(playerid)); amx_Exec(*iter, &ret, idx); if (!ret) return; } } }
void CNetwork::OnMapLoaded() { printf("OnMapLoaded() has been called.\n"); int idx; cell ret = 0; CBasePlayer *pPlayer = new CBasePlayer(); pPlayer->ProcessClientsOnMapLoad(); //amx push would go below here.. (So we can push the OnMapLoaded data to the loaded AMX script later) if (!amx_FindPublic(&inimod_amx, "OnMapLoaded", &idx)) { amx_Exec(&inimod_amx, &ret, idx); } if((long)ret == 1) { printf("ret returned %d\n", ret); } delete pPlayer; }
uint32_t CGamemodeManager::OnPlayerRequestClass(cell playerid, cell classid) { if (!gmIsInit) return 0; int idx; cell ret = 1; if(!__NetGame->playerPool->GetSlotState((_PlayerID)playerid)) return 0; if (!amx_FindPublic(&gmAMX, "OnPlayerRequestClass", &idx)) { amx_Push(&gmAMX, classid); amx_Push(&gmAMX, playerid); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
uint32_t CGamemodeManager::OnPlayerMoneyChange( cell playerid, cell old_value, cell new_value ) // useful for anticheat { if (!gmIsInit) return 0; int idx; cell ret = 0; if(!amx_FindPublic(&gmAMX, "OnPlayerMoneyChange", &idx)) { // stack à l'envers amx_Push(&gmAMX, new_value); amx_Push(&gmAMX, old_value ); amx_Push(&gmAMX, playerid ); amx_Exec(&gmAMX, &ret, idx); } return (uint32_t)ret; }
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; }