Advertisement
Guest User

Sandra

a guest
Jun 10th, 2008
1,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.37 KB | None | 0 0
  1. /*===================================================================================================*\
  2. ||===================================================================================================||
  3. || ________ ________ ___ _ ______ ______ ________ ||
  4. || \ | _____| | ____ | | \ | | | _ \ | _ \ | ____ | / ||
  5. || ======== \ | |_____ | |____| | | |\ \ | | | | | | | |_| / | |____| | / ======== ||
  6. || | | _____ | | ____ | | | \ \| | | | | | | _ \ | ____ | | ||
  7. || ======== / ______| | | | | | | | \ \ | | |_| | | | \ \ | | | | \ ======== ||
  8. || / |________| |_| |_| |_| \__| |______/ |_| \_| |_| |_| \ ||
  9. || ||
  10. ||===================================================================================================||
  11. || Created on the 10th of June 2008 by =>Sandra<= ||
  12. || Do NOT remove any credits!! ||
  13. \*===================================================================================================*/
  14.  
  15. #include <a_samp>
  16.  
  17. new PawnFunctions[][] =
  18. {
  19.  
  20. "acos", "AddMenuItem", "AddPlayerClass", "AddPlayerClassEx", "AddStaticPickup", "AddStaticVehicle", "AddStaticVehicleEx",
  21. "AddVehicleComponent", "AllowAdminTeleport", "AllowInteriorWeapons", "AllowPlayerTeleport", "ApplyAnimation", "asin",
  22. "atan", "atan2", "AttachObjectToPlayer", "AttachPlayerObjectToPlayer", "AttachTrailerToVehicle",
  23.  
  24. "Ban", "BanEx",
  25.  
  26. "CallLocalFunction", "CallRemoteFunction", "ChangeVehicleColor", "ChangeVehiclePaintJob", "ClearAnimations", "CreateExplosion",
  27. "CreateMenu", "CreateObject", "CreatePickup", "CreatePlayerObject", "CreateVehicle",
  28.  
  29. "DestroyMenu", "DestroyObject", "DestroyPickup", "DestroyPlayerObject", "DestroyVehicle", "DetachTrailerFromVehicle",
  30. "DisableInteriorEnterExits", "DisableMenu", "DisableMenuRow", "DisablePlayerCheckpoint", "DisablePlayerRaceCheckpoint",
  31.  
  32. "EnableStuntBonusForAll", "EnableStuntBonusForPlayer", "EnableTirePopping", "EnableZoneNames",
  33.  
  34. "fclose", "fexists", "fopen", "fread", "fremove", "fwrite", "ForceClassSelection", "format",
  35.  
  36. "GameModeExit", "GameTextForAll", "GameTextForPlayer", "GangZoneCreate", "GangZoneDestroy", "GangZoneFlashForAll, ", "GangZoneFlashForPlayer",
  37. "GangZoneHideForAll", "GangZoneHideForPlayer", "GangZoneShowForAll", "GangZoneShowForPlayer", "GangZoneStopFlashForAll", "GangZoneStopFlashForPlayer",
  38. "GetMaxPlayers", "GetObjectPos", "GetObjectRot", "GetPlayerAmmo", "GetPlayerArmour", "GetPlayerColor", "GetPlayerFacingAngle", "GetPlayerHealth",
  39. "GetPlayerInterior", "GetPlayerIp", "GetPlayerKeys", "GetPlayerMenu", "GetPlayerMoney", "GetPlayerName", "GetPlayerObjectPos", "GetPlayerObjectRot",
  40. "GetPlayerPing", "GetPlayerPos", "GetPlayerPos", "GetPlayerScore", "GetPlayerSkin", "GetPlayerSpecialAction", "GetPlayerState", "GetPlayerTeam", "GetPlayerTime",
  41. "GetPlayerVehicleID", "GetPlayerVirtualWorld", "GetPlayerWantedLevel", "GetPlayerWeapon", "GetPlayerWeaponData", "GetServerVarAsBool",
  42. "GetServerVarAsInt", "GetServerVasAsString", "GetVehicleHealth", "GetVehicleModel", "GetVehiclePos", "GetVehicleTrailer",
  43. "GetVehicleVirtualWorld", "GetVehicleZAngle", "GetWeaponName", "getdate", "gettime", "GivePlayerMoney", "GivePlayerWeapon",
  44.  
  45. "HideMenuForPlayer",
  46.  
  47. "IsPlayerAdmin", "IsPlayerConnected", "IsPlayerInAnyVehicle", "IsPlayerInCheckpoint", "IsPlayerInRaceCheckpoint",
  48. "IsTrailerAttachedToVehicle", "IsValidMenu", "IsValidObject", "IsValidPlayerObject",
  49.  
  50. "Kick", "KilTimer",
  51.  
  52. "LimitGlobalChatRadius", "LinkVehicleToInterior",
  53.  
  54. "MoveObject", "MovePlayerObject",
  55.  
  56. "PlayerPlaySound", "PlayerSpectatePlayer", "PlayerSpectateVehicle", "print", "printf", "PutPlayerInVehicle",
  57.  
  58. "random", "RemovePlayerFromVehicle", "RemovePlayerMapIcon", "RemoveVehicleComponent", "ResetPlayerMoney", "ResetPlayerWeapons",
  59.  
  60. "SendClientMessage", "SendClientMessageToAll", "SendDeathMessage", "SendPlayerMessageToAll", "SendPlayerMessageToPlayer",
  61. "SendRconCommand", "SetCameraBehindPlayer", "SetDeathDropAmount", "SetDisabledWeapons", "SetGameModeText", "SetGravity",
  62. "SetMenuColumnHeader", "SetNameTagDrawDistance", "SetObjectPos", "SetObjectRot", "SetPlayerAmmo", "SetPlayerArmour",
  63. "SetPlayerCameraLookAt", "SetPlayerCameraPos", "SetPlayerCheckpoint", "SetPlayerColor", "SetPlayerDisabledWeapons",
  64. "SetPlayerFacingAngle", "SetPlayerHealth", "SetPlayerInterior", "SetPlayerMapIcon", "SetPlayerMarkerForPlayer", "SetPlayerName",
  65. "SetPlayerObjectPos", "SetPlayerObjectRot", "SetPlayerPos", "SetPlayerPosFindZ", "SetPlayerRaceCheckpoint", "SetPlayerScore",
  66. "SetPlayerSkin", "SetPlayerSpecialAction", "SetPlayerTeam", "SetPlayerTime", "SetPlayeVirtualWorld", "SetPlayerWantedLevel",
  67. "SetPlayerWeather", "SetPlayerWorldBounds", "SetSpawnInfo", "SetTeamCount", "SetTimer", "SetTimerEx", "SetVehicleHealth",
  68. "SetVehicleNumberPlate", "SetVehicleParamsForPlayer", "SetVehiclePos", "SetVehicleToRespawn", "SetVehicleVirtualWorld",
  69. "SetVehicleZAngle", "SetWeater", "SetWorldTime", "ShowMenuForPlayer", "ShowNameTags", "ShowPlayerMarkers", "ShowPlayerNameTagForPlayer", "SpawnPlayer", "StopObject",
  70. "StopPlayerObject", "strcmp", "strlen", "strmid", "strval", "strfind", "strins",
  71.  
  72. "TextDrawAlignment", "TextDrawBackgroundColor", "TextDrawBoxColor", "TextDrawColor", "TextDrawCreate", "TextDrawDestroy", "TextDrawFont",
  73. "TextDrawHideForAll", "TextDrawHideForPlayer", "TextDrawLetterSize", "TextDrawSetOutline", "TextDrawProportional", "TextDrawSetShadow",
  74. "TextDrawSetString", "TextDrawShowForAll", "TextDrawShowForPlayer", "TextDrawTextSize", "TextDrawUseBox", "GetTickCount", "TogglePlayerClock", "TogglePlayerControllable",
  75.  
  76. "UsePlayerPedAnims"
  77. };
  78. new FunctionCounts[sizeof(PawnFunctions)];
  79.  
  80.  
  81. new OtherFunctions[][] =
  82. {
  83. "#define", "{", "}"
  84. };
  85. new OtherFunctionCounts[sizeof(OtherFunctions)];
  86. new TotalLines;
  87.  
  88. public OnFilterScriptInit()
  89. {
  90. print("--------------------------------------");
  91. print(" Script-Debug by =>Sandra<= ");
  92. print(" succesfully loaded! ");
  93. print(" ");
  94. print(" Type /debug to start ");
  95. print("--------------------------------------");
  96. return 1;
  97. }
  98.  
  99. public OnFilterScriptExit()
  100. {
  101. print("--------------------------------------");
  102. print(" Script-Debug by =>Sandra<= ");
  103. print(" succesfully unloaded! ");
  104. print("--------------------------------------");
  105. return 1;
  106. }
  107.  
  108. public OnRconCommand(cmd[])
  109. {
  110. if(strcmp(cmd, "/debug", true)==0)
  111. {
  112. TotalLines = 0;
  113. CountScriptLines();
  114. printf("Analyzing %d lines... Please Wait...", TotalLines);
  115. for(new func; func<sizeof(OtherFunctionCounts); func++)
  116. {
  117. OtherFunctionCounts[func] = 0;
  118. }
  119. CountBracketsAndDefines();
  120. CountFunctions();
  121. print("\n\n\n\n");
  122. print(" ________________________________________________________________");
  123. print("| ScriptDebug by =>Sandra<= |");
  124. print("| Debug Results: |");
  125. print("| _______________________________________________________________|");
  126. printf("| Total Lines: %5d |", TotalLines);
  127. printf("| Total Opening brackets: %5d |", OtherFunctionCounts[1]);
  128. printf("| Total Closing brackets: %5d |", OtherFunctionCounts[2]);
  129. printf("| Total Defines: %5d |", OtherFunctionCounts[0]);
  130. if( OtherFunctionCounts[1] != OtherFunctionCounts[2])
  131. {
  132. print("| _______________________________________________________________|");
  133. print("| Warning: The amount of opening brackets and closing brackets |");
  134. print("| does not match! |");
  135. }
  136. print("| _______________________________________________________________|");
  137. print("| |");
  138. print("| PawnFunctions: Times Used: |");
  139. print("|________________________________________________________________|");
  140. for(new func; func<sizeof(PawnFunctions); func++)
  141. {
  142. if(FunctionCounts[func] > 0)
  143. {
  144. printf(" %30s %dx",PawnFunctions[func], FunctionCounts[func]);
  145. }
  146. }
  147. print("| _______________________________________________________________|");
  148. print("| Debugging Done! |");
  149. print(" ________________________________________________________________");
  150. print("\n\n\n\n");
  151. return 1;
  152. }
  153. if(strcmp(cmd, "/searchfunction", true, 15)==0)
  154. {
  155. TotalLines = 0;
  156. CountScriptLines();
  157. if(!strlen(cmd[14]))
  158. {
  159. print("Error: Use /findfunction [Function]");
  160. return 1;
  161. }
  162. printf("Searching for \"%s\"... Please Wait...", cmd[16]);
  163. new entry[256], count, lines[999], newfunc[32];
  164. new File:scriptfile = fopen("ScriptDebug.txt", io_read);
  165. if (scriptfile)
  166. {
  167. format(newfunc, 32, "%s(", cmd[16]);
  168. for(new id; id<TotalLines; id++)
  169. {
  170. fread(scriptfile, entry);
  171. for(new i; i<strlen(entry); i++)
  172. {
  173. if(strfind(entry[i], newfunc, true)==0)
  174. {
  175. count++;
  176. lines[count-1] = (id+1);
  177. }
  178. }
  179. }
  180. }
  181. printf("\n__________________________________________\n");
  182. if(count == 0)
  183. {
  184. printf("\"%s\" is not found in your script!", cmd[16], count);
  185. }
  186. else
  187. {
  188. printf("\"%s\" is found %dx in your script", cmd[16], count);
  189. printf("You can find this function on these lines:");
  190. new str[256];
  191. for(new i; i<count; i++)
  192. {
  193. if(i == 0)
  194. {
  195. format(str, 256, "%d", lines[i]);
  196. }
  197. else
  198. {
  199. format(str, 256, "%s, %d", str, lines[i]);
  200. }
  201. }
  202. print(str);
  203. }
  204. printf("__________________________________________\n\n\n");
  205. return 1;
  206. }
  207. return 0;
  208. }
  209.  
  210. stock CountScriptLines()
  211. {
  212. new entry[256];
  213. new File: scriptfile = fopen("ScriptDebug.txt", io_read);
  214. while(fread(scriptfile, entry, 256))
  215. {
  216. TotalLines++;
  217. }
  218. fclose(scriptfile);
  219. }
  220.  
  221. stock CountFunctions()
  222. {
  223. new entry[256], newfunc[64];
  224. new File: scriptfile = fopen("ScriptDebug.txt", io_read);
  225. if (scriptfile)
  226. {
  227. for(new id; id<TotalLines; id++)
  228. {
  229. fread(scriptfile, entry);
  230. for(new func; func < sizeof(PawnFunctions); func++)
  231. {
  232. format(newfunc, 64, "%s(", PawnFunctions[func]);
  233. for(new i; i<strlen(entry); i++)
  234. {
  235. if(strfind(entry[i], newfunc, true)==0)
  236. {
  237. FunctionCounts[func]++;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. fclose(scriptfile);
  244. }
  245.  
  246. CountBracketsAndDefines()
  247. {
  248. new entry[256];
  249. new File:scriptfile = fopen("ScriptDebug.txt", io_read);
  250. if (scriptfile)
  251. {
  252. for(new id; id<TotalLines; id++)
  253. {
  254. fread(scriptfile, entry);
  255. for(new func; func<sizeof(OtherFunctions); func++)
  256. {
  257. for(new i; i<strlen(entry); i++)
  258. {
  259. if(strfind(entry[i], OtherFunctions[func], true)==0)
  260. {
  261. OtherFunctionCounts[func]++;
  262. }
  263. }
  264. }
  265. }
  266. }
  267. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement