Guest User

Player Commands

a guest
Aug 11th, 2014
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 13.96 KB | None | 0 0
  1. //PcmdsV1.0
  2.  
  3. #include <a_samp>
  4. #include <zcmd>
  5. #include <sscanf2>
  6. #define RED                       0xAA3333AA
  7. #define YELLOW                    0xFFFF00AA
  8. #define PURPLE                    0x9370DBFF
  9. #define red 0xFF0000AA
  10. #define COLOR_YELLOW 0xFFFF00FF
  11. #define COLOR_BLUE 0x0000FFFF
  12. #define COLOR_RED 0xFF0000C7
  13. #define COLOR_GREEN 0x00FF00D0
  14. #define COLOR_WHITE         0xFFFFFFFF
  15. #define COLOR_NORMAL_PLAYER 0xFFBB7777
  16. #define COLOR_ORANGE 0xFF9900AA
  17. #define COLOR_LIME 0x10F441AA
  18. #pragma tabsize 0
  19. #if defined FILTERSCRIPT
  20.  
  21. public OnFilterScriptInit()
  22. {
  23.     print("\n--------------------------------------");
  24.     print("Player Commands Made by IloveImpulse V1");
  25.     print("--------------------------------------\n");
  26.     return 1;
  27. }
  28.  
  29. public OnFilterScriptExit()
  30. {
  31.     return 1;
  32. }
  33.  
  34. #else
  35.  
  36. main()
  37. {
  38.     print("\n----------------------------------");
  39.     print(" Blank Gamemode by your name here");
  40.     print("----------------------------------\n");
  41. }
  42.  
  43. #endif
  44.  
  45. public OnGameModeInit()
  46. {
  47.     // Don't use these lines if it's a filterscript
  48.     SetGameModeText("Blank Script");
  49.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  50.     return 1;
  51. }
  52.  
  53. public OnGameModeExit()
  54. {
  55.     return 1;
  56. }
  57.  
  58. public OnPlayerRequestClass(playerid, classid)
  59. {
  60.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  61.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  62.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  63.     return 1;
  64. }
  65.  
  66. public OnPlayerConnect(playerid)
  67. {
  68.     return 1;
  69. }
  70.  
  71. public OnPlayerDisconnect(playerid, reason)
  72. {
  73.     return 1;
  74. }
  75.  
  76. public OnPlayerSpawn(playerid)
  77. {
  78.     return 1;
  79. }
  80.  
  81. public OnPlayerDeath(playerid, killerid, reason)
  82. {
  83.     return 1;
  84. }
  85.  
  86. public OnVehicleSpawn(vehicleid)
  87. {
  88.     return 1;
  89. }
  90.  
  91. public OnVehicleDeath(vehicleid, killerid)
  92. {
  93.     return 1;
  94. }
  95.  
  96. public OnPlayerText(playerid, text[])
  97. {
  98.     return 1;
  99. }
  100.  
  101. public OnPlayerCommandText(playerid, cmdtext[])
  102. {
  103.     if (strcmp("/mycommand", cmdtext, true, 10) == 0)
  104.     {
  105.         // Do something here
  106.         return 1;
  107.     }
  108.     return 0;
  109. }
  110.  
  111. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  112. {
  113.     return 1;
  114. }
  115.  
  116. public OnPlayerExitVehicle(playerid, vehicleid)
  117. {
  118.     return 1;
  119. }
  120.  
  121. public OnPlayerStateChange(playerid, newstate, oldstate)
  122. {
  123.     return 1;
  124. }
  125.  
  126. public OnPlayerEnterCheckpoint(playerid)
  127. {
  128.     return 1;
  129. }
  130.  
  131. public OnPlayerLeaveCheckpoint(playerid)
  132. {
  133.     return 1;
  134. }
  135.  
  136. public OnPlayerEnterRaceCheckpoint(playerid)
  137. {
  138.     return 1;
  139. }
  140.  
  141. public OnPlayerLeaveRaceCheckpoint(playerid)
  142. {
  143.     return 1;
  144. }
  145.  
  146. public OnRconCommand(cmd[])
  147. {
  148.     return 1;
  149. }
  150.  
  151. public OnPlayerRequestSpawn(playerid)
  152. {
  153.     return 1;
  154. }
  155.  
  156. public OnObjectMoved(objectid)
  157. {
  158.     return 1;
  159. }
  160.  
  161. public OnPlayerObjectMoved(playerid, objectid)
  162. {
  163.     return 1;
  164. }
  165.  
  166. public OnPlayerPickUpPickup(playerid, pickupid)
  167. {
  168.     return 1;
  169. }
  170.  
  171. public OnVehicleMod(playerid, vehicleid, componentid)
  172. {
  173.     return 1;
  174. }
  175.  
  176. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  177. {
  178.     return 1;
  179. }
  180.  
  181. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  182. {
  183.     return 1;
  184. }
  185.  
  186. public OnPlayerSelectedMenuRow(playerid, row)
  187. {
  188.     return 1;
  189. }
  190.  
  191. public OnPlayerExitedMenu(playerid)
  192. {
  193.     return 1;
  194. }
  195.  
  196. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  197. {
  198.     return 1;
  199. }
  200.  
  201. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  202. {
  203.     return 1;
  204. }
  205.  
  206. public OnRconLoginAttempt(ip[], password[], success)
  207. {
  208.     return 1;
  209. }
  210.  
  211. public OnPlayerUpdate(playerid)
  212. {
  213.     return 1;
  214. }
  215.  
  216. public OnPlayerStreamIn(playerid, forplayerid)
  217. {
  218.     return 1;
  219. }
  220.  
  221. public OnPlayerStreamOut(playerid, forplayerid)
  222. {
  223.     return 1;
  224. }
  225.  
  226. public OnVehicleStreamIn(vehicleid, forplayerid)
  227. {
  228.     return 1;
  229. }
  230.  
  231. public OnVehicleStreamOut(vehicleid, forplayerid)
  232. {
  233.     return 1;
  234. }
  235.  
  236. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  237. {
  238.     return 1;
  239. }
  240.  
  241. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  242. {
  243.     return 1;
  244. }
  245. CMD:kill(playerid, params[])
  246. {
  247. SetPlayerHealth(playerid,0);
  248. return 1;
  249. }
  250. CMD:givemoney(playerid, params[])
  251. {
  252.     new targetid, ammount;
  253.     if(sscanf(params,"ui", targetid, ammount)) return SendClientMessage(playerid, 0xFFFFFFF,"Syntax error.Correct usage: /givemoney [PlayerID] [Ammount]");
  254.     if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFF,"That player is not connected to your server!");
  255.     GivePlayerMoney(targetid, ammount);
  256.     return 1;
  257. }
  258. CMD:me(playerid, params[])
  259. {
  260.     new string[128],pname[MAX_PLAYER_NAME]; //this is enough for the line "%s %s"/we will gonna define pname with GetPlayerName
  261.     GetPlayerName(playerid, pname, MAX_PLAYER_NAME); //pname is defined here with GetPlayerName
  262.     if(isnull(params)) return SendClientMessage(playerid, COLOR_RED, "SYNTAX: /me <text>"); //if player didn't type something this message will be showed example if you type: /me only the word will be showed
  263.     format(string, sizeof(string), "[ME]: %s %s", pname, params); //will gonna format the word "[ME]: %s %s" with string/pname/params and gonna use on SendClientMessageToAll - %s - inserts a string.
  264.     SendClientMessageToAll(-1, string); //this will be sent to the everyone with format string.
  265.     return 1;
  266. }
  267. CMD:Greet(playerid, params[])
  268. {
  269.     SendClientMessage(playerid, COLOR_GREEN,"Hello Everyone!");
  270.     return 1;
  271. }
  272. CMD:skin(playerid,params[])
  273. {
  274.     new skinnumber, skinid, string[128];
  275.     if(sscanf(params, "d", skinid)) return SendClientMessage(playerid, -1, "{ffff00}=USAGE=: {ffffff}/skin <skinid>");
  276.     if(skinid < 0 || skinid > 299) return SendClientMessage(playerid, 0xFF000000, "{ff0000}=ERROR=: {ffffff}Choose a skin between 0 to 299!");
  277.     SetPlayerSkin(playerid, skinid);
  278.     skinnumber = GetPlayerSkin(playerid);
  279.     format(string, sizeof(string), "{ffff00}=INFO=: {ffffff}You have changed your skin to %d", skinnumber);
  280.     SendClientMessage(playerid, -1, string);
  281.     return 1;
  282. }
  283.  
  284. CMD:goto(playerid, params[])
  285. {
  286.      new ID;
  287.      new pn[MAX_PLAYER_NAME];
  288.      new an[MAX_PLAYER_NAME];
  289.      new str[128];
  290.      if(sscanf(params, "u", ID)) return SendClientMessage(playerid, 0xFF0000AA, "USAGE: /goto [ID]"); //This is a long line, "sscanf" is the plugin that search the missing params, "params" is the param that define params LOL, "u" is the PARAM that define the MISSING ID, ID is the param for the targetid
  291.      if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: This player is not connected");//Same as !IsPlayerAdmin, but instead of "playerid" we put "ID" because it's the targetid
  292.      GetPlayerName(playerid, an, MAX_PLAYER_NAME);//Define the playerid's param
  293.      GetPlayerName(ID, pn, MAX_PLAYER_NAME);//Define the ID's param
  294.      new Float:x; //Defining float X
  295.      new Float:y; //Same
  296.      new Float:z; //Same
  297.      GetPlayerPos(ID, x, y, z); //This line get the "ID" position
  298.      SetPlayerPos(playerid, x+1, y+1, z); //This line set the "playerid" position from "ID" position, with some changes(x+1, y+1);
  299.      format(str, sizeof(str), "You have been teleported to %s", pn); //Showed before, this is the line that give the message to playerid)
  300.      SendClientMessage(playerid, 0x00FF00AA, str); //This line give the message to playerid
  301.      if(IsPlayerInAnyVehicle(playerid)) //Mhh, let's give you a question, what should this callback do?
  302.      {
  303.           GetPlayerPos(ID, x, y, z);
  304.           SetVehiclePos(playerid, x+1, y+1, z); //And this one? :D
  305.      }
  306.      return 1;
  307. }
  308.  
  309. CMD:rules(playerid, params[])
  310.  {
  311.         SendClientMessage(playerid,COLOR_RED,"-");
  312.         SendClientMessage(playerid,COLOR_RED,"Cheating is strict forbidden, Doing it can lead to ban!");
  313.         SendClientMessage(playerid,COLOR_RED,"Do not Spam/Provoke, Doing it can lead to punishment!");
  314.         SendClientMessage(playerid,COLOR_RED,"Always Respect/Listen the Admins, They are here to help you!");
  315.     return 0;
  316. }
  317.  
  318. CMD:credits(playerid, params[])
  319. {
  320.  SendClientMessage(playerid,COLOR_RED,"Founder/Developer: - ");
  321.  SendClientMessage(playerid,COLOR_YELLOW,"Forum Developer: - ");
  322.  SendClientMessage(playerid,COLOR_GREEN,"Server Mappers: - ");
  323.     return 0;
  324. }
  325.  
  326. CMD:cmds(playerid, params[])
  327.  {
  328.         SendClientMessage(playerid,COLOR_BLUE,"goto,me,kill,rules,credits,skin,cmds,report,myid");
  329.     return 0;
  330. }
  331.  
  332. CMD:myid(playerid, params[])
  333. {
  334.     new string[90]; //this is enough for the line "Your id is %d" - we will gonna format the word "Your id is %d"
  335.     format(string, sizeof(string), "Your id is %d", playerid); //will gonna format the word "Your id is %d" with string/playerid and gonna use on SendClientMessage - %d - Inserts an integer (whole) number
  336.     SendClientMessage(playerid, -1, string); //this will be sent to the player who type /myid with the format string
  337.     return 1;
  338. }
  339. CMD:afk(playerid, params[])
  340. {
  341.   new name[MAX_PLAYER_NAME], string[128]; //Here we area creating a new "name" and a new "string" with the size of 128. What the size basicly means is the amount of words..symbols..etc it can carry.
  342.   GetPlayerName(playerid, name, MAX_PLAYER_NAME); //Here we are getting the name of the "playerid" which is us, and we are assigning/defining it to "name" with the size of max player name.
  343.   format(string, sizeof(string), "%s is now afk", name); //Now here we are formating our string that we just made. What I mean by that is that we are adding our text in the string, and letting pawno add the name of our playerid which again is us..if you look at this part "%s is now afk", name %s means a string and if you test this ingame I think you will get it, after our text there is ",name" at this part we are telling pawno that the %s is the value of "name" that we just defined earlier.
  344.   SendClientMessageToAll(COLOR_GREEN, string); //Now here we are sending our string to everyone in the server.
  345.   TogglePlayerControllable(playerid, 0); //Here we are making the player not moveable what I mean by that is that he can't move at all, he can't even move the camera.
  346.   return 1; // Here we are making the our code get returned to the player what I mean by that is that it will let the code work. If you choose return 0 it wont return anything, ingame you will get the UNKOWN SERVER COMMAND error
  347. }
  348. CMD:back(playerid, params[])
  349. {
  350.     new name[MAX_PLAYER_NAME], string[128]; //Again here we are creating a new "name" and a new "string" with the size of 128.
  351.     GetPlayerName(playerid, name, MAX_PLAYER_NAME); //Here we are getting the playerid's name which means us the guy that typed in the command..So now we are getting the name of the player that typed in the command and assigning it to "name" with the size of max player name.
  352.     format(string, sizeof(string), "%s is now back from afk", name); //Now here we are formating our string.
  353.     SendClientMessageToAll(COLOR_GREEN, string); //Here we are sending our string to everyone in the  server.
  354.     TogglePlayerControllable(playerid, 1); //At this part we are making the player moveable again.
  355.     return 1; //Here we are making the code get returned to the player so it works.
  356. }
  357.  
  358. CMD:pm( playerid, params[ ] ) // We will create a new command ( /pm )
  359. { // Opening bracket
  360.  
  361.     new // creating new variables
  362.         iTarget, // a variable called iTarget
  363.         szMsg[ 100 ]; // a variable called szMsg. This will be a string that can carry 100 characters
  364.  
  365.     if ( sscanf( params, "rs[100]", iTarget, szMsg ) )
  366.     {   // If the player hasn't entered the player or the message ( r = playerID / name || s = string )
  367.         return SendClientMessage( playerid, 0xFF3333AA, "[USAGE]: /pm ( id/name ) ( message )" );
  368.         // Sends the player message about the correct command usage.
  369.     }
  370.  
  371.     if ( iTarget == INVALID_PLAYER_ID ) // The player is not connected!
  372.     {
  373.         return SendClientMessage( playerid, 0xFF3333AA, "[ERROR]: That player is not connected!" );
  374.         // Sends the player message that he/she has entered a wrong ID.
  375.     }
  376.  
  377.     new
  378.         szStr[ 128 ];   // Now, we will create another variable called " szStr ".
  379.                         // 128 is the max size for client mesages.
  380.     new
  381.         pName[ MAX_PLAYER_NAME ], // We will create another variable which will store the sender's name
  382.         tName[ MAX_PLAYER_NAME ]; // Same as above, except this is to store the target's name
  383.  
  384.     GetPlayerName( playerid, pName, MAX_PLAYER_NAME );
  385.     // We will get the sender's name and store it at the pName variable
  386.  
  387.     GetPlayerName( iTarget, tName, MAX_PLAYER_NAME );
  388.     // We will get the target's name and store it at the tName variable
  389.  
  390.     // We will format the message.
  391.     format( szStr, sizeof ( szStr ), "[PM from %s]: %s", pName, szMsg );
  392.     // %s is used to format strings, the first %s is the player's name ( pName ),
  393.     // and the second %s is the message. ( szMsg )
  394.  
  395.     SendClientMessage( iTarget, 0x33FF33AA, szStr );
  396.     // Sends the target the PM which the sender has sent.
  397.  
  398.     // We will format another message.
  399.     format( szStr, sizeof ( szStr ), "[PM to %s]: %s", tName, szMsg );
  400.     // %s is used to format strings, the first %s is the target's name ( tName ),
  401.     // and the second %s is the message. ( szMsg )
  402.  
  403.     SendClientMessage( playerid, 0x33FF33AA, szStr );
  404.     // Sends the sender message about the message he has sent.
  405.  
  406.     return true;
  407. }
  408. CMD:report(playerid, params[]) {
  409. new id;
  410.     new reason[128];
  411.     if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, COLOR_ORANGE, "[SERVER] - USAGE: /report [ID] [REASON]");
  412.     new string[150], sender[MAX_PLAYER_NAME], receiver[MAX_PLAYER_NAME];
  413.     GetPlayerName(playerid, sender, sizeof(sender));
  414.     GetPlayerName(id, receiver, sizeof(receiver));
  415.     format(string, sizeof(string), "[ADMIN] - %s(%d) has reported %s(%d)", sender, playerid, receiver, id);
  416.     SendMessageToAdmins(string);
  417.     format(string, sizeof(string), "[ADMIN] - Reason: %s", reason);
  418.     SendMessageToAdmins(string);
  419.     SendClientMessage(playerid, COLOR_ORANGE, "Your report has been sent.");
  420.     return 1;
  421. }
  422. stock SendMessageToAdmins(text[])
  423. {
  424.     for(new i = 0; i < MAX_PLAYERS; i++)
  425.     {
  426.         if(IsPlayerAdmin(i))
  427.         {
  428.             SendClientMessage(i, COLOR_LIME, text);
  429.         }
  430.     }
  431. }
Advertisement
Add Comment
Please, Sign In to add comment