pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

cueballstopusingy-lesspastebinplease private pastebin - collaborative debugging tool What's a private pastebin?


Posted by Cueball on Mon 4 Feb 06:35
report abuse | download | new post

  1.                                 /**************************************************
  2.                                  *         Command_Generator by ~Cueball~         *
  3.                                  **************************************************/
  4. #include <a_samp>
  5. #define FILTERSCRIPT
  6. #if defined FILTERSCRIPT
  7.  
  8. /*--------------------------------------------------------------------------/
  9. /                    Change These To Alter Script                           /
  10. //-------------------------------------------------------------------------*/
  11.  
  12. #define VehicleTele true
  13. #define PrintInConsole true
  14. #define SendAdminMessage true
  15.  
  16. new File:GenCmds;
  17.  
  18. public OnFilterScriptInit()
  19. {
  20.         print("\n**************************************************");
  21.     print("*         Command_Generator by ~Cueball~         *");
  22.     print("**************************************************\n");
  23.         if(!fexist("Generated_Commands.txt")) { GenCmds = fopen("Generated_Commands.txt", io_readwrite); fclose(GenCmds); }
  24.         return 1;
  25. }
  26.  
  27. public OnFilterScriptExit()
  28. {
  29.         print("\n**************************************************");
  30.     print("*            Command_Generator Closed            *");
  31.     print("**************************************************\n");
  32.         return 1;
  33. }
  34. #endif
  35.  
  36. public OnPlayerConnect(playerid)
  37. {
  38.         SendClientMessage(playerid,0x33CCFFAA,"Running Command_Generator Script by ~Cueball~ || To get started type /saveloc at your wanted location.");
  39.         return 1;
  40. }
  41.  
  42. public OnPlayerCommandText(playerid, cmdtext[])
  43. {
  44.         if(strcmp (cmdtext, "/saveloc", true)==0)
  45.         {
  46.                         new Float:x, Float:y, Float:z, Float:Ang, CommandName[700], VehicleLine[700], PlayerLine[700], AltPlayerLine[700], ReturnLine[50], EndBrace[50], NewLine[50], Separator[80], ConfirmationMessage[150], Stats[50], XValue[50], YValue[50], ZValue[50], ANGValue[50], AdminMessage[100], PlayerIp[50], PlayerName[MAX_PLAYER_NAME], hour, minute, second, year, month, day;
  47.                         if (!cmdtext[9]) { SendClientMessage(playerid,0xFFFFFFAA,"Usage: /saveloc [teleport/command name] (DO NOT INCLUDE THE '/'!)"); return 1; }
  48.                         GetPlayerName(playerid,PlayerName,MAX_PLAYER_NAME); GetPlayerIp(playerid,PlayerIp,50); GetPlayerPos(playerid,x,y,z); GetPlayerFacingAngle(playerid,Ang); gettime(hour,minute,second); getdate(year,month,day);
  49.                         format(CommandName,700,"if (strcmp(\"/%s\", cmdtext,true)==0) { //requested by player '%s' (IP:%s) on the %d/%d/%d. Time: %d:%d:%d\r\n",cmdtext[9],PlayerName,PlayerIp,day,month,year,hour,minute,second);
  50.                         format(VehicleLine,700,"   if (GetPlayerState(playerid) == 2) { SetVehiclePos(GetPlayerVehicleID(playerid),%f,%f,%f); SetVehicleZAngle(GetPlayerVehicleID(playerid), %f); SetCameraBehindPlayer(playerid); } \r\n",x,y,z,Ang);
  51.                         format(PlayerLine, 700,"   else { SetPlayerPos(playerid,%f,%f,%f); SetPlayerFacingAngle(playerid,%f); SetCameraBehindPlayer(playerid); }\r\n",x,y,z,Ang);
  52.             format(AltPlayerLine, 700,"   SetPlayerPos(playerid,%f,%f,%f); SetPlayerFacingAngle(playerid,%f); SetCameraBehindPlayer(playerid); SetPlayerInterior(playerid,%d);\r\n",x,y,z,Ang,GetPlayerInterior(playerid));
  53.                         format(ReturnLine,   50,"return 1;\r\n"); format(EndBrace,     50,"}\r\n"); format(NewLine,50," \r\n"); format(Separator, 80,"//=====================================================\r\n");
  54.                         format(ConfirmationMessage,150,"Command Generator: Your command '/%s' has been generated and sent to the server admin.",cmdtext[9]);
  55.                         format(Stats,50,"Command Statistics:"); format(XValue,50,"X value: %f",x); format(YValue,50,"Y value: %f",y); format(ZValue,50,"Z value: %f",z); format(ANGValue,50,"Angle value: %f",Ang);
  56.                         SendClientMessage(playerid,0x33CCFFAA,ConfirmationMessage); SendClientMessage(playerid,0x33CCFFAA,Stats);
  57.                         SendClientMessage(playerid,0xFFFFFFAA,XValue); SendClientMessage(playerid,0xFFFFFFAA,YValue); SendClientMessage(playerid,0xFFFFFFAA,ZValue); SendClientMessage(playerid,0xFFFFFFAA,ANGValue);
  58.                         SendClientMessage(playerid,0xFFFFFFAA,"Thankyou. Your command was very helpful to the server owner.");
  59.                         #if PrintInConsole == true
  60.                         printf("[generator] Player '%s' (IP:%s) requested '/%s'.", PlayerName,PlayerIp,cmdtext[9]);
  61.                         #endif
  62.                         #if SendAdminMessage == true
  63.                         format(AdminMessage,100,"GENERATOR: Player '%s' (ID:%d) requested '/%s'",PlayerName,playerid,cmdtext[9]); SendClientMessageToAdmins(0x33CCFFAA,AdminMessage);
  64.                         #endif
  65.                         GenCmds = fopen("Generated_Commands.txt", io_append); fwrite(GenCmds,CommandName);
  66.                         #if VehicleTele == true
  67.                         fwrite(GenCmds,VehicleLine); fwrite(GenCmds,PlayerLine);
  68.                         #endif
  69.                         #if VehicleTele != true
  70.                         fwrite(GenCmds,AltPlayerLine);
  71.                         #endif
  72.                         fwrite(GenCmds,ReturnLine); fwrite(GenCmds,EndBrace); fwrite(GenCmds,NewLine); fwrite(GenCmds,Separator); fwrite(GenCmds,NewLine); fclose(GenCmds);
  73.  
  74.                         return 1;
  75.                 }
  76.         return 0;
  77. }
  78.  
  79. stock SendClientMessageToAdmins(colour, const message[]) { // By 50p: http://forum.sa-mp.com/index.php?topic=638.msg59538#msg59538
  80.     for(new i=0; i<MAX_PLAYERS; i++) {
  81.         if(IsPlayerConnected(i)) {
  82.             if(IsPlayerAdmin(i)) {
  83.                 SendClientMessage(i, colour, message);
  84.             }
  85.         }
  86.     }
  87. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post