Advertisement
Lorenc

LorencDebug

May 13th, 2011
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 25.32 KB | None | 0 0
  1. /*
  2.  *  Debug Filterscript by Lorenc
  3.  *
  4.  *  Contact me at zeelorenc@hotmail.com to suggest/create
  5.  *  something with me xD
  6.  *
  7.  *
  8. */
  9.  
  10. #include                    <a_samp>
  11. //#include                  <foreach>
  12. #include                    <zcmd>
  13. #include                    <sscanf2>
  14.  
  15. /* ** Filterscript Settings ** */
  16. #define USE_RCON            false // Change to true if you want RCON to use cmds only.
  17.  
  18. /* ** Colours ** */
  19. #define COLOR_GREEN         0x00CC00FF
  20. #define COLOR_RED           0xFF0000FF
  21. #define COLOR_YELLOW        0xFFFF00FF
  22. #define COLOR_ORANGE        0xEE9911FF
  23.  
  24. /* ** Server/Player Data ** */
  25. enum TEXTDRAW
  26. {
  27.     Text: E_TEXTDRAW_DEBUG_BOX      [MAX_PLAYERS],
  28.     Text: E_TEXTDRAW_DEBUG_POSITION [MAX_PLAYERS],
  29.     Text: E_TEXTDRAW_DEBUG_PLAYER   [MAX_PLAYERS],
  30.     Text: E_TEXTDRAW_DEBUG_HIDE     [MAX_PLAYERS],
  31. }
  32.  
  33. enum PLAYER
  34. {
  35.     Float: E_SYNC_POS               [3], // xyz
  36.     Float: E_SYNC_PLA               [3], // health/armour
  37.     E_SYNC_WORLD,
  38.     E_SYNC_INTERIOR,
  39.     E_SYNC_SKIN,
  40.     E_SYNC_CASH,
  41.     E_SYNC_GUN[12],
  42.     E_SYNC_AMMO[12],
  43.     bool: E_SYNC_NEED,
  44. }
  45.  
  46. enum OBJECTS
  47. {
  48.     Text3D: E_OBJECT_INFO,
  49.     bool:   E_OBJECT_LABELLED,
  50. }
  51.  
  52. enum VEHICLE
  53. {
  54.     Text3D: E_VEHICLE_INFO,
  55.     bool:   E_VEHICLE_LABELLED,
  56. }
  57.  
  58. new
  59.     gVehicleData                    [MAX_VEHICLES][VEHICLE],
  60.     gObjectData                     [MAX_OBJECTS][OBJECTS],
  61.     gTextDrawData                   [TEXTDRAW],
  62.     gPlayerData                     [MAX_PLAYERS][PLAYER],
  63.     bool: gDebugHudShowing          [MAX_PLAYERS char],
  64.     Text3D: PlayerLabel             [MAX_PLAYERS char]
  65. ;
  66.  
  67. /* ** Forwards ** */
  68. forward RestoreBackFromSync(playerid);
  69. forward VehicleObjectUpdate();
  70.  
  71. public OnFilterScriptInit()
  72. {
  73.     new string[128];
  74.     print( "\n * nLorDebug loaded\n" );
  75.    
  76.     CreateObject(3267,1894.813,1628.544,74.204,0.0,0.0,-90.000);
  77.     CreateObject(3267,1961.728,1663.508,74.279,0.0,0.0,135.000);
  78.     CreateObject(3267,1961.765,1593.764,74.154,0.0,0.0,33.750);
  79.     CreateObject(1454,1935.195,1635.968,72.006,0.0,0.0,33.750);
  80.     CreateObject(1457,1936.958,1637.483,72.867,0.0,0.0,47.578);
  81.     CreateObject(1458,1937.400,1637.118,71.461,0.0,0.0,43.358);
  82.     CreateObject(14875,1940.153,1641.579,71.951,0.0,0.0,45.000);
  83.     AddStaticVehicle(560, 2043.628, 1342.956, 15, 0, -1, -1);
  84.     AddStaticVehicle(560, 2043.628+random(10), 1342.956+random(10), 15+random(10), 0, -1, -1);
  85.     AddStaticVehicle(560, 2043.628+random(10), 1342.956+random(10), 15+random(10), 0, -1, -1);
  86.  
  87.     for(new v = 0; v < MAX_VEHICLES; v++)
  88.     {
  89.         if(IsVehicleSpawned(v))
  90.         {
  91.             new Float: vStatus, Float: vPos[3];
  92.             GetVehiclePos(v, vPos[0], vPos[1], vPos[2]);
  93.             GetVehicleHealth(v, vStatus);
  94.             format(string, sizeof(string),  "ID: %d, Model ID: %d\n \
  95.                                              X: %0.3f, Y: %0.3f, Z: %0.3f,\n \
  96.                                              Health: %0.1f",
  97.                                             v, GetVehicleModel(v),
  98.                                             vPos[0], vPos[1], vPos[2],
  99.                                             vStatus);
  100.             gVehicleData[v][E_VEHICLE_LABELLED] = true;
  101.             gVehicleData[v][E_VEHICLE_INFO] = Create3DTextLabel(string, 0xFFFFFFFF, 0,0,0, 30.0, 0);
  102.             Attach3DTextLabelToVehicle(gVehicleData[v][E_VEHICLE_INFO], v, 0.0, 0.0, 0.0);
  103.         }
  104.     }
  105.    
  106.     for(new i = 0; i < MAX_OBJECTS; i++)
  107.     {
  108.         if(IsValidObject(i))
  109.         {
  110.             new Float: oPos[3], Float: rPos[3];
  111.             GetObjectPos(i, oPos[0], oPos[1], oPos[2]);
  112.             GetObjectRot(i, rPos[0], rPos[1], rPos[2]);
  113.             format(string, sizeof(string), "ID: %d\n \
  114.                                             X: %0.3f, Y: %0.3f, Z: %0.3f\n \
  115.                                             \nrX: %0.3f, rY: %0.3f, rZ: %0.3f",
  116.                                             i,
  117.                                             oPos[0], oPos[1], oPos[2],
  118.                                             rPos[0], rPos[1], rPos[2]);
  119.             gObjectData[i][E_OBJECT_LABELLED] = true;
  120.             gObjectData[i][E_OBJECT_INFO] = Create3DTextLabel(string, 0xFFFFFFFF, oPos[0], oPos[1], oPos[2], 30.0, 0);
  121.         }
  122.     }
  123.  
  124.     SetTimer("VehicleObjectUpdate", 750, true);
  125.     return 1;
  126. }
  127.  
  128. public VehicleObjectUpdate()
  129. {
  130.     new string[128], Float: oPos[3], Float: rPos[3],
  131.         Float: vStatus, Float: vPos[3];
  132.     for(new v = 0; v < MAX_VEHICLES; v++)
  133.     {
  134.         if(IsVehicleSpawned(v))
  135.         {
  136.             if(gVehicleData[v][E_VEHICLE_LABELLED] == true)
  137.             {
  138.                 GetVehiclePos(v, vPos[0], vPos[1], vPos[2]);
  139.                 GetVehicleHealth(v, vStatus);
  140.                 format(string, sizeof(string),  "ID: %d, Model ID: %d\n \
  141.                                                  X: %0.3f, Y: %0.3f, Z: %0.3f,\n \
  142.                                                  Health: %0.1f",
  143.                                                 v, GetVehicleModel(v),
  144.                                                 vPos[0], vPos[1], vPos[2],
  145.                                                 vStatus);
  146.                 Update3DTextLabelText(gVehicleData[v][E_VEHICLE_INFO], 0xFFFFFFFF, string);
  147.             }
  148.         }
  149.     }
  150.     for(new i = 0; i < MAX_OBJECTS; i++)
  151.     {
  152.         if(IsValidObject(i))
  153.         {
  154.             if(gObjectData[i][E_OBJECT_LABELLED] == true)
  155.             {
  156.                 GetObjectPos(i, oPos[0], oPos[1], oPos[2]);
  157.                 GetObjectRot(i, rPos[0], rPos[1], rPos[2]);
  158.                 format(string, sizeof(string), "ID: %d\n \
  159.                                                 X: %0.3f, Y: %0.3f, Z: %0.3f\n \
  160.                                                 \nrX: %0.3f, rY: %0.3f, rZ: %0.3f",
  161.                                                 i,
  162.                                                 oPos[0], oPos[1], oPos[2],
  163.                                                 rPos[0], rPos[1], rPos[2]);
  164.                 Update3DTextLabelText(gObjectData[i][E_OBJECT_INFO], 0xFFFFFFFF, string);
  165.             }
  166.         }
  167.     }
  168. }
  169.  
  170. public OnFilterScriptExit()
  171. {
  172.     print( "\n * nLorDebug unloaded\n" );
  173.     for(new i = 0; i < MAX_OBJECTS; i++)
  174.     {
  175.         Delete3DTextLabel(gObjectData[i][E_OBJECT_INFO]);
  176.         gObjectData[i][E_OBJECT_LABELLED] = false;
  177.     }
  178.     for(new v = 0; v < MAX_VEHICLES; v++)
  179.     {
  180.         Delete3DTextLabel(gVehicleData[v][E_VEHICLE_INFO]);
  181.         gVehicleData[v][E_VEHICLE_LABELLED] = false;
  182.     }
  183.     return 1;
  184. }
  185.  
  186. public OnPlayerConnect(playerid)
  187. {
  188.     new string[MAX_PLAYER_NAME + 50];
  189.     loadTextDraws(playerid);
  190.     gDebugHudShowing{playerid} = true;
  191.  
  192.     format(string, sizeof(string), "%s(%d)\nPING:%d", ReturnPlayerName(playerid), playerid, GetPlayerPing(playerid));
  193.     PlayerLabel{playerid} = Create3DTextLabel(string, 0xFFFFFFFF, 0.0, 0.0, 0.0, 30.0, 0);
  194.     Attach3DTextLabelToPlayer(PlayerLabel{playerid}, playerid, 0.0, 0.0, 0.0);
  195.     return 1;
  196. }
  197.  
  198. public OnPlayerDisconnect(playerid, reason)
  199. {
  200.     Delete3DTextLabel(PlayerLabel{playerid});
  201.     return 1;
  202. }
  203.  
  204. public OnPlayerSpawn(playerid)
  205. {
  206.     if(gPlayerData[playerid][E_SYNC_NEED] == true) SetTimerEx("RestoreBackFromSync", 1000, false, "d", playerid);
  207.     return 1;
  208. }
  209.  
  210. public RestoreBackFromSync(playerid)
  211. {
  212.     SetPlayerPos(playerid,  gPlayerData[playerid][E_SYNC_POS][0],
  213.                             gPlayerData[playerid][E_SYNC_POS][1],
  214.                             gPlayerData[playerid][E_SYNC_POS][2]);
  215.  
  216.     ResetPlayerWeapons(playerid);
  217.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][0], gPlayerData[playerid][E_SYNC_AMMO][0]);
  218.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][1], gPlayerData[playerid][E_SYNC_AMMO][1]);
  219.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][2], gPlayerData[playerid][E_SYNC_AMMO][2]);
  220.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][3], gPlayerData[playerid][E_SYNC_AMMO][3]);
  221.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][4], gPlayerData[playerid][E_SYNC_AMMO][4]);
  222.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][5], gPlayerData[playerid][E_SYNC_AMMO][5]);
  223.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][6], gPlayerData[playerid][E_SYNC_AMMO][6]);
  224.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][7], gPlayerData[playerid][E_SYNC_AMMO][7]);
  225.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][8], gPlayerData[playerid][E_SYNC_AMMO][8]);
  226.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][9], gPlayerData[playerid][E_SYNC_AMMO][9]);
  227.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][10], gPlayerData[playerid][E_SYNC_AMMO][10]);
  228.     GivePlayerWeapon(playerid, gPlayerData[playerid][E_SYNC_GUN][11], gPlayerData[playerid][E_SYNC_AMMO][11]);
  229.    
  230.     SetPlayerHealth(playerid, gPlayerData[playerid][E_SYNC_PLA][0]);
  231.     SetPlayerArmour(playerid, gPlayerData[playerid][E_SYNC_PLA][1]);
  232.     SetPlayerSkin(playerid, gPlayerData[playerid][E_SYNC_SKIN]);
  233.     SetPlayerVirtualWorld(playerid, gPlayerData[playerid][E_SYNC_WORLD]);
  234.     SetPlayerInterior(playerid, gPlayerData[playerid][E_SYNC_INTERIOR]);
  235.     ResetPlayerMoney(playerid);
  236.     GivePlayerMoney(playerid, gPlayerData[playerid][E_SYNC_CASH]);
  237.     gPlayerData[playerid][E_SYNC_NEED] = false;
  238.     SendClientMessage(playerid, COLOR_YELLOW, "Successfully Syncohized.");
  239. }
  240.  
  241. public OnVehicleDeath(vehicleid, killerid)
  242. {
  243.     gVehicleData[vehicleid][E_VEHICLE_LABELLED] = false;
  244.     Delete3DTextLabel(gVehicleData[vehicleid][E_VEHICLE_INFO]);
  245.     return 1;
  246. }
  247.  
  248. /* ** Commands ** */
  249.  
  250. CMD:dhud(playerid, params[])
  251. {
  252.     if(gDebugHudShowing{playerid} == true)
  253.     {
  254.         hideDebugBox(playerid);
  255.         gDebugHudShowing{playerid} = false;
  256.         SendClientMessage(playerid, COLOR_YELLOW, "Type /dhud to show this hud.");
  257.     }
  258.     else if(gDebugHudShowing{playerid} == false)
  259.     {
  260.         showDebugBox(playerid);
  261.         SendClientMessage(playerid, COLOR_YELLOW, "Type /dhud to hide this hud.");
  262.         gDebugHudShowing{playerid} = true;
  263.     }
  264.     return 1;
  265. }
  266.  
  267. CMD:info(playerid, params[])
  268. {
  269.     ClearChat(playerid, 50);
  270.     if(isnull(params)) SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /info [help/cmds/credits]");
  271.     else if(strcmp(params, "help", true, 4) == 0)
  272.     {
  273.         SendClientMessage(playerid, COLOR_GREEN, "**** LorDebug - Help ****");
  274.         SendClientMessage(playerid, COLOR_YELLOW, "LorDebug (Lorenc Debug) is a Debugging filterscript");
  275.         SendClientMessage(playerid, COLOR_YELLOW, "devoloped by Lorenc and is more advanced then fsdebug");
  276.         SendClientMessage(playerid, COLOR_YELLOW, "which was contained on the sa-mp package. LorDebug");
  277.         SendClientMessage(playerid, COLOR_YELLOW, "Contains many features inside.");
  278.         SendClientMessage(playerid, COLOR_GREEN, "** Commands only for RCON: "#USE_RCON" **");
  279.     }
  280.     else if(strcmp(params, "cmds", true, 4) == 0)
  281.     {
  282.         SendClientMessage(playerid, COLOR_GREEN, "**** LorDebug - Commands ****");
  283.         SendClientMessage(playerid, COLOR_YELLOW, "/dhud, /v, /deletev, /sync, /gravity, /weather, /time");
  284.         SendClientMessage(playerid, COLOR_YELLOW, "/skin, /goto, /bring");
  285.     }
  286.     else if(strcmp(params, "credits", true, 4) == 0)
  287.     {
  288.         SendClientMessage(playerid, COLOR_GREEN, "**** LorDebug - Credits ****");
  289.         SendClientMessage(playerid, COLOR_YELLOW, "Lorenc - Creating whole script from scratch.");
  290.         SendClientMessage(playerid, COLOR_YELLOW, "Simon - Borrowed few codes off him.");
  291.     }
  292.     return 1;
  293. }
  294.  
  295. CMD:goto(playerid, params[])
  296. {
  297.     new
  298.         pID,
  299.         Float: pos[3],
  300.         string[128];
  301.  
  302.     #if USE_RCON == true
  303.     if(!IsPlayerAdmin(playerid)) return 0;
  304.     #endif
  305.     if(sscanf(params, "u", pID)) SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /goto [playerid]");
  306.     else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Player ID!");
  307.     else
  308.     {
  309.         GetPlayerPos(pID, pos[0], pos[1], pos[2]);
  310.         SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  311.         format(string, sizeof(string), "You have teleported to %s.", ReturnPlayerName(pID));
  312.         SendClientMessage(playerid, COLOR_YELLOW, string);
  313.         format(string, sizeof(string), "%s has teleported to you.", ReturnPlayerName(playerid));
  314.         SendClientMessage(pID, COLOR_YELLOW, string);
  315.     }
  316.     return 1;
  317. }
  318.  
  319. CMD:bring(playerid, params[])
  320. {
  321.     new
  322.         pID,
  323.         Float: pos[3],
  324.         string[128];
  325.  
  326.     #if USE_RCON == true
  327.     if(!IsPlayerAdmin(playerid)) return 0;
  328.     #endif
  329.     if(sscanf(params, "u", pID)) SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /bring [playerid]");
  330.     else if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Player ID!");
  331.     else
  332.     {
  333.         GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  334.         SetPlayerPos(pID, pos[0], pos[1], pos[2]);
  335.         format(string, sizeof(string), "You brought %s to you.", ReturnPlayerName(pID));
  336.         SendClientMessage(playerid, COLOR_YELLOW, string);
  337.         format(string, sizeof(string), "%s has brought you here.", ReturnPlayerName(playerid));
  338.         SendClientMessage(pID, COLOR_YELLOW, string);
  339.     }
  340.     return 1;
  341. }
  342.  
  343. CMD:skin(playerid, params[])
  344. {
  345.     new
  346.         sID;
  347.     #if USE_RCON == true
  348.     if(!IsPlayerAdmin(playerid)) return 0;
  349.     #endif
  350.     if(sscanf(params, "d", sID)) SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /skin [skinid]");
  351.     else if(sID < 0 && sID > 299) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Skin!");
  352.     else
  353.     {
  354.         SetPlayerSkin(playerid, sID);
  355.         SendClientMessage(playerid, COLOR_YELLOW, "You're Skin ID has been changed.");
  356.     }
  357.     return 1;
  358. }
  359.  
  360. CMD:gravity(playerid, params[])
  361. {
  362.     new
  363.         Float: sGravity,
  364.         string[128];
  365.     #if USE_RCON == true
  366.     if(!IsPlayerAdmin(playerid)) return 0;
  367.     #endif
  368.     if(strcmp(params, "default", true, 4) == 0) SetGravity(0.008);
  369.     else if(sscanf(params, "f", sGravity)) SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /gravity [gravity level/default]");
  370.     else if(sGravity > 0 && sGravity < 0.001) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Gravity Level.");
  371.     else
  372.     {
  373.         SetGravity(sGravity);
  374.         format(string, sizeof(string), "Gravity has been set to: %0.3f", sGravity);
  375.         SendClientMessageToAll(COLOR_YELLOW, string);
  376.     }
  377.     return 1;
  378. }
  379.  
  380. CMD:weather(playerid, params[])
  381. {
  382.     new
  383.         sWeather,
  384.         string[128];
  385.     #if USE_RCON == true
  386.     if(!IsPlayerAdmin(playerid)) return 0;
  387.     #endif
  388.     if(sscanf(params, "d", sWeather)) SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /weather [ID]");
  389.     else if(sWeather < 0 && sWeather > 45) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Weather ID.");
  390.     else
  391.     {
  392.         SetWeather(sWeather);
  393.         format(string, sizeof(string), "Weather has been set to: %d", sWeather);
  394.         SendClientMessageToAll(COLOR_YELLOW, string);
  395.     }
  396.     return 1;
  397. }
  398.  
  399. CMD:time(playerid, params[])
  400. {
  401.     new
  402.         sTime,
  403.         string[128];
  404.     #if USE_RCON == true
  405.     if(!IsPlayerAdmin(playerid)) return 0;
  406.     #endif
  407.     if(sscanf(params, "d", sTime)) SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /Time [time]");
  408.     else if(sTime < 0 && sTime > 23) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Time.");
  409.     else
  410.     {
  411.         SetWorldTime(sTime);
  412.         format(string, sizeof(string), "World Time has been set to: %d", sTime);
  413.         SendClientMessageToAll(COLOR_YELLOW, string);
  414.     }
  415.     return 1;
  416. }
  417.  
  418. CMD:v(playerid, params[])
  419. {
  420.     new
  421.         vID,
  422.         cCar;
  423.     #if USE_RCON == true
  424.     if(!IsPlayerAdmin(playerid)) return 0;
  425.     #endif
  426.     if(sscanf(params, "d", vID)) SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /v [vehicleid]");
  427.     else if(vID < 400 || vID > 611) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid Vehicle ID.");
  428.     else
  429.     {
  430.         new
  431.             Float: pos[3],
  432.             Float: Angle,
  433.             pWorld;
  434.         GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  435.         GetPlayerFacingAngle(playerid, Angle);
  436.         pWorld = GetPlayerVirtualWorld(playerid);
  437.         cCar = CreateVehicle(vID, pos[0], pos[1], pos[2], Angle, 0, 0, pWorld);
  438.         PutPlayerInVehicle(playerid, cCar, 0);
  439.         SendClientMessage(playerid, COLOR_YELLOW, "You have created a vehicle.");
  440.        
  441.         new string[128], Float: vStatus, Float: vPos[3];
  442.         GetVehiclePos(cCar, vPos[0], vPos[1], vPos[2]);
  443.         GetVehicleHealth(cCar, vStatus);
  444.         format(string, sizeof(string),  "ID: %d, Model ID: %d\n \
  445.                                          X: %0.3f, Y: %0.3f, Z: %0.3f,\n \
  446.                                          Health: %0.1f",
  447.                                         cCar, GetVehicleModel(cCar),
  448.                                         vPos[0], vPos[1], vPos[2],
  449.                                         vStatus);
  450.         gVehicleData[cCar][E_VEHICLE_LABELLED] = true;
  451.         gVehicleData[cCar][E_VEHICLE_INFO] = Create3DTextLabel(string, 0xFFFFFFFF, 0,0,0, 30.0, 0);
  452.         Attach3DTextLabelToVehicle(gVehicleData[cCar][E_VEHICLE_INFO], cCar, 0.0, 0.0, 0.0);
  453.     }
  454.     return 1;
  455. }
  456.  
  457. CMD:deletev(playerid, params[])
  458. {
  459.     new cv = GetPlayerVehicleID(playerid);
  460.     #if USE_RCON == true
  461.     if(!IsPlayerAdmin(playerid)) return 0;
  462.     #endif
  463.     if(!IsPlayerInVehicle(playerid, cv)) return SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be in a vehicle to use this command.");
  464.     else
  465.     {
  466.         DestroyVehicle(cv);
  467.         SendClientMessage(playerid, COLOR_YELLOW, "Vehicle destroyed!");
  468.     }
  469.     return 1;
  470. }
  471.  
  472. CMD:sync(playerid, params[])
  473. {
  474.     if(gPlayerData[playerid][E_SYNC_NEED] == true) return SendClientMessage(playerid, COLOR_RED, "ERROR: Syncing in progress!");
  475.     else
  476.     {
  477.         SYNC(playerid);
  478.     }
  479.     return 1;
  480. }
  481.  
  482. /* ** End of Commands ** */
  483. public OnPlayerUpdate(playerid)
  484. {
  485.     new
  486.         string[128],
  487.         Float:pos[3],
  488.         Float:Player[2],
  489.         ping,
  490.         world, interior,
  491.         wep[24], ammo
  492.     ;
  493.    
  494.     GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  495.     GetPlayerHealth(playerid, Player[0]);
  496.     GetPlayerArmour(playerid, Player[1]);
  497.    
  498.     ping = GetPlayerPing(playerid);
  499.     interior = GetPlayerInterior(playerid);
  500.     world = GetPlayerVirtualWorld(playerid);
  501.     wep = ReturnWeaponName(GetPlayerWeapon(playerid));
  502.     ammo = GetPlayerAmmo(playerid);
  503.  
  504.     if(gDebugHudShowing{playerid} == true)
  505.     {
  506.         format(string, sizeof(string), "~r~Position:~w~ ~n~ X: %0.3f, Y: %0.3f, Z: %0.3f ~n~ Interior: %d, World: %d",  pos[0], pos[1], pos[2],
  507.                                                                                                                     interior, world);
  508.         TextDrawSetString(gTextDrawData[E_TEXTDRAW_DEBUG_POSITION][playerid], string);
  509.         format(string, sizeof(string), "~n~~r~Player~w~ ~n~ Health: %0.1f, Armour: %0.1f, ~n~ Player ID: %d, Ping: %d, ~n~ Weapon: %s, Ammo: %d", Player[0],Player[1],
  510.                                                                                                                                     playerid,ping,wep,ammo);
  511.         TextDrawSetString(gTextDrawData[E_TEXTDRAW_DEBUG_PLAYER][playerid], string);
  512.         showDebugBox(playerid);
  513.     }
  514.    
  515.     format(string, sizeof(string), "%s(%d)\nPING:%d", ReturnPlayerName(playerid), playerid, GetPlayerPing(playerid));
  516.     Update3DTextLabelText(PlayerLabel{playerid}, 0xFFFFFFFF, string);
  517.     return 1;
  518. }
  519.  
  520. /////////////////////////////////////////////////////////////
  521. /////////               FUNCTIONS                   /////////
  522. /////////////////////////////////////////////////////////////
  523.  
  524. stock ReturnPlayerName(playerid) // By Lorenc
  525. {
  526.     new pname[MAX_PLAYER_NAME];
  527.     GetPlayerName(playerid, pname, sizeof(pname));
  528.     return pname;
  529. }
  530.  
  531. stock bool:IsSpawned(playerid) // By Lorenc
  532. {
  533.     new pstate = GetPlayerState(playerid);
  534.     if((pstate >= PLAYER_STATE_ONFOOT && pstate <= PLAYER_STATE_ENTER_VEHICLE_PASSENGER) || pstate == PLAYER_STATE_SPAWNED) return true;
  535.     return false;
  536. }
  537.  
  538. SYNC(playerid) // By Lorenc
  539. {
  540.     new Float:pos[3], Float:pla[3];
  541.     GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  542.     GetPlayerHealth(playerid, pla[0]);
  543.     GetPlayerArmour(playerid, pla[1]);
  544.    
  545.     GetPlayerWeaponData(playerid, 1, gPlayerData[playerid][E_SYNC_GUN][0], gPlayerData[playerid][E_SYNC_AMMO][0]);
  546.     GetPlayerWeaponData(playerid, 2, gPlayerData[playerid][E_SYNC_GUN][1], gPlayerData[playerid][E_SYNC_AMMO][1]);
  547.     GetPlayerWeaponData(playerid, 3, gPlayerData[playerid][E_SYNC_GUN][2], gPlayerData[playerid][E_SYNC_AMMO][2]);
  548.     GetPlayerWeaponData(playerid, 4, gPlayerData[playerid][E_SYNC_GUN][3], gPlayerData[playerid][E_SYNC_AMMO][3]);
  549.     GetPlayerWeaponData(playerid, 5, gPlayerData[playerid][E_SYNC_GUN][4], gPlayerData[playerid][E_SYNC_AMMO][4]);
  550.     GetPlayerWeaponData(playerid, 6, gPlayerData[playerid][E_SYNC_GUN][5], gPlayerData[playerid][E_SYNC_AMMO][5]);
  551.     GetPlayerWeaponData(playerid, 7, gPlayerData[playerid][E_SYNC_GUN][6], gPlayerData[playerid][E_SYNC_AMMO][6]);
  552.     GetPlayerWeaponData(playerid, 8, gPlayerData[playerid][E_SYNC_GUN][7], gPlayerData[playerid][E_SYNC_AMMO][7]);
  553.     GetPlayerWeaponData(playerid, 9, gPlayerData[playerid][E_SYNC_GUN][8], gPlayerData[playerid][E_SYNC_AMMO][8]);
  554.     GetPlayerWeaponData(playerid, 10, gPlayerData[playerid][E_SYNC_GUN][9], gPlayerData[playerid][E_SYNC_AMMO][9]);
  555.     GetPlayerWeaponData(playerid, 11, gPlayerData[playerid][E_SYNC_GUN][10], gPlayerData[playerid][E_SYNC_AMMO][10]);
  556.     GetPlayerWeaponData(playerid, 12, gPlayerData[playerid][E_SYNC_GUN][11], gPlayerData[playerid][E_SYNC_AMMO][11]);
  557.    
  558.     gPlayerData[playerid][E_SYNC_POS][0] =      pos[0];
  559.     gPlayerData[playerid][E_SYNC_POS][1] =      pos[1];
  560.     gPlayerData[playerid][E_SYNC_POS][2] =      pos[2];
  561.     gPlayerData[playerid][E_SYNC_PLA][0] =      pla[0];
  562.     gPlayerData[playerid][E_SYNC_PLA][1] =      pla[1];
  563.     gPlayerData[playerid][E_SYNC_WORLD] =       GetPlayerVirtualWorld(playerid);
  564.     gPlayerData[playerid][E_SYNC_INTERIOR] =    GetPlayerInterior(playerid);
  565.     gPlayerData[playerid][E_SYNC_SKIN] =        GetPlayerSkin(playerid);
  566.     gPlayerData[playerid][E_SYNC_CASH] =        GetPlayerMoney(playerid);
  567.     gPlayerData[playerid][E_SYNC_NEED] =        true;
  568.  
  569.     SpawnPlayer(playerid);
  570.     ClearChat(playerid, 50);
  571. }
  572.  
  573. hideDebugBox(playerid) // By Lorenc
  574. {
  575.     TextDrawHideForPlayer(playerid, gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid]);
  576.     TextDrawHideForPlayer(playerid, gTextDrawData[E_TEXTDRAW_DEBUG_POSITION][playerid]);
  577.     TextDrawHideForPlayer(playerid, gTextDrawData[E_TEXTDRAW_DEBUG_PLAYER][playerid]);
  578.     TextDrawHideForPlayer(playerid, gTextDrawData[E_TEXTDRAW_DEBUG_HIDE][playerid]);
  579. }
  580.  
  581. showDebugBox(playerid) // By Lorenc
  582. {
  583.     TextDrawShowForPlayer(playerid, gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid]);
  584.     TextDrawShowForPlayer(playerid, gTextDrawData[E_TEXTDRAW_DEBUG_POSITION][playerid]);
  585.     TextDrawShowForPlayer(playerid, gTextDrawData[E_TEXTDRAW_DEBUG_PLAYER][playerid]);
  586.     TextDrawShowForPlayer(playerid, gTextDrawData[E_TEXTDRAW_DEBUG_HIDE][playerid]);
  587. }
  588.  
  589. loadTextDraws(playerid) // By Lorenc
  590. {
  591.     gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid] = TextDrawCreate(534.000000, 317.000000, "~y~Debug~n~~n~~n~~n~~n~");
  592.     TextDrawAlignment(gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid], 2);
  593.     TextDrawBackgroundColor(gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid], 255);
  594.     TextDrawFont(gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid], 0);
  595.     TextDrawLetterSize(gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid], 0.559998, 1.899999);
  596.     TextDrawColor(gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid], -1);
  597.     TextDrawSetOutline(gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid], 0);
  598.     TextDrawSetProportional(gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid], 1);
  599.     TextDrawSetShadow(gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid], 1);
  600.     TextDrawUseBox(gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid], 1);
  601.     TextDrawBoxColor(gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid], 255);
  602.     TextDrawTextSize(gTextDrawData[E_TEXTDRAW_DEBUG_BOX][playerid], 259.000000, 161.000000);
  603.  
  604.     gTextDrawData[E_TEXTDRAW_DEBUG_POSITION][playerid] = TextDrawCreate(459.000000, 339.000000, "Position: ~n~ X: 00000000, Y: 0000000, Z: 00000000");
  605.     TextDrawBackgroundColor(gTextDrawData[E_TEXTDRAW_DEBUG_POSITION][playerid], 255);
  606.     TextDrawFont(gTextDrawData[E_TEXTDRAW_DEBUG_POSITION][playerid], 2);
  607.     TextDrawLetterSize(gTextDrawData[E_TEXTDRAW_DEBUG_POSITION][playerid], 0.170000, 0.899999);
  608.     TextDrawColor(gTextDrawData[E_TEXTDRAW_DEBUG_POSITION][playerid], -1);
  609.     TextDrawSetOutline(gTextDrawData[E_TEXTDRAW_DEBUG_POSITION][playerid], 0);
  610.     TextDrawSetProportional(gTextDrawData[E_TEXTDRAW_DEBUG_POSITION][playerid], 1);
  611.     TextDrawSetShadow(gTextDrawData[E_TEXTDRAW_DEBUG_POSITION][playerid], 1);
  612.  
  613.     gTextDrawData[E_TEXTDRAW_DEBUG_PLAYER][playerid] = TextDrawCreate(459.000000, 356.000000, "Player ~n~ Health: 100.0 Armour 100.0 ~n~ Player ID: 100 Ping: 1000 FPS: 100");
  614.     TextDrawBackgroundColor(gTextDrawData[E_TEXTDRAW_DEBUG_PLAYER][playerid], 255);
  615.     TextDrawFont(gTextDrawData[E_TEXTDRAW_DEBUG_PLAYER][playerid], 2);
  616.     TextDrawLetterSize(gTextDrawData[E_TEXTDRAW_DEBUG_PLAYER][playerid], 0.170000, 0.899999);
  617.     TextDrawColor(gTextDrawData[E_TEXTDRAW_DEBUG_PLAYER][playerid], -1);
  618.     TextDrawSetOutline(gTextDrawData[E_TEXTDRAW_DEBUG_PLAYER][playerid], 0);
  619.     TextDrawSetProportional(gTextDrawData[E_TEXTDRAW_DEBUG_PLAYER][playerid], 1);
  620.     TextDrawSetShadow(gTextDrawData[E_TEXTDRAW_DEBUG_PLAYER][playerid], 1);
  621.  
  622.     gTextDrawData[E_TEXTDRAW_DEBUG_HIDE][playerid] = TextDrawCreate(490.000000, 410.000000, "~g~/dhud to hide this.");
  623.     TextDrawBackgroundColor(gTextDrawData[E_TEXTDRAW_DEBUG_HIDE][playerid], 255);
  624.     TextDrawFont(gTextDrawData[E_TEXTDRAW_DEBUG_HIDE][playerid], 2);
  625.     TextDrawLetterSize(gTextDrawData[E_TEXTDRAW_DEBUG_HIDE][playerid], 0.230000, 0.899999);
  626.     TextDrawColor(gTextDrawData[E_TEXTDRAW_DEBUG_HIDE][playerid], -1);
  627.     TextDrawSetOutline(gTextDrawData[E_TEXTDRAW_DEBUG_HIDE][playerid], 0);
  628.     TextDrawSetProportional(gTextDrawData[E_TEXTDRAW_DEBUG_HIDE][playerid], 1);
  629.     TextDrawSetShadow(gTextDrawData[E_TEXTDRAW_DEBUG_HIDE][playerid], 1);
  630. }
  631.  
  632. stock ReturnWeaponName(weaponid)
  633. {
  634.     new wname[20];
  635.     switch(weaponid) {
  636.         case 0: wname = "Fist";
  637.         case 18: wname = "Molotovs";
  638.         case 40: wname = "Detonator";
  639.         case 44: wname = "Nightvision Goggles";
  640.         case 45: wname = "Thermal Goggles";
  641.         default: GetWeaponName(weaponid, wname, sizeof(wname));
  642.     }
  643.     return wname;
  644. }
  645.  
  646. stock ReturnMonth(Month)
  647. {
  648.     new MonthStr[15];
  649.     switch(Month) {
  650.         case 1:  MonthStr = "January";
  651.         case 2:  MonthStr = "February";
  652.         case 3:  MonthStr = "March";
  653.         case 4:  MonthStr = "April";
  654.         case 5:  MonthStr = "May";
  655.         case 6:  MonthStr = "June";
  656.         case 7:  MonthStr = "July";
  657.         case 8:  MonthStr = "August";
  658.         case 9:  MonthStr = "September";
  659.         case 10: MonthStr = "October";
  660.         case 11: MonthStr = "November";
  661.         case 12: MonthStr = "December";
  662.     }
  663.     return MonthStr;
  664. }
  665.  
  666. stock AddLogLine( player[], file[], input[] )
  667. {
  668.     new string[128];
  669.     format(string, 128, "%s: %s\r\n", player, input);
  670.  
  671.     new File:fhandle;
  672.  
  673.     if(fexist(file)) {
  674.         printf("Creating file '%s' because theres no file created with that name.", file);
  675.     }
  676.  
  677.     fhandle = fopen(file,io_append);
  678.  
  679.     fwrite(fhandle,string);
  680.     fclose(fhandle);
  681.     return 1;
  682. }
  683.  
  684. stock ClearChat(playerid, lines)
  685. {
  686.     for(new i = 0; i < lines; i++)
  687.     {
  688.         SendClientMessage(playerid, 0x0, "");
  689.     }
  690. }
  691.  
  692. stock IsVehicleSpawned(vehicleid)
  693. {
  694.     new Float:VX, Float:VY, Float:VZ;
  695.     GetVehiclePos(vehicleid, VX, VY, VZ);
  696.     if (VX == 0.0 && VY == 0.0 && VZ == 0.0) return 0;
  697.     return 1;
  698. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement