Advertisement
Guest User

MySQL R39-3 v1.1

a guest
Apr 3rd, 2015
2,551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.80 KB | None | 0 0
  1. /*
  2. This is Simple MySQL r9-3 GameMode by JeaSon
  3. Do no re release without my permission
  4.  
  5. */
  6.  
  7. //First, of course we need to include these files first
  8. #include <a_samp> //Without this, we won't be able to use all samp functions/callbacks
  9. #include <a_mysql> //Without this, we won't be able to use all mysql functions
  10. #include <sscanf2> // without this we wont be able to use commands and compile code
  11. #include <zcmd> // without this our commands will not work
  12.  
  13. //Let's define our mysql settings
  14. #define host "localhost" //This will be your mysql host. Default for xampp is localhost
  15. #define user "root" //This will be your mysql username. Default for xampp is root
  16. #define db "sami" //This is your database name. Remember we have created a database called server before.
  17. #define pass "" //This is your mysql password. In xampp, the password didn't set. So leave it empty.
  18.  
  19. //dialogs
  20. #define dREGISTER 1 //dialog register id
  21. #define dLOGIN 2 // ^dialog login id
  22. #define dSTATS 3 //dialog stats id
  23.  
  24. #define LIST_COMMAND true
  25. #define LIST_USE_DIALOG false
  26.  
  27. #define COMMAND_BLOCKED_MSG "This command has been blocked, you cannot use it."
  28. #define COMMAND_BLOCKED_COLOR 0xFF0000FF
  29. #define MAX_COMMAND_BLOCKED 25
  30.  
  31. #define COLOR_RED 0xFF0000FF
  32. #define COLOR_CMY 0xFFFF00FF
  33. #define COLOR_YELLOW 0xFFDD00AA
  34. //these are custom callbacks so they must be forwarded otherwise compiler will show error
  35. forward OnAccountCheck(playerid);
  36. forward OnAccountLoad(playerid);
  37. forward OnAccountRegister(playerid);
  38. forward UnMutedTimer(playerid);
  39.  
  40. new BlockedCommand[MAX_COMMAND_BLOCKED][25];
  41. new IsPlayerRegisterd[MAX_PLAYERS];
  42. new bool:pMuted[MAX_PLAYERS];//Global variables. We will use them later
  43.  
  44. static
  45. mysql, //This variable will be used to manage our database
  46. Name[MAX_PLAYERS][24], //We will use this variable to store player's name.
  47. IP[MAX_PLAYERS][16] //We will use this variable to store player's ip.
  48. ;
  49.  
  50. native WP_Hash(buffer[], len, const str[]); //whirlpool, for hashing our password
  51.  
  52. //Now let's create an enumerator that holds player's information
  53. enum DATAX //We name our enumerator as PDATA (which stands for PlayerDATA). You can name it however you want.
  54. {
  55. ID, //Will be used later to store player's ID from database so we can use it anywhere later
  56. Password[129], //We will load player's password into this varible from database
  57. Admin, //We will load player's admin level from database into this variable so we can use it anywhere later.
  58. VIP, //We will load player's VIP level from database into this variable so we can use it anywhere later.
  59. Kills,
  60. Deaths,
  61. Score,
  62. Money //We will load player's money from database into this variable so we can use it anywhere later.
  63. }
  64. new pData[MAX_PLAYERS][DATAX]; //Variable that stores enumerator above
  65.  
  66. main(){}
  67. public OnGameModeInit()
  68. {
  69. mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG); //Let's enable debugging so we can detect a problem(if there is)
  70. mysql = mysql_connect(host, user, db, pass); //This function will connect your server to database. Remember we have defined our host, username, database and password. It's time to use it here.
  71. if(mysql_errno(mysql) != 0)
  72. {
  73. print("Could not connect to database!"); //This will tell if your connection to database is successful or not. If it's not, check your host, username, database and password. Make sure they all right.
  74. }
  75. else
  76. {
  77. printf("Successfully connected on DB %s",db);
  78. }
  79. SetGameModeText("MySQL R9-3");
  80. return 1;
  81. }
  82.  
  83. //Checking player's account if they are registered or not.
  84. public OnPlayerConnect(playerid)
  85. {
  86. // resetting player enums so old's stats wont mix to new playerid
  87. for(new i; DATAX:i < DATAX; i++)
  88. {
  89. pData[playerid][DATAX:i] = 0;
  90. }
  91. IsPlayerRegisterd[playerid] = 0;
  92.  
  93. new query[128]; //We use this variable to format our query
  94. GetPlayerName(playerid, Name[playerid], 24); //Getting player's name
  95. GetPlayerIp(playerid, IP[playerid], 16); //Getting layer's IP
  96. mysql_format(mysql, query, sizeof(query),"SELECT `IP`, `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
  97. // - We use mysql_format instead of format because we can use an %e specifier. %e specifier escapes a string so we can avoid sql injection which means we don't have to use mysql_real_escape_string
  98. // - Formatting our query; SELECT `Password`, `ID` FROM `players` WHERE `Username`='%e' means we are selecting a Password and ID's column in the table that has player's name in Username column.
  99. // - LIMIT 1; we only need 1 result to be shown
  100. mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
  101. //lets execute the formatted query and when the execution is done, a callback OnAccountCheck will be called
  102. //You can name the callback however you like
  103. return 1;
  104. }
  105.  
  106.  
  107. //Now once the query has been processed;
  108. public OnAccountCheck(playerid)
  109. {
  110. new rows, fields; //a variable that will be used to retrieve rows and fields in the database.
  111. cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
  112. if(rows) //if there is row
  113. {
  114. cache_get_field_content(0, "IP", IP[playerid], mysql, 16);
  115. new newIP[16];
  116. GetPlayerIp(playerid, newIP, 16);
  117. IsPlayerRegisterd[playerid] = 1;
  118.  
  119. if(strlen(IP[playerid]) != 0 && !strcmp(IP[playerid], newIP, true)) //Checks that the MySQL IP has a value and that they are the same.
  120. {
  121. GameTextForPlayer(playerid, "Loading Account", 3000, 3);
  122. SetTimerEx("OnAccountLoad", 3000, false, "i", playerid);
  123. }
  124. else
  125. {
  126. (!strlen(IP[playerid]) || strcmp(IP[playerid], newIP, true));
  127. //then
  128. cache_get_field_content(0, "Password", pData[playerid][Password], mysql, 129);
  129. //we will load player's password into pData[playerid][Password] to be used in logging in
  130. pData[playerid][ID] = cache_get_field_content_int(0, "ID"); //now let's load player's ID into pData[playerid][ID] so we can use it later
  131. printf("%s", pData[playerid][Password]); //OPTIONAL: Just for debugging. If it didn't show your password, then there must be something wrong while getting player's password
  132. ShowPlayerDialog(playerid, dLOGIN, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login", "Login", "Quit"); //And since we found a result from the database, which means, there is an account; we will show a login dialog
  133. }
  134. }
  135. else //if we didn't find any rows from the database, that means, no accounts were found
  136. {
  137. ShowPlayerDialog(playerid, dREGISTER, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.", "Register", "Quit");
  138. //So we show them a dialog register
  139. }
  140.  
  141. return 1;
  142. }
  143.  
  144. //Now let's response to the login and register dialog
  145. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  146. {
  147. switch(dialogid)
  148. {
  149. case dLOGIN: //login dialog
  150. {
  151. if(!response) Kick(playerid); //if they clicked Quit, we will kick them
  152. new hpass[129]; //for password hashing
  153. new query[100]; // for formatting our query.
  154. WP_Hash(hpass, 129, inputtext); //hashing inputtext
  155. if(!strcmp(hpass, pData[playerid][Password])) //remember we have loaded player's password into this variable, pData[playerid][Password] earlier. Now let's use it to compare the hashed password with password that we load
  156. { //if the hashed password matches with the loaded password from database
  157. mysql_format(mysql, query, sizeof(query), "SELECT * FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
  158. //let's format our query
  159. //We select all rows in the table that has your name and limit the result to 1
  160. mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
  161. //lets execute the formatted query and when the execution is done, a callback OnAccountLoad will be called
  162. //You can name the callback however you like
  163. }
  164. else //if the hashed password didn't match with the loaded password(pData[playerid][Password])
  165. {
  166. //we tell them that they have inserted a wrong password
  167. ShowPlayerDialog(playerid, dLOGIN, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login\nWrong password!", "Login", "Quit");
  168. }
  169. }
  170. case dREGISTER: //register dialog
  171. {
  172. if(!response) return Kick(playerid); //if they clicked Quit, we will kick them
  173. if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, dREGISTER, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.\nYour password must be at least 6 characters long!", "Register", "Quit");
  174. //strlen checks a lenght of a string. so if player types their password that is lower than 6, we tell them; Your password must be at least 6 characters long!
  175. new query[300];
  176. WP_Hash(pData[playerid][Password], 129, inputtext); //hashing inputtext
  177. mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `VIP`,`Kills`,`Deaths`,`Score`, `Money`) VALUES ('%e', '%s', '%s', 0, 0, 0, 0, 0, 50000)", Name[playerid], pData[playerid][Password], IP[playerid]);
  178. //Now let's create a new row and insert player's information in it
  179. mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
  180. //let's execute the query
  181. }
  182. }
  183. return 1;
  184. }
  185.  
  186.  
  187. //let's load player's information
  188. public OnAccountLoad(playerid)
  189. {
  190. new score;
  191. pData[playerid][Admin] = cache_get_field_content_int(0, "Admin"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
  192. pData[playerid][VIP] = cache_get_field_content_int(0, "VIP"); //Above
  193. pData[playerid][Money] = cache_get_field_content_int(0, "Money");//Above
  194. pData[playerid][Kills] = cache_get_field_content_int(0,"Kills");
  195. pData[playerid][Deaths] = cache_get_field_content_int(0, "Deaths");
  196. score = cache_get_field_content_int(0, "Score");
  197. SetPlayerScore(playerid, score);
  198. GivePlayerMoney(playerid, pData[playerid][Money]);//Let's set their money
  199. //For player's position, set it once they spawn(OnPlayerSpawn)
  200. SendClientMessage(playerid, -1, "Successfully logged in"); //tell them that they have successfully logged in
  201. return 1;
  202. }
  203.  
  204. public OnAccountRegister(playerid)
  205. {
  206. pData[playerid][ID] = cache_insert_id(); //loads the ID of the player in the variable once they registered.
  207. printf("New account registered. ID: %d", pData[playerid][ID]); //just for debugging.
  208. pData[playerid][Money] = 50000;
  209. GivePlayerMoney(playerid, 50000);
  210. return 1;
  211. }
  212.  
  213. public OnPlayerDisconnect(playerid, reason)
  214. {
  215. if(IsPlayerRegisterd[playerid] != 0)
  216. {
  217. SavePlayerData(playerid);
  218. }
  219. return 1;
  220. }
  221.  
  222. public OnPlayerDeath(playerid, killerid, reason)
  223. {
  224. if(killerid != INVALID_PLAYER_ID)
  225. {
  226. SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
  227. pData[killerid][Kills]++;
  228. }
  229. pData[playerid][Deaths]++;
  230. return 1;
  231. }
  232.  
  233.  
  234. stock SavePlayerData(playerid)
  235. {
  236. new query[100]; //query[128] is for formatting our query and Float:pos[3] is for getting and saving player's position
  237. mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `IP`='%s', `Admin`=%d, `VIP`=%d, `Kills`=%d, `Deaths`=%d, `Score`=%d, `Money`=%d WHERE `ID`=%d",\
  238. IP[playerid], pData[playerid][Admin], pData[playerid][VIP], pData[playerid][Kills], pData[playerid][Deaths], GetPlayerScore(playerid), pData[playerid][Money], pData[playerid][ID]);
  239. //We update the table(`players`) by getting player's admin level, vip level, money, and positions and save them in the database
  240. mysql_tquery(mysql, query, "", "");
  241. //let's execute the query.
  242. }
  243.  
  244. CMD:setlevel(playerid, params[])
  245. {
  246. new lookupid, str[128], level;
  247. if(pData[playerid][Admin] == 5)
  248. {
  249.  
  250. if(sscanf(params,"ud",lookupid,level)) return SendClientMessage(playerid, -1, "Usage: /setlevel (UserID | UserName) (level)");
  251. if(pData[lookupid][Admin] > pData[playerid][Admin]) return SendClientMessage(playerid, -1, "Sorry you cant setlevel becoz his level is higher then you");
  252. if(level < 1 ||level > 5) return SendClientMessage(playerid, -1, "1 to 5 levels"); // you can change this to any level you want
  253. if(!IsPlayerConnected(lookupid)) return SendClientMessage(playerid, -1, "Sorry this player isnt connected ");
  254. if(level < pData[lookupid][Admin])
  255. {
  256. format(str, sizeof(str), "Admin %s (ID:%d) has demoted you to level %d",GetName(playerid), playerid, level);
  257. SendClientMessage(lookupid, -1, str);
  258. format(str, sizeof(str),"You have demoted %s (ID:%d) to level %d",GetName(lookupid),lookupid,level);
  259. SendClientMessage(playerid, -1, str);
  260. }
  261. if(level > pData[lookupid][Admin])
  262. {
  263. format(str, sizeof(str), "Admin %s (ID:%d) has promoted you to level %d",GetName(playerid), playerid, level);
  264. SendClientMessage(lookupid, -1, str);
  265. format(str, sizeof(str),"You have promoted %s (ID:%d) to level %d",GetName(lookupid),lookupid,level);
  266. SendClientMessage(playerid, -1, str);
  267. }
  268. }
  269. else return SendClientMessage(playerid, -1, "You are not authorized to can use this command");
  270. return 1;
  271. }
  272.  
  273. CMD:setvip(playerid, params[])
  274. {
  275. new lookupid, str[128], level;
  276. if(pData[playerid][Admin] == 5)
  277. {
  278.  
  279. if(sscanf(params,"ud",lookupid,level)) return SendClientMessage(playerid, -1, "Usage: /setlevel (UserID | UserName) (level)");
  280. if(pData[lookupid][Admin] > pData[playerid][Admin]) return SendClientMessage(playerid, -1, "Sorry you cant setlevel becoz his level is higher then you");
  281. if(level < 1 ||level > 5) return SendClientMessage(playerid, -1, "1 to 5 levels"); // you can change this to any level you want
  282. if(!IsPlayerConnected(lookupid)) return SendClientMessage(playerid, -1, "Sorry this player isnt connected ");
  283. if(level < pData[lookupid][Admin])
  284. {
  285. format(str, sizeof(str), "Admin %s (ID:%d) has demoted you to VIP level %d",GetName(playerid), playerid, level);
  286. SendClientMessage(lookupid, -1, str);
  287. format(str, sizeof(str),"You have demoted %s (ID:%d) to VIP level %d",GetName(lookupid),lookupid,level);
  288. SendClientMessage(playerid, -1, str);
  289. }
  290. if(level > pData[lookupid][Admin])
  291. {
  292. format(str, sizeof(str), "Admin %s (ID:%d) has promoted you to VIP level %d",GetName(playerid), playerid, level);
  293. SendClientMessage(lookupid, -1, str);
  294. format(str, sizeof(str),"You have promoted %s (ID:%d) to VIP level %d",GetName(lookupid),lookupid,level);
  295. SendClientMessage(playerid, -1, str);
  296. }
  297. }
  298. else return SendClientMessage(playerid, -1, "You are not authorized to can use this command");
  299. return 1;
  300. }
  301.  
  302. CMD:stats(playerid, params[])
  303. {
  304. new str[64];
  305. new deaths = pData[playerid][Deaths];
  306. if(!deaths) deaths = 1;
  307. new Float:kd = floatdiv(pData[playerid][Kills], deaths);
  308. format(str, sizeof(str),"Your Stats\nScore: %d\nKills: %d\nDeaths: %d\nKD-Ratio: %0.2f\nMoney: %d\n Level: %d",pData[playerid][Score],pData[playerid][Kills],pData[playerid][Deaths],kd,pData[playerid][Money],pData[playerid][Admin]);
  309. ShowPlayerDialog(playerid, dSTATS,DIALOG_STYLE_MSGBOX,"Account stats",str, "Close","");
  310. return 1;
  311. }
  312.  
  313. CMD:mute(playerid, params[])
  314. {
  315. if(pData[playerid][Admin] >= 3) // player is not admin
  316. {
  317. new id, mins, str[128];
  318.  
  319. if(sscanf(params,"ui",id,mins)) return SendClientMessage(playerid, -1,"Usage: /mute <playerid> <minutes>");
  320. if (!IsPlayerConnected(id)) return 1; // invalid player
  321. if(pMuted[id] == true) return SendClientMessage(playerid, COLOR_RED,"already muted ");
  322.  
  323. pMuted[id] = true;
  324.  
  325. format(str, sizeof(str),"Admin %s (ID:%d) has muted %s (ID:%d) for %d min(s)",GetName(playerid), playerid, GetName(id), id, mins);
  326. SendClientMessageToAll(COLOR_RED, str);
  327. SetTimerEx("UnMutedTimer", 60*1000*mins, false, "i", id); //60*1000 = 1 minute
  328.  
  329. }
  330. return 1;
  331. }
  332.  
  333. CMD:unmute(playerid, params[])
  334. {
  335. if(pData[playerid][Admin] >= 3) // player is not admin
  336. {
  337. new id, str[128];
  338. if(sscanf(params,"u",id)) return SendClientMessage(playerid, COLOR_CMY,"Usage: /mute <playerid>");
  339. if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_CMY,"target is not connected"); // invalid player id
  340. if(pMuted[id] == false) return SendClientMessage(playerid, COLOR_RED,"Player is not muted ");
  341.  
  342. pMuted[id] = false;
  343.  
  344. format(str, sizeof(str),"Admin %s (ID:%d) has unmuted %s (ID:%d)",GetName(playerid), playerid, GetName(id), id);
  345. SendClientMessageToAll(COLOR_RED, str);
  346. }
  347. return 1;
  348. }
  349.  
  350. public UnMutedTimer(playerid)
  351. {
  352. new str[128];
  353. pMuted[playerid] = false;
  354. format(str,sizeof(str),"%s (ID:%d) has been auto unmuted by server ",GetName(playerid), playerid);
  355. SendClientMessageToAll(COLOR_RED, str);
  356. return 1;
  357. }
  358.  
  359.  
  360. CMD:setmoney(playerid, params[])
  361. {
  362. new str[128], lookupid, amount;
  363. if(pData[playerid][Admin] >= 3)
  364. {
  365. if(sscanf(params, "ui",lookupid, amount)) return SendClientMessage(playerid ,COLOR_YELLOW, "Usage: /setmoney <playerid/Name> <amount>");
  366. if(!IsPlayerConnected(lookupid)) return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected");
  367. format(str, sizeof(str), "Admin %s (ID:%d) has setted %s (ID:%d) money count to (%d)", GetName(playerid), playerid, GetName(lookupid),lookupid, amount);
  368. SendClientMessage(lookupid, COLOR_YELLOW, str);
  369. SetPlayerMoney(lookupid, amount);
  370. pData[lookupid][Money] = amount;
  371. } else return SendClientMessage(playerid, COLOR_YELLOW, "Only admin level 3+ can use this cmd");
  372. return 1;
  373. }
  374.  
  375. CMD:setscore(playerid, params[])
  376. {
  377. new str[128], lookupid, amount;
  378. if(pData[playerid][Admin] >= 3)
  379. {
  380. if(sscanf(params, "ui",lookupid, amount)) return SendClientMessage(playerid ,COLOR_YELLOW, "Usage: /setscore <playerid/Name> <amount>");
  381. if(!IsPlayerConnected(lookupid)) return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected");
  382. format(str, sizeof(str), "Admin %s (ID:%d) has setted %s (ID:%d) score count to (%d)", GetName(playerid), playerid, GetName(lookupid),lookupid, amount);
  383. SendClientMessage(lookupid, COLOR_YELLOW, str);
  384. SetPlayerScore(lookupid, amount);
  385. pData[lookupid][Score] = amount;
  386. } else return SendClientMessage(playerid, COLOR_YELLOW, "Only admin level 3+ can use this cmd");
  387. return 1;
  388. }
  389.  
  390. CMD:setdeaths(playerid, params[])
  391. {
  392.  
  393. new str[128], lookupid, amount;
  394. if(pData[playerid][Admin] >= 3)
  395. {
  396. if(sscanf(params, "ui",lookupid, amount)) return SendClientMessage(playerid ,COLOR_YELLOW, "Usage: /setdeaths <playerid/Name> <amount>");
  397. if(!IsPlayerConnected(lookupid)) return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected");
  398. format(str, sizeof(str), "Admin %s (ID:%d) has setted %s (ID:%d) Death count to (%d)", GetName(playerid), playerid, GetName(lookupid),lookupid, amount);
  399. SendClientMessage(lookupid, COLOR_YELLOW, str);
  400. pData[lookupid][Deaths] = amount;
  401. } else return SendClientMessage(playerid, COLOR_YELLOW, "Only admin level 3+ can use this cmd");
  402. return 1;
  403. }
  404.  
  405. CMD:setkills(playerid, params[])
  406. {
  407. new str[128], lookupid, amount;
  408. if(pData[playerid][Admin] >= 3)
  409. {
  410. if(sscanf(params, "ui",lookupid, amount)) return SendClientMessage(playerid ,COLOR_YELLOW, "Usage: /sekills <playerid/Name> <amount>");
  411. if(!IsPlayerConnected(lookupid)) return SendClientMessage(playerid, COLOR_YELLOW, "Player is not connected");
  412. format(str, sizeof(str), "Admin %s (ID:%d) has setted %s (ID:%d) Kill count to (%d)", GetName(playerid), playerid, GetName(lookupid),lookupid, amount);
  413. SendClientMessage(lookupid, COLOR_YELLOW, str);
  414. pData[lookupid][Kills] = amount;
  415. } else return SendClientMessage(playerid, COLOR_YELLOW, "Only admin level 3+ can use this cmd");
  416. return 1;
  417. }
  418.  
  419. CMD:blockcommand(playerid, params[])
  420. {
  421. if(!IsPlayerAdmin(playerid)) return 0;
  422. new command[25];
  423. if(sscanf(params, "s[25]", command)) return SendClientMessage(playerid, -1, "USAGE: /blockcommand [command]");
  424. if(command[0] == '/') strdel(command, 0, 1);
  425. new slotfree = -1;
  426. for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
  427. {
  428. if(BlockedCommand[i][0] == '\0') slotfree = i;
  429. else if(!strcmp(BlockedCommand[i], command, true)) return SendClientMessage(playerid, -1, "This command is already blocked. Use '/unblockcommand [command]' to unblock it.");
  430. if(slotfree != -1) continue;
  431. }
  432. if(slotfree == -1) return SendClientMessage(playerid, -1, "You have reached the maximum limit of blocked commands. Please unblock some before proceeding.");
  433. format(BlockedCommand[slotfree], 25, "%s", command);
  434. SendClientMessage(playerid, -1, "SUCCESS: Command Blocked successfully.");
  435. return 1;
  436. }
  437. CMD:blockcmd(playerid, params[]) return cmd_blockcommand(playerid, params);
  438.  
  439. CMD:unblockcommand(playerid, params[])
  440. {
  441. if(!IsPlayerAdmin(playerid)) return 0;
  442. new command[25];
  443. if(sscanf(params, "s[25]", command)) return SendClientMessage(playerid, -1, "USAGE: /unblockcommand [command]");
  444. if(command[0] == '/') strdel(command, 0, 1);
  445. new slotfree = -1;
  446. for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
  447. {
  448. if(!strcmp(BlockedCommand[i], command, true) && BlockedCommand[i][0] != '\0')
  449. {
  450. slotfree = i;
  451. break;
  452. }
  453. }
  454. if(slotfree == -1) return SendClientMessage(playerid, -1, "This command is not blocked. Use '/blockcommand [command]' to block it.");
  455. strdel(BlockedCommand[slotfree], 0, strlen(BlockedCommand[slotfree]));
  456. SendClientMessage(playerid, -1, "SUCCESS: Command Unblocked successfully.");
  457. return 1;
  458. }
  459. CMD:unblockcmd(playerid, params[]) return cmd_unblockcommand(playerid, params);
  460.  
  461. public OnPlayerCommandPerformed(playerid, cmdtext[], success)
  462. {
  463. new bool:CMD_BLOCKED = false;
  464. for(new i = 0; i < MAX_COMMAND_BLOCKED; i++)
  465. {
  466. if(BlockedCommand[i][0] == '\0') continue;
  467. if(cmdtext[0] == '/')
  468. {
  469. if(!strcmp(BlockedCommand[i], cmdtext[1], true)) CMD_BLOCKED = true;
  470. }
  471. else if(!strcmp(BlockedCommand[i], cmdtext, true)) CMD_BLOCKED = true;
  472. else continue;
  473. }
  474. if(CMD_BLOCKED) return SendClientMessage(playerid, COMMAND_BLOCKED_COLOR, COMMAND_BLOCKED_MSG);
  475. return success;
  476. }
  477.  
  478. stock GetName(playerid)
  479. {
  480. new PlayerName[MAX_PLAYER_NAME];
  481. GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  482. return PlayerName;
  483. }
  484.  
  485. stock SetPlayerMoney(playerid, money)
  486. {
  487. ResetPlayerMoney(playerid);
  488. GivePlayerMoney(playerid, money);
  489. return 1;
  490. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement