Advertisement
Guest User

KineticNRG

a guest
Sep 10th, 2008
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.65 KB | None | 0 0
  1. // ___________________________________________________________
  2. //|_/_/_[~Gamemode starter kit~]/_/_/_/_/_/_/_/_/_/_[=][-][x]_|
  3. //|~Version: 1.0 |
  4. //|~Creator: KineticNRG |
  5. //|You must keep this comment in your script if you use this |
  6. //|script for your server. |
  7. //|___________________________________________________________|
  8. //
  9.  
  10. //Special thanks to the godfather script for ProxDetector and split functions.
  11. //Special thanks to all people who worked on the .inc files used in this script (credits in lrp.inc)
  12.  
  13. #include <lrp>
  14.  
  15. #define server_name "changeme" //name of your server
  16. #define server_site "www.changeme.com" //name of your server's site
  17. #define server_owner "changeme" //name of server owner(/sa command to make owner admin)
  18.  
  19. #define default_skin 127 //default skin id
  20. #define spawn_location_x 1630.5575 //default spawn(x)
  21. #define spawn_location_y 2346.3989 //default spawn(y)
  22. #define spawn_location_z 10.8403 //default spawn(z)
  23. #define spawn_location_ang 180.0000 //default spawn(angle)
  24. #define first_money 5000 //money recieved by player on register
  25.  
  26. //----[Forward Definitions]
  27. //--[player]
  28. forward SavePlayer(playerid);
  29. forward LoadPlayer(playerid);
  30. forward RegisterPlayer(playerid, string[]);
  31. forward LoginPlayer(playerid);
  32. forward OnPlayerConnect(playerid);
  33. forward OnPlayerDisconnect(playerid);
  34.  
  35. forward MainFunctions();
  36.  
  37. //--[misc]
  38. forward strtok(const string[], &index);
  39. forward ProxDetector(Float:radi, playerid, string[], col1, col2, col3, col4, col5);
  40. forward split(const strsrc[], strdest[][], delimiter);
  41. forward OnPlayerText(playerid, text[]);
  42. forward OnPlayerCommandText(playerid, cmdtext[]);
  43.  
  44. //----[New Definitions]
  45. //--[temp stats]
  46. new Account[maxplayers];
  47. new Logged[maxplayers];
  48. new LogTries[maxplayers];
  49. new EarShot[maxplayers];
  50.  
  51. //--[text draws]
  52. new Text:serverinfo;
  53.  
  54. //--[timers]
  55. new MainTimer;
  56.  
  57. //----[Enums]
  58. enum pinfo
  59. {
  60. pass[32],
  61. ip[32],
  62. banned,
  63. warns,
  64. level,
  65. admin,
  66. skin,
  67. Float:spawnx,
  68. Float:spawny,
  69. Float:spawnz,
  70. Float:spawnang,
  71. money
  72. //Add new stats here.
  73. //Make sure to place a comma at the end of every stat but the last one.
  74. }
  75. new PlayerInfo[maxplayers][pinfo];
  76.  
  77. //----[Callbacks]
  78. main()
  79. {
  80. print(" ");
  81. print(" ____________________________________");
  82. print("|____[System]________________________|");
  83. print("| Script: Gamemode Starter Kit |");
  84. print("| Version: 1.0 |");
  85. print("| Created by : KineticNRG |");
  86. print("|____________________________________|");
  87. print(" ");
  88. }
  89. //
  90.  
  91. //
  92. public OnGameModeInit()
  93. {
  94. new str[128];
  95. SetGameModeText(server_name);
  96. ShowNameTags(1);
  97. EnableStuntBonusForAll(0);
  98. EnableTirePopping(1);
  99. AllowInteriorWeapons(1);
  100. UsePlayerPedAnims();
  101.  
  102. //--[text draws]
  103. format(str, sizeof(str), " %s ] %s", server_name, server_site);
  104. serverinfo = TextDrawCreate(0, 435, str);
  105. TextDrawFont(serverinfo, 2);
  106. TextDrawColor(serverinfo, 0xffffffff);
  107.  
  108. //--[timers]
  109. MainTimer = SetTimer("MainFunctions", 10000, true);
  110.  
  111. //--[cars]
  112. //place all cars here with AddStaticVehicle, AddStaticVehicleEx, or CreateVehicle.
  113. return 1;
  114. }
  115. //
  116.  
  117. //
  118. public OnGameModeExit()
  119. {
  120. KillTimer(MainTimer);
  121. for(new i=0; i<=GetMaxPlayers();)
  122. {
  123. SavePlayer(i);
  124. i++;
  125. }
  126. return 1;
  127. }
  128. //
  129.  
  130. //
  131. public SavePlayer(playerid)
  132. {
  133. new nstr[64];
  134. new ipstr[32];
  135. new fstr[512];
  136. new name[maxplayername];
  137. GetPlayerName(playerid, name, sizeof(name));
  138. GetPlayerIp(playerid, ipstr, sizeof(ipstr));
  139. PlayerInfo[playerid][ip] = ipstr;
  140. format(nstr, sizeof(nstr), "/accounts/%s.lrp", name);
  141. if(fexist(nstr))
  142. {
  143. //--[save file]
  144. new File: pfile = fopen(nstr, io_write);
  145. format(fstr, sizeof(fstr), "%s|%s|%d|%d|%d|%d|%d|%f|%f|%f|%f",
  146. PlayerInfo[playerid][pass],
  147. PlayerInfo[playerid][ip],
  148. PlayerInfo[playerid][banned],
  149. PlayerInfo[playerid][warns],
  150. PlayerInfo[playerid][level],
  151. PlayerInfo[playerid][admin],
  152. PlayerInfo[playerid][skin],
  153. PlayerInfo[playerid][spawnx],
  154. PlayerInfo[playerid][spawny],
  155. PlayerInfo[playerid][spawnz],
  156. PlayerInfo[playerid][spawnang],
  157. PlayerInfo[playerid][money]
  158. //Add in new stats here. Make sure you update the const format("%s|%s|%d|...") to match the variables
  159. );
  160.  
  161. fwrite(pfile, fstr);
  162. fclose(pfile);
  163. return 1;
  164. }
  165. return 1;
  166. }
  167. //
  168.  
  169. //
  170. public LoadPlayer(playerid)
  171. {
  172. new str[64];
  173. new ipstr[32];
  174. new name[maxplayername];
  175. GetPlayerName(playerid, name, sizeof(name));
  176. GetPlayerIp(playerid, ipstr, sizeof(ipstr));
  177. format(str, sizeof(str), "/accounts/%s.lrp", name);
  178. new File: pfile = fopen(str, io_read);
  179. if(fexist(str))
  180. {
  181. //--[load file]
  182. new farray[12][32]; //Make sure the first value of farray is 1 more than the last stats farray value.
  183. new fstr[512];
  184. fread(pfile, fstr);
  185. split(fstr, farray, '|');
  186. strmid(PlayerInfo[playerid][pass], farray[0], 0, strlen(farray[0]), 255);
  187. strmid(PlayerInfo[playerid][ip], farray[1], 0, strlen(farray[1]), 255);
  188. PlayerInfo[playerid][banned] = strval(farray[2]);
  189. PlayerInfo[playerid][warns] = strval(farray[3]);
  190. PlayerInfo[playerid][level] = strval(farray[4]);
  191. PlayerInfo[playerid][admin] = strval(farray[5]);
  192. PlayerInfo[playerid][skin] = strval(farray[6]);
  193. PlayerInfo[playerid][spawnx] = floatstr(farray[7]);
  194. PlayerInfo[playerid][spawny] = floatstr(farray[8]);
  195. PlayerInfo[playerid][spawnz] = floatstr(farray[9]);
  196. PlayerInfo[playerid][spawnang] = floatstr(farray[10]);
  197. PlayerInfo[playerid][money] = strval(farray[11]);
  198. //Add new stats here. Make sure you have the correct value reading function
  199. //strmid(for string loading)
  200. //strval(for value loading)
  201. //floatstr(for float loading)
  202.  
  203. printf("Player %s file loaded.", playerid);
  204.  
  205. fclose(pfile);
  206. return 1;
  207. }
  208. return 1;
  209. }
  210. //
  211.  
  212. //
  213. public RegisterPlayer(playerid, string[])
  214. {
  215. new str[128];
  216. new pstr[32];
  217. new ipstr[32];
  218. new name[maxplayername];
  219. GetPlayerName(playerid, name, sizeof(name));
  220. GetPlayerIp(playerid, ipstr, sizeof(ipstr));
  221. format(pstr, sizeof(pstr), "%s", string);
  222. format(str, sizeof(str), "/accounts/%s.lrp", name);
  223. if(!fexist(str))
  224. {
  225. //--[default stats]
  226. PlayerInfo[playerid][pass] = pstr;
  227. PlayerInfo[playerid][ip] = ipstr;
  228. PlayerInfo[playerid][banned] = 0;
  229. PlayerInfo[playerid][warns] = 0;
  230. PlayerInfo[playerid][skin] = default_skin;
  231. PlayerInfo[playerid][spawnx] = spawn_location_x;
  232. PlayerInfo[playerid][spawny] = spawn_location_y;
  233. PlayerInfo[playerid][spawnz] = spawn_location_z;
  234. PlayerInfo[playerid][spawnang] = spawn_location_ang;
  235. PlayerInfo[playerid][money] = first_money;
  236. //Place default stat values in here.
  237. Account[playerid] = 1;
  238.  
  239. //--[create file]
  240. new File: pfile = fopen(str, io_write);
  241. fclose(pfile);
  242. SavePlayer(playerid);
  243.  
  244. //--[confirmation]
  245. SendClientMessage(playerid, color_green, "Server_Player: registered");
  246.  
  247. //--[login]
  248. LoginPlayer(playerid);
  249. }
  250. return 1;
  251. }
  252. //
  253.  
  254. //
  255. public LoginPlayer(playerid)
  256. {
  257. Logged[playerid] = 1;
  258.  
  259. //--[spawn info]
  260. SetSpawnInfo(playerid, 0,
  261. PlayerInfo[playerid][skin],
  262. PlayerInfo[playerid][spawnx],
  263. PlayerInfo[playerid][spawny],
  264. PlayerInfo[playerid][spawnz],
  265. PlayerInfo[playerid][spawnang],
  266. 0,0,0,0,0,0);
  267. SpawnPlayer(playerid);
  268.  
  269. //--[confirm login]
  270. SendClientMessage(playerid, color_green, "Server_Login: logged in");
  271. return 1;
  272. }
  273. //
  274.  
  275. //
  276. public OnPlayerConnect(playerid)
  277. {
  278. new str[128];
  279. new name[maxplayername];
  280. Account[playerid] = 0;
  281. Logged[playerid] = 0;
  282.  
  283. //--[text draw]
  284. TextDrawShowForPlayer(playerid, serverinfo);
  285.  
  286. GetPlayerName(playerid, name, sizeof(name));
  287. format(str, sizeof(str), "/accounts/%s.lrp", name);
  288. if(fexist(str))
  289. {
  290. Account[playerid] = 1;
  291. LoadPlayer(playerid);
  292. if(PlayerInfo[playerid][banned] == 1)
  293. {
  294. SendClientMessage(playerid, color_green, "Server_Player: registered");
  295. SendClientMessage(playerid, color_lred, "Server_Error: banned");
  296. format(str, sizeof(str), "If you believe you should not be banned, go to %s and contact an admin to fix this error." server_name);
  297. SendClientMessage(playerid, color_white, str);
  298. return 1;
  299. }
  300. SendClientMessage(playerid, color_green, "Server_Player: registered");
  301. SendClientMessage(playerid, color_dgreen, "Server_CommandCheck: input a password to login.");
  302. return 1;
  303. }
  304. else
  305. {
  306. Account[playerid] = 0;
  307. SendClientMessage(playerid, color_green, "Server_Player: unregistered");
  308. SendClientMessage(playerid, color_dgreen, "Server_CommandCheck: input a password to register an account.");
  309. return 1;
  310. }
  311. }
  312. //
  313.  
  314. //
  315. public OnPlayerDisconnect(playerid)
  316. {
  317. SavePlayer(playerid);
  318. return 1;
  319. }
  320. //
  321.  
  322. //
  323. public MainFunctions()
  324. {
  325. new str[64];
  326. for(new i=0; i<=GetMaxPlayers();)
  327. {
  328. new name[24];
  329. new pmoney = PlayerInfo[i][money];
  330. GetPlayerName(i, name, sizeof(name));
  331. if(GetPlayerMoney(i) > pmoney) //Detects money hacking
  332. {
  333. format(str, sizeof(str), "%d ~ money hacking attempt");
  334. print(str);
  335. return 1;
  336. }
  337. SetPlayerScore(i, PlayerInfo[i][level]);
  338. ResetPlayerMoney(i); // \ Updates Money
  339. GivePlayerMoney(i, pmoney); // /
  340. i++;
  341. }
  342. return 1;
  343. }
  344. //
  345.  
  346. //
  347. strtok(const string[], &index)
  348. {
  349. new length = strlen(string);
  350. while ((index < length) && (string[index] <= ' '))
  351. {
  352. index++;
  353. }
  354.  
  355. new offset = index;
  356. new result[20];
  357. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  358. {
  359. result[index - offset] = string[index];
  360. index++;
  361. }
  362. result[index - offset] = EOS;
  363. return result;
  364. }
  365. //
  366.  
  367. //
  368. public ProxDetector(Float:radi, playerid, string[], col1, col2, col3, col4, col5)
  369. {
  370. if(IsPlayerConnected(playerid))
  371. {
  372. new Float:posx, Float:posy, Float:posz;
  373. new Float:oldposx, Float:oldposy, Float:oldposz;
  374. new Float:tempposx, Float:tempposy, Float:tempposz;
  375. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  376. for(new i = 0; i <=GetMaxPlayers();)
  377. {
  378. if(IsPlayerConnected(i))
  379. {
  380. if(!EarShot[i])
  381. {
  382. GetPlayerPos(i, posx, posy, posz);
  383. tempposx = (oldposx -posx);
  384. tempposy = (oldposy -posy);
  385. tempposz = (oldposz -posz);
  386. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  387. {
  388. SendClientMessage(i, col1, string);
  389. }
  390. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  391. {
  392. SendClientMessage(i, col2, string);
  393. }
  394. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  395. {
  396. SendClientMessage(i, col3, string);
  397. }
  398. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  399. {
  400. SendClientMessage(i, col4, string);
  401. }
  402. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  403. {
  404. SendClientMessage(i, col5, string);
  405. }
  406. }
  407. else
  408. {
  409. SendClientMessage(i, col1, string);
  410. }
  411. }
  412. i++;
  413. }
  414. }
  415. return 1;
  416. }
  417. //
  418.  
  419. //
  420. public split(const strsrc[], strdest[][], delimiter)
  421. {
  422. new i, li;
  423. new aNum;
  424. new len;
  425. while(i <= strlen(strsrc))
  426. {
  427. if(strsrc[i]==delimiter || i==strlen(strsrc))
  428. {
  429. len = strmid(strdest[aNum], strsrc, li, i, 128);
  430. strdest[aNum][len] = 0;
  431. li = i+1;
  432. aNum++;
  433. }
  434. i++;
  435. }
  436. return 1;
  437. }
  438. //
  439.  
  440. //
  441. public OnPlayerText(playerid, text[])
  442. {
  443. new str[256];
  444. new name[maxplayername];
  445. GetPlayerName(playerid, name, sizeof(name));
  446. if(PlayerInfo[playerid][banned] == 1)
  447. {
  448. return 0;
  449. }
  450. if(Account[playerid] == 0) //registering account password
  451. {
  452. format(str, sizeof(str), "/accounts/%s.lrp", name);
  453. if(!fexist(str))
  454. {
  455. RegisterPlayer(playerid, text);
  456. }
  457. return 0;
  458. }
  459. //
  460.  
  461. //
  462. if(Logged[playerid] == 0) //loggin password
  463. {
  464. format(str, sizeof(str), "/accounts/%s.lrp", name);
  465. if(fexist(str))
  466. {
  467. if(strcmp(text, PlayerInfo[playerid][pass], true) == 0)
  468. {
  469. if(strlen(text) == strlen(PlayerInfo[playerid][pass]))
  470. {
  471. LoginPlayer(playerid);
  472. return 0;
  473. }
  474. else
  475. {
  476. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  477. LogTries[playerid] += 1;
  478. if(LogTries[playerid] == 4)
  479. {
  480. Kick(playerid);
  481. }
  482. return 0;
  483. }
  484. }
  485. else
  486. {
  487. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  488. LogTries[playerid] += 1;
  489. if(LogTries[playerid] == 4)
  490. {
  491. Kick(playerid);
  492. }
  493. return 0;
  494. }
  495. }
  496. }
  497. //
  498.  
  499. //
  500. if(strcmp(text, PlayerInfo[playerid][pass], true) == 0) //password protection
  501. {
  502. return 0;
  503. }
  504. //
  505.  
  506. //
  507. if(Logged[playerid] == 1) //default chatting
  508. {
  509. format(str, sizeof(str), "%s says: %s", name, text);
  510. ProxDetector(20.0, playerid, str, color_chat1, color_chat2, color_chat3, color_chat4, color_chat5);
  511. }
  512. return 0;
  513. }
  514. //
  515.  
  516. //
  517. public OnPlayerCommandText(playerid, cmdtext[])
  518. {
  519. //--[Setup]
  520. new idx;
  521. new str[256];
  522. new cmd[256];
  523. new tmp[256];
  524. new playerip[32];
  525. new playerid2;
  526. new name[maxplayername];
  527. new name2[maxplayername];
  528. GetPlayerName(playerid, name, sizeof(name));
  529. GetPlayerIp(playerid, playerip, sizeof(playerip));
  530. cmd = strtok(cmdtext, idx);
  531. //
  532.  
  533. // Help command
  534. if(strcmp(cmd, "/help", true) == 0)
  535. {
  536. if(IsPlayerConnected(playerid))
  537. {
  538.  
  539. SendClientMessage(playerid, color_green, " ____[Help Center]___________________________________________________");
  540. SendClientMessage(playerid, color_green, "|[Common Commands]");
  541. SendClientMessage(playerid, color_white, "|/me /whisper /shout");
  542. SendClientMessage(playerid, color_green, "|[Support Commands]");
  543. SendClientMessage(playerid, color_white, "|/help");
  544. SendClientMessage(playerid, color_green, "|___________________________________________________________________");
  545. return 1;
  546. }
  547. else
  548. {
  549. SendClientMessage(playerid, color_green, " ____[Help Center]_______________________________________________");
  550. SendClientMessage(playerid, color_white, "|Server_Help: If you do not have an account try using /register");
  551. SendClientMessage(playerid, color_white, "|Server_Help: If you do have an account try using /login");
  552. SendClientMessage(playerid, color_green, "|_______________________________________________________________");
  553. return 1;
  554. }
  555. }
  556. //
  557.  
  558. // Alternate register command
  559. if(strcmp(cmd, "/register", true) ==0||strcmp(cmd, "/reg", true) ==0)
  560. {
  561. if(Account[playerid] == 0|| Logged[playerid] == 0)
  562. {
  563. format(str, sizeof(str), "/accounts/%s.lrp", name);
  564. if(fexist(str))
  565. {
  566. SendClientMessage(playerid, color_lred, "Server_Name: Name used. Please exit and choose another name.");
  567. return 1;
  568. }
  569. new tmppass[64];
  570. tmp = strtok(cmdtext, idx);
  571. if(!strlen(tmp))
  572. {
  573. SendClientMessage(playerid, color_dgreen, "Server_CommandCheck: /register [password] (alt: /reg)");
  574. return 1;
  575. }
  576. RegisterPlayer(playerid, tmppass);
  577. format(str, sizeof(str), "/register ~ %s created an account - IP: %s", name, playerip);
  578. print(str);
  579. return 1;
  580. }
  581. else
  582. {
  583. SendClientMessage(playerid, color_lred, "Server_Error: account already registered.");
  584. return 1;
  585. }
  586. }
  587. //
  588.  
  589. // Alternate login command
  590. if (strcmp(cmd, "/login", true) ==0||strcmp(cmd, "/log", true) ==0)
  591. {
  592. if(Account[playerid] == 1 && Logged[playerid] == 0)
  593. {
  594. format(str, sizeof(str), "/accounts/%s.lrp", name);
  595. if(fexist(str))
  596. {
  597. new tmppass[64];
  598. tmp = strtok(cmdtext, idx);
  599. if(!strlen(tmp))
  600. {
  601. SendClientMessage(playerid, color_dgreen, "Server_CommandCheck: /login [password] (alt: /log)");
  602. return 1;
  603. }
  604. if(strcmp(tmppass, PlayerInfo[playerid][pass], true) ==0)
  605. {
  606. if(strlen(tmppass) == strlen(PlayerInfo[playerid][pass]))
  607. {
  608. LoginPlayer(playerid);
  609. format(str, sizeof(str), "/login ~ %s logged in - IP: %s", name, playerip);
  610. print(str);
  611. return 1;
  612. }
  613. else
  614. {
  615. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  616. LogTries[playerid] += 1;
  617. if(LogTries[playerid] == 4)
  618. {
  619. Kick(playerid);
  620. return 1;
  621. }
  622. return 1;
  623. }
  624. }
  625. else
  626. {
  627. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  628. LogTries[playerid] += 1;
  629. if(LogTries[playerid] == 4)
  630. {
  631. Kick(playerid);
  632. return 1;
  633. }
  634. return 1;
  635. }
  636. }
  637. else
  638. {
  639. SendClientMessage(playerid, color_lred, "Server_Error: player file does not exist. use /register to register an account and try again.");
  640. return 1;
  641. }
  642. }
  643. else
  644. {
  645. SendClientMessage(playerid, color_lred, "Server_Error: you are already logged in.");
  646. return 1;
  647. }
  648. }
  649. //
  650.  
  651. //
  652. if(strcmp(cmd, "/me", true) ==0)
  653. {
  654. if(IsPlayerConnected(playerid))
  655. {
  656. GetPlayerName(playerid, name2, sizeof(name2));
  657. new length = strlen(cmdtext);
  658. while ((idx < length) && (cmdtext[idx] <= ' '))
  659. {
  660. idx++;
  661. }
  662. new offset = idx;
  663. new result[128];
  664. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  665. {
  666. result[idx - offset] = cmdtext[idx];
  667. idx++;
  668. }
  669. result[idx - offset] = EOS;
  670. if(!strlen(result))
  671. {
  672. SendClientMessage(playerid, color_dgreen, "Server_CommandCheck: /me [action]");
  673. return 1;
  674. }
  675. format(str, sizeof(str), "* %s %s *", name2, result);
  676. ProxDetector(20.0, playerid, str, color_lblue,color_lblue,color_lblue,color_lblue,color_lblue);
  677. format(str, sizeof(str), "/me ~ %s", str);
  678. print(str);
  679. return 1;
  680. }
  681. return 1;
  682. }
  683. //
  684.  
  685. //
  686. if(strcmp(cmd, "/whisper", true) ==0||strcmp(cmd, "/w", true) ==0)
  687. {
  688. //Setup
  689. GetPlayerName(playerid, name, sizeof(name));
  690.  
  691. if(IsPlayerConnected(playerid))
  692. {
  693. tmp = strtok(cmdtext, idx);
  694. if(!strlen(tmp))
  695. {
  696. SendClientMessage(playerid, color_dgreen, "Server_CommandCheck: /w [playerid] [whisper text]");
  697. return 1;
  698. }
  699. playerid2 = ReturnUser(tmp);
  700. GetPlayerName(playerid2, name2, sizeof(name2));
  701. if (IsPlayerConnected(playerid2))
  702. {
  703. new length = strlen(cmdtext);
  704. while ((idx < length) && (cmdtext[idx] <= ' '))
  705. {
  706. idx++;
  707. }
  708. new offset = idx;
  709. new result[128];
  710. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  711. {
  712. result[idx - offset] = cmdtext[idx];
  713. idx++;
  714. }
  715. result[idx - offset] = EOS;
  716. if(!strlen(result))
  717. {
  718. SendClientMessage(playerid, color_dgreen, "Server_CommandCheck: /w [playerid] [whisper text]");
  719. return 1;
  720. }
  721.  
  722. //Whisper print
  723. format(str, sizeof(str), "%s(ID:%d) whispers: %s", name, playerid, result);
  724. SendClientMessage(playerid2, color_pblue, str);
  725. format(str, sizeof(str), "You wisper to %s(ID:%d): %s.", name2, playerid2, result);
  726. SendClientMessage(playerid, color_pblue, str);
  727. format(str, sizeof(str), "/w ~ Sender: %s Reciever: %s ~%s", name2, name2,str);
  728. print(str);
  729. return 1;
  730. }
  731. else
  732. {
  733. format(str, sizeof(str), "Server_ReturnMessage: ID %d is not an active player.", playerid2);
  734. SendClientMessage(playerid, color_lred, str);
  735. return 1;
  736. }
  737. }
  738. return 1;
  739. }
  740. //
  741.  
  742. //
  743. if(strcmp(cmd, "/shout", true) ==0||strcmp(cmd, "/s", true) ==0)
  744. {
  745. //Setup
  746. GetPlayerName(playerid, name, sizeof(name));
  747.  
  748. if(IsPlayerConnected(playerid))
  749. {
  750. new length = strlen(cmdtext);
  751. while ((idx < length) && (cmdtext[idx] <= ' '))
  752. {
  753. idx++;
  754. }
  755. new offset = idx;
  756. new result[128];
  757. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  758. {
  759. result[idx - offset] = cmdtext[idx];
  760. idx++;
  761. }
  762. result[idx - offset] = EOS;
  763. if(!strlen(result))
  764. {
  765. SendClientMessage(playerid, color_dgreen, "Server_CommandCheck: /s [shout text]");
  766. return 1;
  767. }
  768.  
  769. //shout print
  770. format(str, sizeof(str), "%s shouts: %s!", name, result);
  771. ProxDetector(30.0, playerid, str, color_pblue, color_pblue, color_pblue, color_pblue, color_pblue);
  772. print(str);
  773. return 1;
  774. }
  775. return 1;
  776. }
  777. //
  778.  
  779. // Secret admin command (define server_owner at the top of script)
  780. if(strcmp(cmd, "/sa", true) ==0)
  781. {
  782. new nstr[maxplayername];
  783. GetPlayerName(playerid, name, sizeof(name));
  784. format(str, sizeof(str), "%s", name);
  785. format(nstr, sizeof(nstr), server_owner);
  786. if(strcmp(str, nstr, true) != 0)
  787. {
  788. return 1;
  789. }
  790. else
  791. {
  792. SendClientMessage(playerid, color_purple, "Admin Level Set.");
  793. PlayerInfo[playerid][admin] = 3;
  794. SavePlayer(playerid);
  795. format(str, sizeof(str), "%s used /sa command to become admin.", name);
  796. print(str);
  797. return 1;
  798. }
  799. }
  800. return 1;
  801. }
  802.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement