Advertisement
Guest User

Cod

a guest
Mar 20th, 2018
861
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 54.90 KB | None | 0 0
  1. /*
  2.  
  3. PROJECT: mod_sa
  4. LICENSE: See LICENSE in the top level directory
  5. COPYRIGHT: Copyright we_sux, BlastHack
  6.  
  7. mod_sa is available from https://github.com/BlastHackNet/mod_s0beit_sa/
  8.  
  9. mod_sa is free software: you can redistribute it and/or modify
  10. it under the terms of the GNU General Public License as published by
  11. the Free Software Foundation, either version 3 of the License, or
  12. (at your option) any later version.
  13.  
  14. mod_sa is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. GNU General Public License for more details.
  18.  
  19. You should have received a copy of the GNU General Public License
  20. along with mod_sa. If not, see <http://www.gnu.org/licenses/>.
  21.  
  22. */
  23.  
  24. #include "main.h"
  25.  
  26. int g_iSpectateEnabled = 0, g_iSpectateLock = 0, g_iSpectatePlayerID = -1;
  27. int g_iJoiningServer = 0;
  28. int iClickWarpEnabled = 0;
  29. int g_iNumPlayersMuted = 0;
  30. bool g_bPlayerMuted[SAMP_MAX_PLAYERS];
  31.  
  32. void sampMainCheat(void)
  33. {
  34. traceLastFunc("sampMainCheat()");
  35.  
  36. // g_Vehicles & g_Players pointers need to be refreshed or nulled
  37. if (isBadPtr_writeAny(g_SAMP->pPools, sizeof(stSAMPPools)))
  38. {
  39. g_Vehicles = NULL;
  40. g_Players = NULL;
  41. }
  42. else if (g_Vehicles != g_SAMP->pPools->pVehicle || g_Players != g_SAMP->pPools->pPlayer)
  43. {
  44. if (isBadPtr_writeAny(g_SAMP->pPools->pVehicle, sizeof(stVehiclePool)))
  45. g_Vehicles = NULL;
  46. else
  47. g_Vehicles = g_SAMP->pPools->pVehicle;
  48. if (isBadPtr_writeAny(g_SAMP->pPools->pPlayer, sizeof(stPlayerPool)))
  49. g_Players = NULL;
  50. else
  51. g_Players = g_SAMP->pPools->pPlayer;
  52. }
  53.  
  54. // update GTA to SAMP translation structures
  55. update_translateGTASAMP_vehiclePool();
  56. update_translateGTASAMP_pedPool();
  57.  
  58. spectateHandle();
  59. sampAntiHijack();
  60.  
  61. // start chatbox logging
  62. if (set.chatbox_logging)
  63. {
  64. static int chatbox_init;
  65. if (!chatbox_init)
  66. {
  67. SYSTEMTIME time;
  68. GetLocalTime(&time);
  69. LogChatbox(false, "Session started at %02d/%02d/%02d", time.wDay, time.wMonth, time.wYear);
  70. chatbox_init = 1;
  71. }
  72. }
  73.  
  74. if (KEYCOMBO_PRESSED(set.key_player_info_list))
  75. cheat_state->player_info_list ^= 1;
  76.  
  77. if (KEYCOMBO_PRESSED(set.key_rejoin))
  78. {
  79. restartGame();
  80. disconnect(500);
  81. cheat_state_text("Rejoining in %d seconds...", set.rejoin_delay / 1000);
  82. cheat_state->_generic.rejoinTick = GetTickCount();
  83. }
  84.  
  85. if (KEYCOMBO_PRESSED(set.key_respawn))
  86. playerSpawn();
  87.  
  88. if (KEYCOMBO_DOWN(set.chat_secondary_key))
  89. {
  90. int i, key, spam;
  91. const char *msg;
  92. for (i = 0; i < INI_CHATMSGS_MAX; i++)
  93. {
  94. struct chat_msg *msg_item = &set.chat[i];
  95. if (msg_item->key == NULL)
  96. continue;
  97. if (msg_item->msg == NULL)
  98. continue;
  99. if (msg_item->key != key_being_pressed)
  100. continue;
  101. key = msg_item->key;
  102. msg = msg_item->msg;
  103. spam = msg_item->spam;
  104. if (spam)
  105. {
  106. if (msg)
  107. if (KEY_DOWN(key))
  108. say("%s", msg);
  109. }
  110. else
  111. {
  112. if (msg)
  113. if (KEY_PRESSED(key))
  114. say("%s", msg);
  115. }
  116. }
  117. }
  118. if (set.clickwarp_enabled && iIsSAMPSupported)
  119. {
  120. if (KEYCOMBO_PRESSED(set.key_clickwarp_enable))
  121. {
  122. g_iCursorEnabled ^= 1;
  123. toggleSAMPCursor(g_iCursorEnabled);
  124. }
  125. if (g_iCursorEnabled && KEYCOMBO_PRESSED(set.key_clickwarp_click))
  126. {
  127. iClickWarpEnabled = 1;
  128. }
  129. }
  130.  
  131. static int iSAMPHooksInstalled;
  132. if (!iSAMPHooksInstalled)
  133. {
  134. installSAMPHooks();
  135. iSAMPHooksInstalled = 1;
  136. }
  137.  
  138. if (cheat_state->_generic.rejoinTick && cheat_state->_generic.rejoinTick < (GetTickCount() - set.rejoin_delay))
  139. {
  140. g_SAMP->iGameState = GAMESTATE_WAIT_CONNECT;
  141. cheat_state->_generic.rejoinTick = 0;
  142. }
  143.  
  144. if (g_iJoiningServer == 1)
  145. {
  146. restartGame();
  147. disconnect(500);
  148. cheat_state_text("Joining server in %d seconds...", set.rejoin_delay / 1000);
  149. cheat_state->_generic.join_serverTick = GetTickCount();
  150. g_iJoiningServer = 2;
  151. }
  152.  
  153. if (g_iJoiningServer == 2
  154. && cheat_state->_generic.join_serverTick
  155. && cheat_state->_generic.join_serverTick < (GetTickCount() - set.rejoin_delay))
  156. {
  157. g_SAMP->iGameState = GAMESTATE_WAIT_CONNECT;
  158. g_iJoiningServer = 0;
  159. cheat_state->_generic.join_serverTick = 0;
  160. }
  161. }
  162.  
  163. void spectateHandle(void)
  164. {
  165. if (g_iSpectateEnabled)
  166. {
  167. if (g_iSpectateLock) return;
  168.  
  169. if (g_iSpectatePlayerID != -1)
  170. {
  171. if (g_Players->iIsListed[g_iSpectatePlayerID] != 0)
  172. {
  173. if (g_Players->pRemotePlayer[g_iSpectatePlayerID] != NULL)
  174. {
  175. int iState = getPlayerState(g_iSpectatePlayerID);
  176.  
  177. if (iState == PLAYER_STATE_ONFOOT)
  178. {
  179. struct actor_info *pPlayer = getGTAPedFromSAMPPlayerID(g_iSpectatePlayerID);
  180. if (pPlayer == NULL) return;
  181. GTAfunc_CameraOnActor(pPlayer);
  182. g_iSpectateLock = 1;
  183. }
  184. else if (iState == PLAYER_STATE_DRIVER)
  185. {
  186. struct vehicle_info *pPlayerVehicleID = g_Players->pRemotePlayer[g_iSpectatePlayerID]->pPlayerData->pSAMP_Vehicle->pGTA_Vehicle;
  187. if (pPlayerVehicleID == NULL) return;
  188. GTAfunc_CameraOnVehicle(pPlayerVehicleID);
  189. g_iSpectateLock = 1;
  190. }
  191. else if (iState == PLAYER_STATE_PASSENGER)
  192. {
  193. struct vehicle_info *pPlayerVehicleID = g_Players->pRemotePlayer[g_iSpectatePlayerID]->pPlayerData->pSAMP_Vehicle->pGTA_Vehicle;
  194. if (pPlayerVehicleID == NULL) return;
  195. GTAfunc_CameraOnVehicle(pPlayerVehicleID);
  196. g_iSpectateLock = 1;
  197. }
  198. }
  199. else
  200. {
  201. cheat_state_text("Player is not streamed in");
  202. g_iSpectateEnabled = 0;
  203. }
  204. }
  205. }
  206. }
  207. }
  208.  
  209. void spectatePlayer(int iPlayerID)
  210. {
  211. if (iPlayerID == -1)
  212. {
  213. GTAfunc_TogglePlayerControllable(0);
  214. GTAfunc_LockActor(0);
  215. pGameInterface->GetCamera()->RestoreWithJumpCut();
  216.  
  217. g_iSpectateEnabled = 0;
  218. g_iSpectateLock = 0;
  219. g_iSpectatePlayerID = -1;
  220. return;
  221. }
  222.  
  223. g_iSpectatePlayerID = iPlayerID;
  224. g_iSpectateLock = 0;
  225. g_iSpectateEnabled = 1;
  226. }
  227.  
  228. void sampAntiHijack(void)
  229. {
  230. if (g_SAMP == NULL) return;
  231. traceLastFunc("sampAntiHijack()");
  232.  
  233. vehicle_info *veh = vehicle_info_get(VEHICLE_SELF, VEHICLE_ALIVE);
  234. if (set.anti_carjacking && veh == NULL)
  235. {
  236. if (cheat_state->_generic.got_vehicle_id)
  237. cheat_state->_generic.got_vehicle_id = false;
  238. if (cheat_state->_generic.anti_carjackTick
  239. && cheat_state->_generic.anti_carjackTick < (GetTickCount() - 500)
  240. && cheat_state->_generic.car_jacked)
  241. {
  242. if (cheat_state->_generic.car_jacked_last_vehicle_id == 0)
  243. {
  244. GTAfunc_showStyledText("~r~Unable To Unjack~w~!", 1000, 5);
  245. cheat_state->_generic.anti_carjackTick = 0;
  246. cheat_state->_generic.car_jacked = false;
  247. return;
  248. }
  249.  
  250. cheat_state->_generic.anti_carjackTick = 0;
  251. cheat_state->_generic.car_jacked = false;
  252. GTAfunc_PutActorInCar(GetVehicleByGtaId(cheat_state->_generic.car_jacked_last_vehicle_id));
  253.  
  254. // struct vehicle_info *veh = GetVehicleByGtaId(cheat_state->_generic.car_jacked_last_vehicle_id);
  255. //if ( veh != NULL )
  256. // vect3_copy( cheat_state->_generic.car_jacked_lastPos, &veh->base.matrix[4 * 3] );
  257. GTAfunc_showStyledText("~r~Car Unjacked~w~!", 1000, 5);
  258. return;
  259. }
  260. }
  261. else if (set.anti_carjacking)
  262. {
  263. if (veh->passengers[0] == actor_info_get(ACTOR_SELF, 0))
  264. {
  265. if (!cheat_state->_generic.got_vehicle_id)
  266. {
  267. cheat_state->_generic.car_jacked_last_vehicle_id = getPlayerVehicleGTAScriptingID(ACTOR_SELF);
  268. if (cheat_state->_generic.car_jacked_last_vehicle_id > 0)
  269. cheat_state->_generic.got_vehicle_id = true;
  270. }
  271. }
  272. }
  273. }
  274.  
  275.  
  276. //bool bReportChecked = false;
  277. //short PlayerID;
  278. //void CheckReport()
  279. //{
  280. // if (bReportChecked && KEY_DOWN(VK_LCONTROL) && KEY_DOWN(VK_LSHIFT))
  281. // {
  282. // say("/Spec %d", PlayerID);
  283. // bReportChecked = false;
  284. // }
  285. //}
  286.  
  287. void HandleRPCPacketFunc(unsigned char id, RPCParameters *rpcParams, void(*callback) (RPCParameters *))
  288. {
  289. traceLastFunc("HandleRPCPacketFunc");
  290. if (set.netPatchAssoc[id][INCOMING_RPC] != nullptr && set.netPatchAssoc[id][INCOMING_RPC]->enabled)
  291. return;
  292.  
  293. if (rpcParams != nullptr && rpcParams->numberOfBitsOfData >= 8)
  294. {
  295. switch (id)
  296. {
  297. case RPC_PlayerSpectatePlayer:
  298. {
  299. BitStream bsData(rpcParams->input, rpcParams->numberOfBitsOfData / 8, false);
  300. uint16_t playerId;
  301. bool mode;
  302.  
  303. bsData.Read(playerId);
  304. bsData.Read(mode);
  305. OLCheats->iSpectateID = playerId;
  306. //bsData.Read(unk);
  307. //Log("RPC_PlayerSpectatePlayer");
  308. cheat_state_text("RPC_PlayerSpectatePlayer, %d %d %d", playerId, mode, rpcParams->numberOfBitsOfData);
  309. }
  310. case RPC_PlayerSpectateVehicle:
  311. {
  312. BitStream bsData(rpcParams->input, rpcParams->numberOfBitsOfData / 8, false);
  313. uint16_t playerId;
  314. bool mode;
  315.  
  316. bsData.Read(playerId);
  317. bsData.Read(mode);
  318. //bsData.Read(unk);
  319. //Log("RPC_PlayerSpectatePlayer");
  320. cheat_state_text("RPC_PlayerSpectateVehicle, %d %d %d", playerId, mode, rpcParams->numberOfBitsOfData);
  321. }
  322. //
  323. //case 171: // wrong idk wat is
  324. //{
  325. // Log("RPC 171 SPEC");
  326. // cheat_state_text("RPC 171 SPEC");
  327. //}
  328. //case 172: // wrong idk wat is
  329. //{
  330. // Log("RPC 172 SPEC");
  331. // cheat_state_text("RPC 172 SPEC");
  332. //}
  333. //case 173: // wrong idk wat is
  334. //{
  335. // Log("RPC 173 SPEC");
  336. // cheat_state_text("RPC 173 SPEC");
  337. //}
  338. //
  339. /*
  340. case RPC_UpdateScoresPingsIPs:
  341. {
  342. Log("RPC_UpdateScoresPingsIPs RECEIVED");
  343. cheat_state_text("RPC_UpdateScoresPingsIPs RECEIVED");
  344. }*/
  345.  
  346. case RPC_SetPlayerHealth:
  347. {
  348. traceLastFunc("RPC_SetPlayerHealth");
  349. if (!set.enable_extra_godmode || !cheat_state->_generic.hp_cheat) break;
  350.  
  351. actor_info *self = actor_info_get(ACTOR_SELF, NULL);
  352. if (self)
  353. {
  354. BitStream bsData(rpcParams->input, rpcParams->numberOfBitsOfData / 8, false);
  355. float fHealth;
  356. bsData.Read(fHealth);
  357. if (fHealth < self->hitpoints)
  358. {
  359. cheat_state_text("Warning: Server tried change your health to %0.1f", fHealth);
  360. return; // exit from the function without processing RPC
  361. }
  362. }
  363. break;
  364. }
  365.  
  366. case RPC_SetVehicleHealth:
  367. {
  368. traceLastFunc("RPC_SetVehicleHealth");
  369. if (!set.enable_extra_godmode || !cheat_state->_generic.hp_cheat) break;
  370.  
  371. vehicle_info *vself = vehicle_info_get(VEHICLE_SELF, NULL);
  372. if (vself)
  373. {
  374. BitStream bsData(rpcParams->input, rpcParams->numberOfBitsOfData / 8, false);
  375. short sId;
  376. float fHealth;
  377. bsData.Read(sId);
  378. bsData.Read(fHealth);
  379. if (sId == g_Players->pLocalPlayer->sCurrentVehicleID && fHealth < vself->hitpoints)
  380. {
  381. cheat_state_text("Warning: Server tried change your vehicle health to %0.1f", fHealth);
  382. return; // exit from the function without processing RPC
  383. }
  384. }
  385. break;
  386. }
  387. case RPC_ClientMessage:
  388. {
  389. traceLastFunc("RPC_ClientMessage");
  390. if (!set.anti_spam && !set.chatbox_logging) break;
  391.  
  392. BitStream bsData(rpcParams->input, rpcParams->numberOfBitsOfData / 8, false);
  393. uint32_t dwStrLen, dwColor;
  394. char szMsg[256];
  395. static char last_servermsg[256];
  396. static DWORD allow_show_again = 0;
  397.  
  398. if (cheat_state->_generic.cheat_panic_enabled)
  399. break;
  400.  
  401. bsData.Read(dwColor);
  402. bsData.Read(dwStrLen);
  403. if (dwStrLen >= sizeof(szMsg)) dwStrLen = sizeof(szMsg) - 1;
  404. bsData.Read(szMsg, dwStrLen);
  405. szMsg[dwStrLen] = '\0';
  406.  
  407. if (set.anti_spam && (strcmp(last_servermsg, szMsg) == 0 && GetTickCount() < allow_show_again))
  408. return; // exit without processing rpc
  409.  
  410. // might be a personal message by muted player - look for name in server message
  411. // ignore message, if name was found
  412. if (set.anti_spam && g_iNumPlayersMuted > 0)
  413. {
  414. int i, j;
  415. char *playerName = NULL;
  416. for (i = 0, j = 0; i < SAMP_MAX_PLAYERS && j < g_iNumPlayersMuted; i++)
  417. {
  418. if (g_bPlayerMuted[i])
  419. {
  420. playerName = (char *)getPlayerName(i);
  421.  
  422. if (playerName == NULL)
  423. {
  424. // Player not connected anymore - remove player from muted list
  425. g_bPlayerMuted[i] = false;
  426. g_iNumPlayersMuted--;
  427. continue;
  428. }
  429. else if (strstr(szMsg, playerName) != NULL)
  430. {
  431. return;
  432. }
  433. j++;
  434. }
  435. }
  436. }
  437. if (set.chatbox_logging)
  438. LogChatbox(false, "%s", szMsg);
  439. strncpy_s(last_servermsg, szMsg, sizeof(last_servermsg) - 1);
  440. allow_show_again = GetTickCount() + 5000;
  441. break;
  442. }
  443. case RPC_Chat:
  444. {
  445. traceLastFunc("RPC_Chat");
  446. //if (!set.anti_spam && !set.chatbox_logging) break;
  447.  
  448. BitStream bsData(rpcParams->input, rpcParams->numberOfBitsOfData / 8, false);
  449. static char last_clientmsg[SAMP_MAX_PLAYERS][256];
  450. static DWORD allow_show_again = 0;
  451. uint16_t playerId = uint16_t(-1);
  452. uint8_t byteTextLen;
  453. char szText[256];
  454.  
  455. if (cheat_state->_generic.cheat_panic_enabled)
  456. break;
  457.  
  458. bsData.Read(playerId);
  459. if (isBadSAMPPlayerID(playerId))
  460. break;
  461.  
  462. bsData.Read(byteTextLen);
  463. bsData.Read(szText, byteTextLen);
  464. szText[byteTextLen] = '\0';
  465.  
  466. //if (set.anti_spam && ((strcmp(last_clientmsg[playerId], szText) == 0 && GetTickCount() < allow_show_again) || (g_iNumPlayersMuted > 0 && g_bPlayerMuted[playerId])))
  467. // return; // exit without processing rpc
  468.  
  469. // nothing to copy anymore, after chatbox_logging, so copy this before
  470. strncpy_s(last_clientmsg[playerId], szText, sizeof(last_clientmsg[playerId]) - 1);
  471.  
  472. if (set.chatbox_logging)
  473. LogChatbox(false, "%s: %s", getPlayerName(playerId), szText);
  474.  
  475. if (g_BotFuncs->BotSettings.bFollow
  476. && g_BotFuncs->BotSettings.bCopyChat
  477. && g_BotFuncs->BotSettings.UseFakeBot
  478. && OLCheats->Target_PlayerID == playerId)
  479. {
  480. uint8_t startBracket = 0, endBracket = 0;
  481. bool bCheckID = false;
  482. std::string message(szText);
  483.  
  484. bool bOpenBracket = false;
  485. for (int i = 0; i < 256; i++)
  486. {
  487. if (bOpenBracket)
  488. {
  489. if (szText[i] == ')')
  490. {
  491. bCheckID = true;
  492. endBracket = i;
  493. break;
  494. }
  495. }
  496. if (szText[i] == '(')
  497. {
  498. startBracket = i;
  499. bOpenBracket = true;
  500. }
  501. }
  502. if(bCheckID)
  503. message.replace(startBracket, endBracket - startBracket + 1, "");
  504. strcpy(szText, message.c_str());
  505. BitStream bsSend;
  506. BYTE byteTextLen = (BYTE)strlen(szText);
  507. bsSend.Write(byteTextLen);
  508. bsSend.Write(szText, byteTextLen);
  509. for (int i = g_BotFuncs->BotSettings.ClientCount - 1; i >= 0; i--)
  510. g_BotFuncs->OL_Bot_SendRPC(i, RPC_Chat, bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, false);
  511.  
  512. //say(szText);
  513. //cheat_state_text(szText);
  514. }
  515. //g_BotFuncs->BotClient[g_BotFuncs->BotSettings.ClientCount - 1]->pRakClient->RPC(&RPC, &bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, false, UNASSIGNED_NETWORK_ID, nullptr);
  516. //}
  517.  
  518. // ---- CUSTOM FOR ADMINS -----
  519.  
  520. //std::string message(szText);
  521. //std::string report = "reported";
  522. //if (message.find(report) != std::string::npos)
  523. //{
  524. // bool bOpenBracket = false;
  525. // std::string temp;
  526. // for (int i = message.find(report); i < 256; i++)
  527. // {
  528. // if (bOpenBracket)
  529. // {
  530. // if (szText[i] == ')')
  531. // break;
  532. // std::string temp2(1, szText[i]);
  533. // temp += temp2;
  534. // }
  535. // if (szText[i] == '(')
  536. // {
  537. // bOpenBracket = true;
  538. // bReportChecked = true;
  539. // }
  540. //
  541. // }
  542. // PlayerID = atoi(temp.c_str());
  543. //
  544. //}
  545. //allow_show_again = GetTickCount() + 5000;
  546. break;
  547. }
  548. case RPC_InitGame:
  549. {
  550. traceLastFunc("RPC_InitGame");
  551. RakNet::BitStream bsData(rpcParams->input, rpcParams->numberOfBitsOfData / 8, false);
  552.  
  553. bsData.SetReadOffset(363);
  554. bsData.Read(g_NewModSa->byteLagComp);
  555. break;
  556. }
  557. //case 44:
  558. // break;
  559. //case 47:
  560. // break;
  561. //case 58:
  562. // break;
  563. //case 36:
  564. // break;
  565. //case 108:
  566. // break;
  567. //case 86:
  568. // break;
  569. //case 137:
  570. // break;
  571. //case 138:
  572. // break;
  573. //case 69:
  574. // break;
  575. //case 55:
  576. // break;
  577. //case 166:
  578. // break;
  579. //case 43:
  580. // break;
  581. //case 165:
  582. // break;
  583. //case 113:
  584. // break;
  585. //case 164:
  586. // break;
  587. //case 95:
  588. // break;
  589. //case 63:
  590. // break;
  591. //case 134:
  592. // break;
  593. //case 135:
  594. // break;
  595. //case 24:
  596. // break;
  597. //case 99:
  598. // break;
  599. //case 106:
  600. // break;
  601. //case 84:
  602. // break;
  603. //case 96:
  604. // break;
  605. //case 32:
  606. // break;
  607. //case 163:
  608. // break;
  609. //case 156:
  610. // break;
  611. //case 72:
  612. // break;
  613. //case 11:
  614. // break;
  615. //default:
  616. // cheat_state_text("RPC Receive Log: %d", id);
  617. // Log("RPC Receive Log: %d", id);
  618. // break;
  619. } // switch
  620.  
  621. }
  622. callback(rpcParams);
  623. }
  624.  
  625.  
  626.  
  627.  
  628. bool OnSendRPC(int uniqueID, BitStream *parameters, PacketPriority priority, PacketReliability reliability, char orderingChannel, bool shiftTimestamp)
  629. {
  630.  
  631. //if (OLCheats->bSilentAim && uniqueID == RPC_GiveTakeDamage)
  632. //{
  633. // bool bGive;
  634. // parameters->Read(bGive);
  635. // if (!bGive)
  636. // return false;
  637. //}
  638. //if (uniqueID == RPC_SetInteriorId)
  639. //{
  640. // BYTE byteInteriorID;
  641. // parameters->Read(byteInteriorID);
  642. // cheat_state_text("SetInteriorId %d", byteInteriorID);
  643. // Log("SetInteriorId %d", byteInteriorID);
  644. //}
  645. //
  646. //if (uniqueID == RPC_SetPlayerInterior)
  647. //{
  648. // BYTE byteInteriorID;
  649. // parameters->Read(byteInteriorID);
  650. // cheat_state_text("RPC_SetPlayerInterior %d", byteInteriorID);
  651. // Log("RPC_SetPlayerInterior %d", byteInteriorID);
  652. //}
  653. //Log("RPC Send Log: %d", uniqueID);
  654. //cheat_state_text("RPC Send Log: %d", uniqueID);
  655.  
  656. //if (uniqueID == 168)
  657. //{
  658. // cheat_state_text("dasdsdasasd");
  659. // return false;
  660. //}
  661. //if (uniqueID == RPC_Death)
  662. //{
  663. // BYTE Reason;
  664. // USHORT Killer;
  665. // parameters->Read(Reason);
  666. // parameters->Read(Killer);
  667. // Log("reason = %d", Reason);
  668. // Log("killer = %d", Killer);
  669. //}
  670. /*
  671. if (uniqueID == RPC_UpdateScoresPingsIPs)
  672. {
  673. Log("RPC_UpdateScoresPingsIPs SENT");
  674. cheat_state_text("RPC_UpdateScoresPingsIPs SENT");
  675. }*/
  676.  
  677. if (uniqueID == RPC_ClientJoin)
  678. {
  679.  
  680. BYTE byteAuthBSLen;
  681. char auth_bs[64] = { 0 };
  682. char szClientVer[] = "0.3.7";
  683. BYTE iClientVerLen = sizeof(szClientVer) - 1;
  684. parameters->Read(g_NewModSa->iVersion);
  685. parameters->Read(g_NewModSa->byteMod);
  686. parameters->Read(g_NewModSa->byteNameLen);
  687. parameters->Read(g_NewModSa->szNickName, g_NewModSa->byteNameLen);
  688. parameters->Read(g_NewModSa->Challenge);
  689. parameters->Read(byteAuthBSLen);
  690. parameters->Read(auth_bs, byteAuthBSLen);
  691. parameters->Read(iClientVerLen);
  692. parameters->Read(szClientVer, iClientVerLen);
  693. parameters->Reset();
  694. Log("byteAuthBSLen %d", byteAuthBSLen);
  695. Log("auth_bs %s", auth_bs);
  696.  
  697. //Log("%d", &OLCheats->bChangeGPCI);
  698. if(OLCheats->bChangeGPCIa)
  699. gen_rand_gpci(auth_bs, 0x3E9);
  700.  
  701. byteAuthBSLen = (BYTE)strlen(auth_bs);
  702.  
  703. parameters->Write(g_NewModSa->iVersion);
  704. parameters->Write(g_NewModSa->byteMod);
  705. parameters->Write(g_NewModSa->byteNameLen);
  706. parameters->Write(g_NewModSa->szNickName, g_NewModSa->byteNameLen);
  707.  
  708. parameters->Write(g_NewModSa->Challenge);
  709. parameters->Write(byteAuthBSLen);
  710. parameters->Write(auth_bs, byteAuthBSLen);
  711.  
  712. parameters->Write(iClientVerLen);
  713. parameters->Write(szClientVer, iClientVerLen);
  714. Log("NEW byteAuthBSLen %d", byteAuthBSLen);
  715. Log("NEW auth_bs %s", auth_bs);
  716. cheat_state_text("serial spoofed");
  717. }
  718.  
  719. //f (uniqueID == RPC_InitGame)
  720. //
  721. // BitStream bsData(parameters->input, parameters->numberOfBitsOfData / 8, false);
  722. // parameters->SetReadOffset(363);
  723. // parameters->Read(g_NewModSa->byteLagComp);
  724. //
  725. //
  726. if (uniqueID == RPC_Chat && g_Players != nullptr)
  727. {
  728. uint8_t byteTextLen;
  729. char szText[256];
  730.  
  731. parameters->Read(byteTextLen);
  732. parameters->Read(szText, byteTextLen);
  733. szText[byteTextLen] = '\0';
  734.  
  735. if (OLCheats->bShowOLChat)
  736. {
  737. OL_Chat_Send(szText);
  738. return false;
  739. }
  740.  
  741. if (set.chatbox_logging)
  742. LogChatbox(false, "%s: %s", getPlayerName(g_Players->sLocalPlayerID), szText);
  743.  
  744. if (g_BotFuncs->BotSettings.bCopyChat
  745. && !g_BotFuncs->BotSettings.UseFakeBot
  746. && g_BotFuncs->BotSettings.bFollow)
  747. {
  748. BitStream bsSend;
  749. BYTE byteTextLen = (BYTE)strlen(szText);
  750. bsSend.Write(byteTextLen);
  751. bsSend.Write(szText, byteTextLen);
  752. for (int i = g_BotFuncs->BotSettings.ClientCount - 1; i >= 0; i--)
  753. g_BotFuncs->OL_Bot_SendRPC(i, RPC_Chat, bsSend, HIGH_PRIORITY, RELIABLE_ORDERED, 0, false);
  754. }
  755. }
  756.  
  757. //if (OLCheats->bSilentAim && uniqueID == RPC_GiveTakeDamage)
  758. // return false;
  759. if (uniqueID == RPC_GiveTakeDamage)
  760. {
  761. bool bGive;
  762. parameters->Read(bGive);
  763. if (!bGive && OLCheats->bSilentAim)
  764. return false;
  765. //}
  766. //bool bGive;
  767. USHORT PlayerID;
  768. float fAmmount;
  769. int WeaponID;
  770. int BodyPart;
  771. //parameters->Read(bGive);
  772. parameters->Read(PlayerID);
  773. parameters->Read(fAmmount);
  774. parameters->Read(WeaponID);
  775. parameters->Read(BodyPart);
  776.  
  777. }
  778.  
  779. if (uniqueID == RPC_ClientCheck && cheat_state && cheat_state->_generic.hp_cheat)
  780. {
  781. uint8_t type = 0;
  782. parameters->Read(type);
  783. if (type == 2)
  784. {
  785. uint32_t arg = 0;
  786. uint8_t response = 0;
  787. parameters->Read(arg);
  788. parameters->Read(response);
  789.  
  790. // remove invulnerability flags from our real flags
  791. uint32_t fakeFlags = arg & (0xFF00FFFF | ((~ACTOR_FLAGS_INVULNERABLE) << 16));
  792.  
  793. // reform packet data
  794. parameters->SetWriteOffset(0);
  795. parameters->Write(type);
  796. parameters->Write(fakeFlags);
  797. parameters->Write(response);
  798. }
  799. }
  800.  
  801. if (set.netPatchAssoc[uniqueID][OUTCOMING_RPC] != nullptr && set.netPatchAssoc[uniqueID][OUTCOMING_RPC]->enabled)
  802. return false;
  803.  
  804. if (g_BotFuncs->BotSettings.bCopyRPC
  805. && g_BotFuncs->BotSettings.bFollow)
  806. {
  807. for (int i = g_BotFuncs->BotSettings.ClientCount - 1; i >= 0; i--)
  808. g_BotFuncs->OL_Bot_SendRPC(i, uniqueID, *parameters, HIGH_PRIORITY, RELIABLE_ORDERED, 0, false);
  809. }
  810.  
  811.  
  812.  
  813.  
  814. return true;
  815. }
  816.  
  817.  
  818.  
  819. bool OnSendPacket(BitStream *parameters, PacketPriority priority, PacketReliability reliability, char orderingChannel)
  820. {
  821. if (OLCheats->bFakeLagSync)
  822. {
  823. static DWORD SyncTick = GetTickCount();
  824. if (GetTickCount() - SyncTick > OLCheats->dwTimeFakeLagSync)
  825. {
  826. if ((GetTickCount() - SyncTick) > (OLCheats->dwTimeFakeLagSync + OLCheats->dwTimeFakeLagDesync))
  827. {
  828. SyncTick = GetTickCount();
  829. }
  830. else
  831. {
  832. if (!(OLCheats->bSyncWhenAim && g_Players->pLocalPlayer->onFootData.stSampKeys.keys_aim))
  833. {
  834. return false;
  835. }
  836. else
  837. {
  838. cheat_state_text("Sync beacuse you are aiming");
  839. }
  840. }
  841. }
  842. }
  843. if (OLCheats->bPlaneCrasher
  844. || OLCheats->bVortexCrasher
  845. || OLCheats->bPlaneCrasher2
  846. || OLCheats->bVortexCrasher2
  847. || OLCheats->bStuntCrasher
  848. || OLCheats->bVehicleBugger
  849. || OLCheats->bDetonatorCrasher
  850. || OLCheats->bTrailerGrabber)
  851. return false;
  852. //if (OLCheats->bKickPassenger)
  853. // return false;
  854.  
  855. uint8_t packetId;
  856. parameters->Read(packetId);
  857. bool bEditFootSync = false;
  858. bool bEditAimSync = false;
  859. bool bEditVehicleSync = false;
  860. bool bEditBulletSync = false;
  861. switch (packetId)
  862. {
  863. case ID_SPECTATOR_SYNC:
  864. stSpectatorData SpectatorData;
  865. parameters->ResetReadPointer();
  866. parameters->Read(packetId);
  867. parameters->Read((char *)&SpectatorData, sizeof(stSpectatorData));
  868. /*
  869. cheat_state_text("%f\n%f\n%f\n%d",
  870. SpectatorData.fPosition[0],
  871. SpectatorData.fPosition[1],
  872. SpectatorData.fPosition[2],
  873. SpectatorData.sLeftRightKeys);
  874. */
  875. parameters->Reset();
  876. parameters->Write((BYTE)ID_SPECTATOR_SYNC);
  877. parameters->Write((PCHAR)&SpectatorData, sizeof(stSpectatorData));
  878. g_RakFuncs->Send(parameters, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0);
  879. return false;
  880. break;
  881.  
  882. case ID_PLAYER_SYNC:
  883. if (OLCheats->bBypassAimAntiCheat2
  884. || OLCheats->bInvertWalk
  885. || OLCheats->bInvertWalk2
  886. || OLCheats->bFakeLagSpeed
  887. || OLCheats->bPlayerHologram
  888. || OLCheats->bWheelWalk)
  889. {
  890. stOnFootData OnFootData;
  891. parameters->ResetReadPointer();
  892. parameters->Read(packetId);
  893. parameters->Read((char *)&OnFootData, sizeof(stOnFootData));
  894.  
  895. if (OLCheats->bBypassAimAntiCheat2)
  896. {
  897. bEditFootSync = true;
  898. if (g_Players->pLocalPlayer->onFootData.stSampKeys.keys_primaryFire
  899. || g_Players->pLocalPlayer->onFootData.stSampKeys.keys_secondaryFire__shoot)
  900. {
  901. OnFootData.sKeys = 4;
  902. }
  903. }
  904.  
  905. if (OLCheats->bWheelWalk)
  906. {
  907. static float fAngle = 0;
  908. float fZero[3] = { 0.0f, 0.0f, 0.0f };
  909. fAngle += vect3_dist(fZero, OnFootData.fMoveSpeed) * 2.f;
  910. bEditFootSync = true;
  911. D3DXQUATERNION Quat, Quat2;
  912. Quat.w = OnFootData.fQuaternion[0];
  913. Quat.x = OnFootData.fQuaternion[1];
  914. Quat.y = OnFootData.fQuaternion[2];
  915. Quat.z = OnFootData.fQuaternion[3];
  916. //
  917. D3DXVECTOR3 Axis;
  918. Axis.x = 1;
  919. Axis.y = 0;
  920. Axis.z = 0;
  921. D3DXQuaternionRotationAxis(&Quat2, &Axis, fAngle);
  922. D3DXQuaternionMultiply(&Quat, &Quat, &Quat2);
  923. OnFootData.fQuaternion[0] = Quat.w;
  924. OnFootData.fQuaternion[1] = Quat.x;
  925. OnFootData.fQuaternion[2] = Quat.y;
  926. OnFootData.fQuaternion[3] = Quat.z;
  927. OnFootData.sCurrentAnimationID = 1068;
  928. OnFootData.sAnimFlags = 4356;
  929. }
  930.  
  931. if (OLCheats->bInvertWalk)
  932. {
  933. bEditFootSync = true;
  934.  
  935. D3DXQUATERNION Quat, Quat2;
  936. Quat.w = OnFootData.fQuaternion[0];
  937. Quat.x = OnFootData.fQuaternion[1];
  938. Quat.y = OnFootData.fQuaternion[2];
  939. Quat.z = OnFootData.fQuaternion[3];
  940. //
  941. D3DXVECTOR3 Axis;
  942. Axis.x = 0;
  943. Axis.y = 1;
  944. Axis.z = 0;
  945. D3DXQuaternionRotationAxis(&Quat2, &Axis, M_PI);
  946. D3DXQuaternionMultiply(&Quat, &Quat, &Quat2);
  947. OnFootData.fQuaternion[0] = Quat.w;
  948. OnFootData.fQuaternion[1] = Quat.x;
  949. OnFootData.fQuaternion[2] = Quat.y;
  950. OnFootData.fQuaternion[3] = Quat.z;
  951.  
  952. }
  953.  
  954. if (OLCheats->bInvertWalk2)
  955. {
  956. bEditFootSync = true;
  957.  
  958. D3DXQUATERNION Quat;
  959. D3DXQUATERNION Quat2;
  960. Quat.w = OnFootData.fQuaternion[0];
  961. Quat.x = OnFootData.fQuaternion[1];
  962. Quat.y = OnFootData.fQuaternion[2];
  963. Quat.z = OnFootData.fQuaternion[3];
  964. //
  965. D3DXVECTOR3 Axis;
  966. Axis.x = 0;
  967. Axis.y = 0;
  968. Axis.z = 1;
  969. D3DXQuaternionRotationAxis(&Quat2, &Axis, M_PI);
  970. D3DXQuaternionMultiply(&Quat, &Quat, &Quat2);
  971. OnFootData.fQuaternion[0] = Quat.w;
  972. OnFootData.fQuaternion[1] = Quat.x;
  973. OnFootData.fQuaternion[2] = Quat.y;
  974. OnFootData.fQuaternion[3] = Quat.z;
  975.  
  976. }
  977. if (OLCheats->bFakeLagSpeed)
  978. {
  979. bEditFootSync = true;
  980. //stOnFootData OnFootData;
  981. //memcpy(&OnFootData, &g_Players->pLocalPlayer->onFootData, sizeof(stOnFootData));
  982. OnFootData.fMoveSpeed[0] *= OLCheats->fMultiplierFakeSpeed;
  983. OnFootData.fMoveSpeed[1] *= OLCheats->fMultiplierFakeSpeed;
  984.  
  985. //parameters->Reset();
  986. //parameters->Write((BYTE)ID_PLAYER_SYNC);
  987. //parameters->Write((PCHAR)&OnFootData, sizeof(stOnFootData));
  988. //g_RakFuncs->Send(parameters, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0);
  989. //return false;
  990. }
  991. if (OLCheats->bPlayerHologram)
  992. {
  993. bEditFootSync = true;
  994. //stOnFootData OnFootData;
  995. //memcpy(&OnFootData, &g_Players->pLocalPlayer->onFootData, sizeof(stOnFootData));
  996. OnFootData.byteSpecialAction = 3;
  997. //parameters->Reset();
  998. //parameters->Write((BYTE)ID_PLAYER_SYNC);
  999. //parameters->Write((PCHAR)&OnFootData, sizeof(stOnFootData));
  1000. //g_RakFuncs->Send(parameters, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0);
  1001. }
  1002. if (bEditFootSync)
  1003. {
  1004. parameters->Reset();
  1005. parameters->Write((BYTE)ID_PLAYER_SYNC);
  1006. parameters->Write((PCHAR)&OnFootData, sizeof(stOnFootData));
  1007. g_RakFuncs->Send(parameters, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0);
  1008. return false;
  1009. }
  1010. }
  1011. break;
  1012. case ID_VEHICLE_SYNC:
  1013. if (OLCheats->bDoorStorm)
  1014. return false;
  1015. stInCarData InCar;
  1016. memcpy(&InCar, &g_Players->pLocalPlayer->inCarData, sizeof(stInCarData));
  1017. if (OLCheats->bInvisibleBike || OLCheats->bInvisibleBike2)
  1018. {
  1019. //parameters->ResetReadPointer();
  1020. //parameters->Read(packetId);
  1021. //parameters->Read((PCHAR)&InCar, sizeof(stInCarData)); don't work
  1022. bEditVehicleSync = true;
  1023. InCar.byteCurrentWeapon = 0;
  1024. InCar.fTrainSpeed = NAN;
  1025. }
  1026. if (OLCheats->bInvertWalk)
  1027. {
  1028. bEditVehicleSync = true;
  1029. D3DXQUATERNION Quat;
  1030. D3DXQUATERNION Quat2;
  1031. Quat.w = InCar.fQuaternion[0];
  1032. Quat.x = InCar.fQuaternion[1];
  1033. Quat.y = InCar.fQuaternion[2];
  1034. Quat.z = InCar.fQuaternion[3];
  1035. //
  1036. D3DXVECTOR3 Axis;
  1037. Axis.x = 0;
  1038. Axis.y = 1;
  1039. Axis.z = 0;
  1040. D3DXQuaternionRotationAxis(&Quat2, &Axis, M_PI);
  1041. D3DXQuaternionMultiply(&Quat, &Quat, &Quat2);
  1042. InCar.fQuaternion[0] = Quat.w;
  1043. InCar.fQuaternion[1] = Quat.x;
  1044. InCar.fQuaternion[2] = Quat.y;
  1045. InCar.fQuaternion[3] = Quat.z;
  1046. }
  1047. if (OLCheats->bInvertWalk2)
  1048. {
  1049. bEditVehicleSync = true;
  1050. D3DXQUATERNION Quat;
  1051. D3DXQUATERNION Quat2;
  1052. Quat.w = InCar.fQuaternion[0];
  1053. Quat.x = InCar.fQuaternion[1];
  1054. Quat.y = InCar.fQuaternion[2];
  1055. Quat.z = InCar.fQuaternion[3];
  1056. //
  1057. D3DXVECTOR3 Axis;
  1058. Axis.x = 0;
  1059. Axis.y = 0;
  1060. Axis.z = 1;
  1061. D3DXQuaternionRotationAxis(&Quat2, &Axis, M_PI);
  1062. D3DXQuaternionMultiply(&Quat, &Quat, &Quat2);
  1063. InCar.fQuaternion[0] = Quat.w;
  1064. InCar.fQuaternion[1] = Quat.x;
  1065. InCar.fQuaternion[2] = Quat.y;
  1066. InCar.fQuaternion[3] = Quat.z;
  1067. }
  1068.  
  1069. if (bEditVehicleSync)
  1070. {
  1071. parameters->Reset();
  1072. parameters->Write((BYTE)ID_VEHICLE_SYNC);
  1073. parameters->Write((PCHAR)&InCar, sizeof(stInCarData));
  1074. g_RakFuncs->Send(parameters, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0);
  1075. return false;
  1076. }
  1077. break;
  1078. case ID_BULLET_SYNC:
  1079. /*
  1080. if (1)
  1081. {
  1082. stBulletData BulletData;
  1083. parameters->ResetReadPointer();
  1084. parameters->Read(packetId);
  1085. parameters->Read((PCHAR)&BulletData, sizeof(stBulletData));
  1086. Log("BulletData.byteType = %d", BulletData.byteType);
  1087. Log("BulletData.byteWeaponID = %d", BulletData.byteWeaponID);
  1088. Log("BulletData.fCenter[0] = %f", BulletData.fCenter[0]);
  1089. Log("BulletData.fCenter[1] = %f", BulletData.fCenter[1]);
  1090. Log("BulletData.fCenter[2] = %f", BulletData.fCenter[2]);
  1091. Log("BulletData.fOrigin[0] = %f", BulletData.fOrigin[0]);
  1092. Log("BulletData.fOrigin[1] = %f", BulletData.fOrigin[1]);
  1093. Log("BulletData.fOrigin[2] = %f", BulletData.fOrigin[2]);
  1094. Log("BulletData.fTarget[0] = %f", BulletData.fTarget[0]);
  1095. Log("BulletData.fTarget[1] = %f", BulletData.fTarget[1]);
  1096. Log("BulletData.fTarget[2] = %f", BulletData.fTarget[2]);
  1097. Log("BulletData.sTargetID = %d", BulletData.sTargetID);
  1098. }*/
  1099. if (OLCheats->bSilentAim || OLCheats->bFixInvisibleFire)
  1100. {
  1101. stBulletData BulletData;
  1102. parameters->ResetReadPointer();
  1103. parameters->Read(packetId);
  1104. parameters->Read((PCHAR)&BulletData, sizeof(stBulletData));
  1105. if (g_NewModSa->byteLagComp && OLCheats->bSilentAim)
  1106. {
  1107. if (g_NewModSa->iAimPlayerID == -1)
  1108. return true;
  1109. if (!IsPlayerStreamed(g_NewModSa->iAimPlayerID))
  1110. return true;
  1111. BulletData.byteType = 1;
  1112. vect3_copy(&g_Players->pRemotePlayer[g_NewModSa->iAimPlayerID]->pPlayerData->pSAMP_Actor->pGTA_Ped->base.matrix[12],
  1113. BulletData.fOrigin);
  1114. vect3_copy(&g_Players->pRemotePlayer[g_NewModSa->iAimPlayerID]->pPlayerData->pSAMP_Actor->pGTA_Ped->base.matrix[12],
  1115. BulletData.fTarget);
  1116. if (OLCheats->fInaccurateAim > 0)
  1117. {
  1118. if (g_Players->pRemotePlayer[g_NewModSa->iAimPlayerID]->pPlayerData->bytePlayerState == PLAYER_STATE_ONFOOT)
  1119. {
  1120. BulletData.fCenter[0] = (OLCheats->fInaccurateAim / 2) - ((rand() % (int)(OLCheats->fInaccurateAim * 10.0f) / 100.0f));
  1121. BulletData.fCenter[1] = (OLCheats->fInaccurateAim / 2) - ((rand() % (int)(OLCheats->fInaccurateAim * 10.0f) / 100.0f));
  1122. BulletData.fCenter[2] = 0.50f - ((rand() % 100) / 100.0f);
  1123. }
  1124. else
  1125. {
  1126. BulletData.fCenter[0] = 0.0f;
  1127. BulletData.fCenter[1] = 0.0f;
  1128. BulletData.fCenter[2] = 0.56 - ((rand() % 5) / 100.0f);
  1129. }
  1130. }
  1131. else
  1132. {
  1133. BulletData.fCenter[0] = 0;
  1134. BulletData.fCenter[1] = 0;
  1135. if (g_Players->pRemotePlayer[g_NewModSa->iAimPlayerID]->pPlayerData->bytePlayerState == PLAYER_STATE_ONFOOT)
  1136. {
  1137. BulletData.fCenter[2] = 0;
  1138. }
  1139. else
  1140. {
  1141. BulletData.fCenter[2] = 0.56 - ((rand() % 5) / 100.0f);
  1142. }
  1143. }
  1144. BulletData.sTargetID = g_NewModSa->iAimPlayerID;
  1145. if (OLCheats->bBypassAimAntiCheat)
  1146. {
  1147. uint8_t random_ac_bypass = rand() % 3;
  1148. if (random_ac_bypass == 1)
  1149. {
  1150. BitStream bsGiveDamage;
  1151. bsGiveDamage.Write(false);
  1152. bsGiveDamage.Write((USHORT)g_NewModSa->iAimPlayerID);
  1153. bsGiveDamage.Write(fWeaponDamage[g_Players->pLocalPlayer->byteCurrentWeapon]);
  1154. bsGiveDamage.Write((int)g_Players->pLocalPlayer->byteCurrentWeapon);
  1155. //Log("Custom Send: damage %f, player %d, weapon %d", fWeaponDamage[g_Players->pLocalPlayer->byteCurrentWeapon], g_NewModSa->iAimPlayerID, g_Players->pLocalPlayer->byteCurrentWeapon);
  1156. bsGiveDamage.Write((rand() % 7) + 3);
  1157. g_RakFuncs->RPC(RPC_GiveTakeDamage, &bsGiveDamage, HIGH_PRIORITY, RELIABLE_SEQUENCED, NULL, false);
  1158. }
  1159. else
  1160. {
  1161. BulletData.byteType = 0;
  1162. }
  1163.  
  1164. }
  1165. else
  1166. {
  1167. if (g_Players->pRemotePlayer[g_NewModSa->iAimPlayerID]->pPlayerData->pSAMP_Actor->pGTA_Ped->hitpoints != 0)
  1168. {
  1169. BitStream bsGiveDamage;
  1170. bsGiveDamage.Write(false);
  1171. bsGiveDamage.Write((USHORT)g_NewModSa->iAimPlayerID);
  1172. bsGiveDamage.Write(fWeaponDamage[g_Players->pLocalPlayer->byteCurrentWeapon]);
  1173. bsGiveDamage.Write((int)g_Players->pLocalPlayer->byteCurrentWeapon);
  1174. //Log("Custom Send: damage %f, player %d, weapon %d", fWeaponDamage[g_Players->pLocalPlayer->byteCurrentWeapon], g_NewModSa->iAimPlayerID, g_Players->pLocalPlayer->byteCurrentWeapon);
  1175. bsGiveDamage.Write((rand() % 7) + 3);
  1176. g_RakFuncs->RPC(RPC_GiveTakeDamage, &bsGiveDamage, HIGH_PRIORITY, RELIABLE_SEQUENCED, NULL, false);
  1177. }
  1178. }
  1179. bEditBulletSync = true;
  1180. }
  1181.  
  1182. if (OLCheats->bFixInvisibleFire)
  1183. {
  1184. BulletData.byteWeaponID = 34;
  1185. bEditBulletSync = true;
  1186. }
  1187. if (bEditBulletSync)
  1188. {
  1189. parameters->Reset();
  1190. parameters->Write((BYTE)ID_BULLET_SYNC);
  1191. parameters->Write((PCHAR)&BulletData, sizeof(stBulletData));
  1192. g_RakFuncs->Send(parameters, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0);
  1193. return false;
  1194. }
  1195. }
  1196. break;
  1197. case ID_AIM_SYNC:
  1198. //if (1)
  1199. //{
  1200. // stAimData AimData;
  1201. // parameters->ResetReadPointer();
  1202. // parameters->Read(packetId);
  1203. // parameters->Read((PCHAR)&AimData, sizeof(stAimData));
  1204. // cheat_state_text("%d", AimData.byteCamMode);
  1205. //}
  1206.  
  1207. if (OLCheats->bSilentAim || OLCheats->bInvalidAimZ)
  1208. {
  1209.  
  1210. stAimData AimData;
  1211. parameters->ResetReadPointer();
  1212. parameters->Read(packetId);
  1213. parameters->Read((PCHAR)&AimData, sizeof(stAimData));
  1214. if (OLCheats->bSilentAim)
  1215. {
  1216. bEditAimSync = true;
  1217. if (g_NewModSa->iAimPlayerID == -1)
  1218. return true;
  1219. if (!IsPlayerStreamed(g_NewModSa->iAimPlayerID)
  1220. || /* of course*/ (g_Players->pLocalPlayer->onFootData.byteCurrentWeapon == 40))// he.. he
  1221. return true;
  1222.  
  1223. if (g_NewModSa->byteLagComp)
  1224. {
  1225.  
  1226. if (OLCheats->bShotWall)
  1227. {
  1228. AimData.byteCamMode = 55;
  1229. if (OLCheats->bBypassAimAntiCheat)
  1230. {
  1231. AimData.vecAimf1[0] = g_Players->pLocalPlayer->aimData.vecAimf1[0];
  1232. AimData.vecAimf1[1] = g_Players->pLocalPlayer->aimData.vecAimf1[1];
  1233. AimData.vecAimf1[2] = g_Players->pLocalPlayer->aimData.vecAimf1[2] + 0.25f;
  1234. }
  1235. else
  1236. {
  1237.  
  1238. AimData.vecAimf1[0] = 0;
  1239. AimData.vecAimf1[1] = 0;
  1240. AimData.vecAimf1[2] = -0.01f;
  1241.  
  1242. }
  1243. vect3_copy(&g_Players->pRemotePlayer[g_NewModSa->iAimPlayerID]->pPlayerData->pSAMP_Actor->pGTA_Ped->base.matrix[12],
  1244. AimData.vecAimPos);
  1245. }
  1246. }
  1247. else
  1248. {
  1249. //lagcomp off
  1250. //AimData.byteCamMode = 65; //work with all weapon and sniper
  1251.  
  1252.  
  1253. if (!IsPlayerStreamed(g_NewModSa->iAimPlayerID))
  1254. return true;
  1255.  
  1256. float fEnemyPos[3], fSelfPos[3];
  1257.  
  1258. OL_CalculateLagPosition(g_NewModSa->iAimPlayerID, fEnemyPos);
  1259.  
  1260. //OL_CalculateAimf1(fEnemyPos, AimData.vecAimPos, AimData.vecAimf1);
  1261.  
  1262. //AimData.fAimZ = 0.0f;
  1263.  
  1264. vect3_copy(&g_Players->pRemotePlayer[g_NewModSa->iAimPlayerID]->pPlayerData->pSAMP_Actor->pGTA_Ped->base.matrix[12],
  1265. fEnemyPos);
  1266. vect3_copy(&g_Players->pLocalPlayer->pSAMP_Actor->pGTA_Ped->base.matrix[12],
  1267. fSelfPos);
  1268. AimData.vecAimf1[0] = 0;
  1269. //AimData.vecAimf1[1] = 0; uhmmm problems with height
  1270. AimData.vecAimf1[1] = 0;//((fEnemyPos[2] - 3.5f) > fSelfPos[2]) ? 1.0f : 0.f;
  1271. AimData.vecAimf1[2] = ((fEnemyPos[2] - 3.5f) > fSelfPos[2]) ? 1.0f : -0.01f;//-0.01f;
  1272.  
  1273. vect3_copy(&g_Players->pRemotePlayer[g_NewModSa->iAimPlayerID]->pPlayerData->pSAMP_Actor->pGTA_Ped->base.matrix[12],
  1274. AimData.vecAimPos);
  1275.  
  1276. /* nub wey
  1277. AimData.vecAimPos[0] += g_Players->pRemotePlayer[g_NewModSa->iAimPlayerID]->pPlayerData->onFootData.fMoveSpeed[0]
  1278. * 10.97f;
  1279. AimData.vecAimPos[1] += g_Players->pRemotePlayer[g_NewModSa->iAimPlayerID]->pPlayerData->onFootData.fMoveSpeed[1]
  1280. * 10.97f;
  1281. AimData.vecAimPos[2] += 1.0f + g_Players->pRemotePlayer[g_NewModSa->iAimPlayerID]->pPlayerData->onFootData.fMoveSpeed[2]
  1282. * 10.97f;*/
  1283.  
  1284. OL_CalculateLagPosition(g_NewModSa->iAimPlayerID, AimData.vecAimPos);
  1285.  
  1286. }
  1287.  
  1288. }
  1289. if (OLCheats->bInvalidAimZ)
  1290. {
  1291. bEditAimSync = true;
  1292. AimData.fAimZ = NAN;
  1293. }
  1294.  
  1295. if (bEditAimSync)
  1296. {
  1297. parameters->Reset();
  1298. parameters->Write((BYTE)ID_AIM_SYNC);
  1299. parameters->Write((PCHAR)&AimData, sizeof(stAimData));
  1300. g_RakFuncs->Send(parameters, HIGH_PRIORITY, UNRELIABLE_SEQUENCED, 0);
  1301. return false;
  1302. }
  1303. }
  1304. break;
  1305. case ID_STATS_UPDATE:
  1306.  
  1307.  
  1308. if (OLCheats->bFakeFPS)
  1309. {
  1310. static int i = INT_MAX;
  1311. stStatsData StatsData;
  1312. parameters->ResetReadPointer();
  1313. parameters->Read(packetId);
  1314. parameters->Read((PCHAR)&StatsData, sizeof(stStatsData));
  1315. StatsData.iAmmo = i;
  1316. parameters->Reset();
  1317. parameters->Write((BYTE)ID_STATS_UPDATE);
  1318. parameters->Write((PCHAR)&StatsData, sizeof(stStatsData));
  1319. if (i == 0)
  1320. {
  1321. i = INT_MAX;
  1322. }
  1323. i -= OLCheats->iFPS;
  1324. if (i < 0)
  1325. i = 0;
  1326. }
  1327.  
  1328. break;
  1329. }
  1330.  
  1331.  
  1332. if (set.netPatchAssoc[packetId][OUTCOMING_PACKET] != nullptr && set.netPatchAssoc[packetId][OUTCOMING_PACKET]->enabled)
  1333. return false;
  1334. return true;
  1335. }
  1336.  
  1337.  
  1338.  
  1339. bool OnReceivePacket(Packet *p)
  1340. {
  1341. if (p->data == nullptr || p->length == 0)
  1342. return true;
  1343. if (set.netPatchAssoc[p->data[0]][INCOMING_PACKET] != nullptr && set.netPatchAssoc[p->data[0]][INCOMING_PACKET]->enabled)
  1344. return false;
  1345. if (p->data[0] == ID_MARKERS_SYNC) // packetId
  1346. {
  1347. BitStream bs(p->data, p->length, false);
  1348. int iNumberOfPlayers = 0;
  1349. uint16_t playerID = uint16_t(-1);
  1350. short sPos[3] = { 0, 0, 0 };
  1351. bool bIsPlayerActive = false;
  1352.  
  1353. bs.IgnoreBits(8);
  1354. bs.Read(iNumberOfPlayers);
  1355. if (iNumberOfPlayers < 0 || iNumberOfPlayers > SAMP_MAX_PLAYERS)
  1356. return true;
  1357.  
  1358. for (int i = 0; i < iNumberOfPlayers; i++)
  1359. {
  1360. bs.Read(playerID);
  1361. bs.ReadCompressed(bIsPlayerActive);
  1362. if (bIsPlayerActive == 0 || isBadSAMPPlayerID(playerID))
  1363. continue;
  1364. bs.Read(sPos);
  1365. g_stStreamedOutInfo.iPlayerID[playerID] = playerID;
  1366. g_stStreamedOutInfo.fPlayerPos[playerID][0] = sPos[0];
  1367. g_stStreamedOutInfo.fPlayerPos[playerID][1] = sPos[1];
  1368. g_stStreamedOutInfo.fPlayerPos[playerID][2] = sPos[2];
  1369. }
  1370. }
  1371. return true;
  1372. }
  1373.  
  1374. // commands below
  1375.  
  1376. void cmd_change_server(char *param) // 127.0.0.1 7777 Username Password
  1377. {
  1378. traceLastFunc("cmd_change_server()");
  1379.  
  1380. // bool success = false;
  1381.  
  1382. char IP[128], Nick[SAMP_MAX_PLAYER_NAME], Password[128] = "", Port[128];
  1383. int iPort;
  1384.  
  1385. int ipc = sscanf(param, "%s%s%s%s", IP, Port, Nick, Password);
  1386. if (ipc < 2)
  1387. {
  1388. addMessageToChatWindow("USAGE: /mod_change_server <ip> <port> <Username> <Server Password>");
  1389. addMessageToChatWindow("Variables that are set to \"NULL\" (capitalized) will be ignored.");
  1390. addMessageToChatWindow("If you set the Password to \"NULL\" it is set to <no server password>.");
  1391. addMessageToChatWindow("Username and password can also be left out completely.");
  1392. return;
  1393. }
  1394. if (stricmp(IP, "NULL") == NULL)
  1395. strcpy(IP, g_SAMP->szIP);
  1396.  
  1397. if (stricmp(Port, "NULL") == NULL)
  1398. iPort = g_SAMP->ulPort;
  1399. else
  1400. iPort = atoi(Port);
  1401.  
  1402. if (ipc > 2)
  1403. {
  1404. if (stricmp(Nick, "NULL") != NULL)
  1405. {
  1406. if (strlen(Nick) > SAMP_ALLOWED_PLAYER_NAME_LENGTH)
  1407. Nick[SAMP_ALLOWED_PLAYER_NAME_LENGTH] = '\0';
  1408. setLocalPlayerName(Nick);
  1409. }
  1410. }
  1411. if (ipc > 3)
  1412. {
  1413. if (stricmp(Password, "NULL") == NULL)
  1414. strcpy(Password, "");
  1415. }
  1416.  
  1417. changeServer(IP, iPort, Password);
  1418. }
  1419.  
  1420. void cmd_change_server_fav(char *param)
  1421. {
  1422. traceLastFunc("cmd_change_server_fav()");
  1423.  
  1424. if (strlen(param) == 0)
  1425. {
  1426. addMessageToChatWindow("/mod_fav_server <server name/part of server name>");
  1427. addMessageToChatWindow("In order to see the favorite server list type: /mod_fav_server list");
  1428. return;
  1429. }
  1430.  
  1431. if (strncmp(param, "list", 4) == 0)
  1432. {
  1433. int count = 0;
  1434. for (int i = 0; i < INI_SERVERS_MAX; i++)
  1435. {
  1436. if (set.server[i].server_name == NULL)
  1437. continue;
  1438.  
  1439. count++;
  1440. addMessageToChatWindow("%s", set.server[i].server_name);
  1441. }
  1442. if (count == 0)
  1443. addMessageToChatWindow("No servers in favorite server list. Edit the ini file to add some.");
  1444. return;
  1445. }
  1446.  
  1447. for (int i = 0; i < INI_SERVERS_MAX; i++)
  1448. {
  1449. if (set.server[i].server_name == NULL || set.server[i].ip == NULL
  1450. || strlen(set.server[i].ip) < 7 || set.server[i].port == 0)
  1451. continue;
  1452.  
  1453. if (!findstrinstr((char *)set.server[i].server_name, param))
  1454. continue;
  1455.  
  1456. if (!set.use_current_name)
  1457. setLocalPlayerName(set.server[i].nickname);
  1458.  
  1459. changeServer(set.server[i].ip, set.server[i].port, set.server[i].password);
  1460.  
  1461. return;
  1462. }
  1463.  
  1464. addMessageToChatWindow("/mod_fav_server <server name/part of server name>");
  1465. return;
  1466. }
  1467.  
  1468. void cmd_current_server(char *param)
  1469. {
  1470. addMessageToChatWindow("Server Name: %s", g_SAMP->szHostname);
  1471. addMessageToChatWindow("Server Address: %s:%i", g_SAMP->szIP, g_SAMP->ulPort);
  1472. addMessageToChatWindow("Username: %s", getPlayerName(g_Players->sLocalPlayerID));
  1473. }
  1474.  
  1475. void cmd_tele_loc(char *param)
  1476. {
  1477. if (strlen(param) == 0)
  1478. {
  1479. addMessageToChatWindow("USAGE: /mod_tele_loc <location name>");
  1480. addMessageToChatWindow("Use /mod_tele_locations to show the location names.");
  1481. addMessageToChatWindow("The more specific you are on location name the better the result.");
  1482. return;
  1483. }
  1484.  
  1485. for (int i = 0; i < STATIC_TELEPORT_MAX; i++)
  1486. {
  1487. if (strlen(set.static_teleport_name[i]) == 0 || vect3_near_zero(set.static_teleport[i].pos))
  1488. continue;
  1489.  
  1490. if (!findstrinstr(set.static_teleport_name[i], param))
  1491. continue;
  1492.  
  1493. cheat_state_text("Teleported to: %s.", set.static_teleport_name[i]);
  1494. cheat_teleport(set.static_teleport[i].pos, set.static_teleport[i].interior_id);
  1495. return;
  1496. }
  1497.  
  1498. addMessageToChatWindow("USAGE: /mod_tele_loc <location name>");
  1499. addMessageToChatWindow("Use /mod_tele_locations to show the location names.");
  1500. addMessageToChatWindow("The more specific you are on location name the better the result.");
  1501. }
  1502.  
  1503. void cmd_tele_locations(char *)
  1504. {
  1505. for (int i = 0; i < STATIC_TELEPORT_MAX; i++)
  1506. {
  1507. if (strlen(set.static_teleport_name[i]) == 0 || vect3_near_zero(set.static_teleport[i].pos))
  1508. continue;
  1509. addMessageToChatWindow("%s", set.static_teleport_name[i]);
  1510. }
  1511.  
  1512. addMessageToChatWindow("To teleport use the menu or: /mod_tele_loc <location name>");
  1513. }
  1514.  
  1515. void cmd_pickup(char *params)
  1516. {
  1517. if (!strlen(params))
  1518. {
  1519. addMessageToChatWindow("USAGE: /mod_pickup <pickup id>");
  1520. return;
  1521. }
  1522.  
  1523. g_RakFuncs->SendPickUp(atoi(params));
  1524. }
  1525.  
  1526. void cmd_setclass(char *params)
  1527. {
  1528. if (!strlen(params))
  1529. {
  1530. addMessageToChatWindow("USAGE: /mod_setclass <class id>");
  1531. return;
  1532. }
  1533.  
  1534. g_RakFuncs->RequestClass(atoi(params));
  1535. g_RakFuncs->SendSpawn();
  1536. }
  1537.  
  1538. void cmd_fakekill(char *params)
  1539. {
  1540. int killer, reason, amount;
  1541. if (!strlen(params) || sscanf(params, "%d%d%d", &killer, &reason, &amount) < 3)
  1542. return addMessageToChatWindow("USAGE: /mod_fakekill <killer id> <reason> <amount>");
  1543.  
  1544. if (amount < 1 || killer < 0 || killer > SAMP_MAX_PLAYERS)
  1545. return;
  1546.  
  1547. for (int i = 0; i < amount; i++)
  1548. g_RakFuncs->SendDeath(killer, reason);
  1549. }
  1550.  
  1551. void cmd_bot_animation(char *params)
  1552. {
  1553. int botID, animationID;
  1554. if (!strlen(params) || sscanf(params, "%d %d", &botID, &animationID) < 2)
  1555. return addMessageToChatWindow("USAGE: /.bot_anim <BOT ID> <Animation ID>");
  1556. g_BotFuncs->BotSettings.bBotPick = true;
  1557. g_BotFuncs->BotClient[botID].sCurrentAnimationID = animationID;
  1558. }
  1559.  
  1560. void cmd_nothing(char *params)
  1561. {
  1562. say("--> Download OverLight Mod <--");
  1563. }
  1564.  
  1565. void cmd_find_chat(char *params)
  1566. {
  1567. if (params[0] == '\0')
  1568. return addMessageToChatWindow("USAGE: /.find_chat <word>");
  1569. OLCheats->bFind = true;
  1570. OLCheats->WordFindChat = params;
  1571. }
  1572.  
  1573. void cmd_stop_find_chat(char *params)
  1574. {
  1575. OLCheats->bFind = false;
  1576. }
  1577.  
  1578. void cmd_fake_fps(char *params)
  1579. {
  1580. if (params[0] == '\0')
  1581. return addMessageToChatWindow("USAGE: /.fake_fps <value>");
  1582. int iFPS = atoi(params);
  1583. OLCheats->bFakeFPS = true;
  1584. OLCheats->iFPS = iFPS;
  1585. addMessageToChatWindow("Fake FPS value changed to: %d", iFPS);
  1586. }
  1587.  
  1588. void cmd_add_bot_nick(char *params)
  1589. {
  1590. if (params[0] == '\0')
  1591. return addMessageToChatWindow("USAGE: /.bot_nick nickname");
  1592. g_BotFuncs->OL_Add_Bot_Nick(params);
  1593. }
  1594.  
  1595. void cmd_bot_steal_nick(char *params)
  1596. {
  1597. if (params[0] == '\0')
  1598. return addMessageToChatWindow("USAGE: /.bot_steal_nick <player ID>");
  1599. int playerID = atoi(params);
  1600. g_BotFuncs->BotSettings.UseFakeBot = true;
  1601. OLCheats->Target_PlayerID = playerID;
  1602. g_BotFuncs->OL_Add_Bot();
  1603. }
  1604.  
  1605. void cmd_bot_ping_increase(char *params)
  1606. {
  1607. if (params[0] == '\0')
  1608. return addMessageToChatWindow("USAGE: /.bot_ping <value>, you can set big negative value for get ping 0");
  1609. int increasePing = atoi(params);
  1610. g_BotFuncs->BotSettings.FakePing = true;
  1611. g_BotFuncs->BotSettings.incrasePing = increasePing;
  1612. }
  1613.  
  1614. void cmd_bot_follow_anim(char *params)
  1615. {
  1616. if (params[0] == '\0')
  1617. return addMessageToChatWindow("USAGE: /.bot_fanim <Animation ID>");
  1618. int iAnimID = atoi(params);
  1619. g_BotFuncs->BotSettings.bBotFollowAnim = true;
  1620. g_BotFuncs->BotSettings.sBotFollowAnimID = iAnimID;
  1621. }
  1622.  
  1623. void cmd_add_friend(char *params)
  1624. {
  1625. if (params[0] == '\0')
  1626. return addMessageToChatWindow("USAGE: /.add_friend <player id>");
  1627. int playerid = atoi(params);
  1628.  
  1629. if (isBadSAMPPlayerID(playerid) || g_Players->iIsListed[playerid] != 1)
  1630. return addMessageToChatWindow("Player does not exist.");
  1631.  
  1632. std::ofstream outputFile;
  1633. char filename[512];
  1634. char *nick;
  1635. snprintf(filename, sizeof(filename), "%s\\" M0D_FOLDER "%s", g_szWorkingDirectory, "friends.ini");
  1636. outputFile.open(filename, std::fstream::out | std::fstream::app);
  1637.  
  1638. if (g_Players->pRemotePlayer[playerid]->iNameAllocated <= 0xF)
  1639. {
  1640. nick = g_Players->pRemotePlayer[playerid]->szPlayerName;
  1641. }
  1642. else
  1643. {
  1644. nick = g_Players->pRemotePlayer[playerid]->pszPlayerName;
  1645. }
  1646. outputFile << nick << "\n";
  1647. outputFile.close();
  1648. addMessageToChatWindow("Added %s [ID: %d]", nick, playerid);
  1649.  
  1650. }
  1651.  
  1652.  
  1653. void cmd_warp(char *params)
  1654. {
  1655. if (params[0] == '\0')
  1656. return addMessageToChatWindow("USAGE: /mod_warp <player id>");
  1657.  
  1658. int playerid = atoi(params);
  1659. if (isBadSAMPPlayerID(playerid) || g_Players->iIsListed[playerid] != 1)
  1660. return addMessageToChatWindow("Player does not exist.");
  1661.  
  1662. float pos[3];
  1663. actor_info *actor = nullptr;
  1664. if (g_Players->pRemotePlayer[playerid]->pPlayerData == nullptr
  1665. || g_Players->pRemotePlayer[playerid]->pPlayerData->pSAMP_Actor == nullptr)
  1666. {
  1667. if (vect3_near_zero(g_stStreamedOutInfo.fPlayerPos[playerid]))
  1668. return addMessageToChatWindow("Player is not streamed in.");
  1669.  
  1670. vect3_copy(g_stStreamedOutInfo.fPlayerPos[playerid], pos);
  1671. pos[1] += 1.0f;
  1672. cheat_teleport(pos, 0);
  1673. return;
  1674. }
  1675.  
  1676. if (!getPlayerPos(playerid, pos) ||
  1677. g_Players->pRemotePlayer[playerid]->pPlayerData == nullptr ||
  1678. g_Players->pRemotePlayer[playerid]->pPlayerData->pSAMP_Actor == nullptr ||
  1679. (actor = g_Players->pRemotePlayer[playerid]->pPlayerData->pSAMP_Actor->pGTA_Ped) == nullptr)
  1680. {
  1681. return addMessageToChatWindow("Bad player info.");
  1682. }
  1683.  
  1684. pos[1] += 1.0f;
  1685. cheat_teleport(pos, actor->base.interior_id);
  1686. }
  1687.  
  1688. void cmd_showCMDS(char *)
  1689. {
  1690. for (int i = 0; i < g_m0dCmdNum; i++)
  1691. {
  1692. addMessageToChatWindow("%s", g_m0dCmdlist[i]);
  1693. }
  1694. }
  1695.  
  1696. void cmd_ol_show_cmds(char *)
  1697. {
  1698. addMessageToChatWindow("/.add_friend <player ID> /.fake_fps <value fps> /.stick <id> /.ol_cmds");
  1699. addMessageToChatWindow("/.bot_nick <nickname> /.bot_steal_nick <player ID>");
  1700. addMessageToChatWindow("/.bot_ping <increase value> /.bot_anim <BOT ID> <Anim ID> /.bot_fanim <Anim ID>");
  1701. addMessageToChatWindow("/.find_chat <words> /.stop_find /.spec");
  1702. }
  1703.  
  1704.  
  1705. void cmd_stick(char *params)
  1706. {
  1707. cheat_state->actor.stick ^= true;
  1708. cheat_state->vehicle.stick ^= true;
  1709. if (params[0] == '\0')
  1710. return addMessageToChatWindow("USAGE: /.stick <player id>");
  1711. OLCheats->iStickID = atoi(params);
  1712. addMessageToChatWindow("Sticked");
  1713. }
  1714.  
  1715. void cmd_ol_spec(char *params)
  1716. {
  1717. int playerID = atoi(params);
  1718. g_Players->pLocalPlayer->iIsSpectating = 1;
  1719. g_Players->pLocalPlayer->iSpectateID = playerID;
  1720. g_Players->pLocalPlayer->iInitiatedSpectating = 1;
  1721. OLCheats->iSpectateID = playerID;
  1722. OLCheats->bSpectate = true;
  1723. }
  1724.  
  1725. void cmd_ol_specoff(char *params)
  1726. {
  1727. g_Players->pLocalPlayer->iIsSpectating = 0;
  1728. OLCheats->bSpectate = false;
  1729. }
  1730.  
  1731. void cmd_ol_bot_say(char *params)
  1732. {
  1733. char Say[50];
  1734.  
  1735. int botID;
  1736.  
  1737. if (!strlen(params) || sscanf(params, "%d %[^\n]", &botID, &Say) < 2)
  1738. return addMessageToChatWindow("USAGE: /.bot_say <BOT ID> <Text bla bla>");
  1739.  
  1740. if (botID >= g_BotFuncs->BotSettings.ClientCount)
  1741. return addMessageToChatWindow("This bot id isn't connected");
  1742. BitStream bsChat;
  1743. if (Say[0] == '/')
  1744. {
  1745. int Len;
  1746. Len = strlen(Say);
  1747.  
  1748.  
  1749. bsChat.Write(Len);
  1750. bsChat.Write(Say, Len);
  1751. g_BotFuncs->OL_Bot_SendRPC(botID, RPC_ServerCommand, bsChat, HIGH_PRIORITY, RELIABLE_SEQUENCED, NULL, false);
  1752. }
  1753. else
  1754. {
  1755. BYTE Len;
  1756. Len = (BYTE)strlen(Say);
  1757.  
  1758.  
  1759. bsChat.Write(Len);
  1760. bsChat.Write(Say, Len);
  1761. g_BotFuncs->OL_Bot_SendRPC(botID, RPC_Chat, bsChat, HIGH_PRIORITY, RELIABLE_SEQUENCED, NULL, false);
  1762. }
  1763. }
  1764.  
  1765. void initChatCmds(void)
  1766. {
  1767. if (g_m0dCommands == true)
  1768. return;
  1769.  
  1770. cheat_state_text("initiated modcommands");
  1771. g_m0dCommands = true;
  1772.  
  1773. addClientCommand("mod_show_cmds", cmd_showCMDS);
  1774. addClientCommand("mod_change_server", cmd_change_server);
  1775. addClientCommand("mod_fav_server", cmd_change_server_fav);
  1776. addClientCommand("mod_current_server", cmd_current_server);
  1777. addClientCommand("mod_tele_loc", cmd_tele_loc);
  1778. addClientCommand("mod_teleport_location", cmd_tele_loc);
  1779. addClientCommand("mod_tele_locations", cmd_tele_locations);
  1780. addClientCommand("mod_teleport_locations", cmd_tele_locations);
  1781. addClientCommand("mod_pickup", cmd_pickup);
  1782. addClientCommand("mod_setclass", cmd_setclass);
  1783. addClientCommand("mod_fakekill", cmd_fakekill);
  1784. addClientCommand("mod_warp", cmd_warp);
  1785. // troll admins xD
  1786. //addClientCommand("ban", cmd_nothing);
  1787. //addClientCommand("rcon ban", cmd_nothing);
  1788. //addClientCommand("rcon kick", cmd_nothing);
  1789. //addClientCommand("banip", cmd_nothing);
  1790. //addClientCommand("kick", cmd_nothing);
  1791. addClientCommand(".add_friend", cmd_add_friend);
  1792. addClientCommand(".fake_fps", cmd_fake_fps);
  1793. addClientCommand(".bot_nick", cmd_add_bot_nick);
  1794. addClientCommand(".bot_steal_nick", cmd_bot_steal_nick);
  1795. addClientCommand(".bot_ping", cmd_bot_ping_increase);
  1796. addClientCommand(".bot_anim", cmd_bot_animation);
  1797. addClientCommand(".bot_fanim", cmd_bot_follow_anim);
  1798. addClientCommand(".bot_say", cmd_ol_bot_say);
  1799. addClientCommand(".find_chat", cmd_find_chat);
  1800. addClientCommand(".stop_find", cmd_stop_find_chat);
  1801. addClientCommand(".stick", cmd_stick);
  1802. addClientCommand(".ol_cmds", cmd_ol_show_cmds);
  1803. addClientCommand(".spec", cmd_ol_spec);
  1804. addClientCommand(".specoff", cmd_ol_specoff);
  1805.  
  1806. }
  1807.  
  1808. void BIG_NUM_MUL(unsigned long in[5], unsigned long out[6], unsigned long factor)
  1809. {
  1810.  
  1811. //based on TTMath library by Tomasz Sowa.
  1812.  
  1813. unsigned long src[5] = { 0 };
  1814. for (int i = 0; i < 5; i++)
  1815. src[i] = ((in[4 - i] >> 24) | ((in[4 - i] << 8) & 0x00FF0000) | ((in[4 - i] >> 8) & 0x0000FF00) | (in[4 - i] << 24));
  1816.  
  1817. unsigned long long tmp = 0;
  1818.  
  1819. tmp = unsigned long long(src[0])*unsigned long long(factor);
  1820. out[0] = tmp & 0xFFFFFFFF;
  1821. out[1] = tmp >> 32;
  1822. tmp = unsigned long long(src[1])*unsigned long long(factor) + unsigned long long(out[1]);
  1823. out[1] = tmp & 0xFFFFFFFF;
  1824. out[2] = tmp >> 32;
  1825. tmp = unsigned long long(src[2])*unsigned long long(factor) + unsigned long long(out[2]);
  1826. out[2] = tmp & 0xFFFFFFFF;
  1827. out[3] = tmp >> 32;
  1828. tmp = unsigned long long(src[3])*unsigned long long(factor) + unsigned long long(out[3]);
  1829. out[3] = tmp & 0xFFFFFFFF;
  1830. out[4] = tmp >> 32;
  1831. tmp = unsigned long long(src[4])*unsigned long long(factor) + unsigned long long(out[4]);
  1832. out[4] = tmp & 0xFFFFFFFF;
  1833. out[5] = tmp >> 32;
  1834.  
  1835. for (int i = 0; i < 12; i++)
  1836. {
  1837. unsigned char temp = ((unsigned char*)out)[i];
  1838. ((unsigned char*)out)[i] = ((unsigned char*)out)[23 - i];
  1839. ((unsigned char*)out)[23 - i] = temp;
  1840. }
  1841. }
  1842.  
  1843.  
  1844. // thanks to raksamp devs!
  1845. int gen_rand_gpci(char buf[64], unsigned long factor)
  1846. {
  1847. unsigned char out[6 * 4] = { 0 };
  1848.  
  1849. static const char alphanum[] =
  1850. "0123456789"
  1851. "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  1852.  
  1853. for (int i = 0; i < 6 * 4; ++i)
  1854. out[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
  1855.  
  1856.  
  1857. out[6 * 4] = 0;
  1858.  
  1859. BIG_NUM_MUL((unsigned long*)out, (unsigned long*)out, factor);
  1860.  
  1861. unsigned int notzero = 0;
  1862. buf[0] = '0'; buf[1] = '\0';
  1863.  
  1864. if (factor == 0) return 1;
  1865.  
  1866. int pos = 0;
  1867. for (int i = 0; i < 24; i++)
  1868. {
  1869. unsigned char tmp = out[i] >> 4;
  1870. unsigned char tmp2 = out[i] & 0x0F;
  1871.  
  1872. if (notzero || tmp)
  1873. {
  1874. buf[pos++] = (char)((tmp > 9) ? (tmp + 55) : (tmp + 48));
  1875. if (!notzero) notzero = 1;
  1876. }
  1877.  
  1878. if (notzero || tmp2)
  1879. {
  1880. buf[pos++] = (char)((tmp2 > 9) ? (tmp2 + 55) : (tmp2 + 48));
  1881. if (!notzero) notzero = 1;
  1882. }
  1883. }
  1884. buf[pos] = 0;
  1885.  
  1886. return pos;
  1887. }
  1888.  
  1889. void gen_random(char *s, const int len)
  1890. {
  1891. static const char alphanum[] =
  1892. "0123456789"
  1893. "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  1894. "abcdefghijklmnopqrstuvwxyz";
  1895.  
  1896. for (int i = 0; i < len; ++i)
  1897. s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
  1898.  
  1899. s[len] = 0;
  1900. }
  1901.  
  1902. void gen_randomletter(char *s, const int len)
  1903. {
  1904. static const char alphanum[] =
  1905. "abcdefghijklmnopqrstuvwxyz";
  1906.  
  1907. for (int i = 0; i < len; ++i)
  1908. s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
  1909.  
  1910. s[len] = 0;
  1911. }
  1912.  
  1913. void gen_randomnumber(char *s, const int len)
  1914. {
  1915. static const char alphanum[] =
  1916. "0123456789";
  1917.  
  1918. for (int i = 0; i < len; ++i)
  1919. s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
  1920.  
  1921. s[len] = 0;
  1922. }
  1923.  
  1924. void gen_randombinary(char *s, const int len)
  1925. {
  1926. static const char alphanum[] =
  1927. "01";
  1928.  
  1929. for (int i = 0; i < len; ++i)
  1930. s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
  1931.  
  1932. s[len] = 0;
  1933. }
  1934.  
  1935. void gen_randomuppercase(char *s, const int len)
  1936. {
  1937. static const char alphanum[] =
  1938. "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  1939.  
  1940. for (int i = 0; i < len; ++i)
  1941. s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
  1942.  
  1943. s[len] = 0;
  1944. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement