Guest User

Untitled

a guest
Dec 23rd, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.09 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. #include <zcmd>
  15.  
  16. #define server_name "changeme" //name of your server
  17. #define server_site "www.changeme.com" //name of your server's site
  18. #define server_owner "Lewis" //name of server owner(/sa command to make owner admin)
  19.  
  20. #define MAX_HOUSES 100 //Lets define that we can have the max limit of our houses to 100.
  21.  
  22. #define default_skin 127 //default skin id
  23. #define spawn_location_x 1630.5575 //default spawn(x)
  24. #define spawn_location_y 2346.3989 //default spawn(y)
  25. #define spawn_location_z 10.8403 //default spawn(z)
  26. #define spawn_location_ang 180.0000 //default spawn(angle)
  27. #define first_money 5000 //money recieved by player on register
  28.  
  29. //----[Forward Definitions]
  30. //--[player]
  31. forward SavePlayer(playerid);
  32. forward LoadPlayer(playerid);
  33. forward RegisterPlayer(playerid, string[]);
  34. forward LoginPlayer(playerid);
  35. forward OnPlayerConnect(playerid);
  36. forward OnPlayerDisconnect(playerid);
  37.  
  38. forward MainFunctions();
  39.  
  40. //--[misc]
  41. forward strtok(const string[], &index);
  42. forward ProxDetector(Float:radi, playerid, string[], col1, col2, col3, col4, col5);
  43. forward split(const strsrc[], strdest[][], delimiter);
  44. forward OnPlayerText(playerid, text[]);
  45. forward OnPlayerCommandText(playerid, cmdtext[]);
  46.  
  47.  
  48. //New for HOUSES
  49. new HouseCount;//To check how many houses have we created.
  50. new HouseEnter[MAX_HOUSES];//This will be where we will store the house entrance checkpoint
  51. new HouseExit[MAX_HOUSES];//This will be where we will store the house exit checkpoint.
  52. new PlayerInHouseID[MAX_PLAYERS];//To check what house id is the player in.
  53.  
  54.  
  55.  
  56.  
  57. //----[New Definitions]
  58. //--[temp stats]
  59. new Account[maxplayers];
  60. new Logged[maxplayers];
  61. new LogTries[maxplayers];
  62. new EarShot[maxplayers];
  63.  
  64. //--[text draws]
  65. new Text:serverinfo;
  66.  
  67. //--[timers]
  68. new MainTimer;
  69.  
  70. enum HouseInfo//Naming the enum
  71. {
  72. Owner[24],//This will be where it will store the house owner name, in a 24 bit size array
  73. Owned,//To store if the house is owned or not.
  74. Price,//How much the house will cost.
  75. Float:XPos,//Float X position of the checkpoint
  76. Float:YPos,//Self explanatory.
  77. Float:ZPos,//Self explanatory
  78. VirtualWorld,//The checkpoints virtual world.
  79. Text3D:HouseLabel//That label where it says "Owned Price..."
  80. }
  81. new HInfo[MAX_HOUSES][HouseInfo];//This is the var where we will read the house info.
  82.  
  83. //----[Enums]
  84. enum pinfo
  85. {
  86. pass[32],
  87. ip[32],
  88. banned,
  89. warns,
  90. level,
  91. admin,
  92. skin,
  93. Float:spawnx,
  94. Float:spawny,
  95. Float:spawnz,
  96. Float:spawnang,
  97. money
  98. //Add new stats here.
  99. //Make sure to place a comma at the end of every stat but the last one.
  100. }
  101. new PlayerInfo[maxplayers][pinfo];
  102.  
  103. //----[Callbacks]
  104. main()
  105. {
  106. print(" ");
  107. print(" ____________________________________");
  108. print("|____[System]________________________|");
  109. print("| Script: Gamemode Starter Kit |");
  110. print("| Version: 1.0 |");
  111. print("| Created by : KineticNRG:Edited by Looie09|");
  112. print("|____________________________________|");
  113. print(" ");
  114. }
  115. //
  116.  
  117. //
  118. public OnGameModeInit()
  119. {
  120. new str[128];
  121. SetGameModeText(server_name);
  122. ShowNameTags(1);
  123. EnableStuntBonusForAll(0);
  124. EnableTirePopping(1);
  125. AllowInteriorWeapons(1);
  126. UsePlayerPedAnims();
  127.  
  128. //--[text draws]
  129. format(str, sizeof(str), " %s ] %s", server_name, server_site);
  130. serverinfo = TextDrawCreate(0, 435, str);
  131. TextDrawFont(serverinfo, 2);
  132. TextDrawColor(serverinfo, 0xffffffff);
  133.  
  134. //--[timers]
  135. MainTimer = SetTimer("MainFunctions", 10000, true);
  136.  
  137. //--[cars]
  138. //place all cars here with AddStaticVehicle, AddStaticVehicleEx, or CreateVehicle.
  139. return 1;
  140. }
  141. //
  142.  
  143. //
  144. public OnGameModeExit()
  145. {
  146. KillTimer(MainTimer);
  147. for(new i=0; i<=GetMaxPlayers();)
  148. {
  149. SavePlayer(i);
  150. i++;
  151. }
  152. return 1;
  153. }
  154. //
  155.  
  156. //
  157. public SavePlayer(playerid)
  158. {
  159. new nstr[64];
  160. new ipstr[32];
  161. new fstr[512];
  162. new name[maxplayername];
  163. GetPlayerName(playerid, name, sizeof(name));
  164. GetPlayerIp(playerid, ipstr, sizeof(ipstr));
  165. PlayerInfo[playerid][ip] = ipstr;
  166. format(nstr, sizeof(nstr), "/accounts/%s.lrp", name);
  167. if(fexist(nstr))
  168. {
  169. //--[save file]
  170. new File: pfile = fopen(nstr, io_write);
  171. format(fstr, sizeof(fstr), "%s|%s|%d|%d|%d|%d|%d|%f|%f|%f|%f",
  172. PlayerInfo[playerid][pass],
  173. PlayerInfo[playerid][ip],
  174. PlayerInfo[playerid][banned],
  175. PlayerInfo[playerid][warns],
  176. PlayerInfo[playerid][level],
  177. PlayerInfo[playerid][admin],
  178. PlayerInfo[playerid][skin],
  179. PlayerInfo[playerid][spawnx],
  180. PlayerInfo[playerid][spawny],
  181. PlayerInfo[playerid][spawnz],
  182. PlayerInfo[playerid][spawnang],
  183. PlayerInfo[playerid][money]
  184. //Add in new stats here. Make sure you update the const format("%s|%s|%d|...") to match the variables
  185. );
  186.  
  187. fwrite(pfile, fstr);
  188. fclose(pfile);
  189. return 1;
  190. }
  191. return 1;
  192. }
  193. //
  194.  
  195. //
  196. public LoadPlayer(playerid)
  197. {
  198. new str[64];
  199. new ipstr[32];
  200. new name[maxplayername];
  201. GetPlayerName(playerid, name, sizeof(name));
  202. GetPlayerIp(playerid, ipstr, sizeof(ipstr));
  203. format(str, sizeof(str), "/accounts/%s.lrp", name);
  204. new File: pfile = fopen(str, io_read);
  205. if(fexist(str))
  206. {
  207. //--[load file]
  208. new farray[12][32]; //Make sure the first value of farray is 1 more than the last stats farray value.
  209. new fstr[512];
  210. fread(pfile, fstr);
  211. split(fstr, farray, '|');
  212. strmid(PlayerInfo[playerid][pass], farray[0], 0, strlen(farray[0]), 255);
  213. strmid(PlayerInfo[playerid][ip], farray[1], 0, strlen(farray[1]), 255);
  214. PlayerInfo[playerid][banned] = strval(farray[2]);
  215. PlayerInfo[playerid][warns] = strval(farray[3]);
  216. PlayerInfo[playerid][level] = strval(farray[4]);
  217. PlayerInfo[playerid][admin] = strval(farray[5]);
  218. PlayerInfo[playerid][skin] = strval(farray[6]);
  219. PlayerInfo[playerid][spawnx] = floatstr(farray[7]);
  220. PlayerInfo[playerid][spawny] = floatstr(farray[8]);
  221. PlayerInfo[playerid][spawnz] = floatstr(farray[9]);
  222. PlayerInfo[playerid][spawnang] = floatstr(farray[10]);
  223. PlayerInfo[playerid][money] = strval(farray[11]);
  224. //Add new stats here. Make sure you have the correct value reading function
  225. //strmid(for string loading)
  226. //strval(for value loading)
  227. //floatstr(for float loading)
  228.  
  229. printf("Player %s file loaded.", playerid);
  230.  
  231. fclose(pfile);
  232. return 1;
  233. }
  234. return 1;
  235. }
  236. //
  237.  
  238. //
  239. public RegisterPlayer(playerid, string[])
  240. {
  241. new str[128];
  242. new pstr[32];
  243. new ipstr[32];
  244. new name[maxplayername];
  245. GetPlayerName(playerid, name, sizeof(name));
  246. GetPlayerIp(playerid, ipstr, sizeof(ipstr));
  247. format(pstr, sizeof(pstr), "%s", string);
  248. format(str, sizeof(str), "/accounts/%s.lrp", name);
  249. if(!fexist(str))
  250. {
  251. //--[default stats]
  252. PlayerInfo[playerid][pass] = pstr;
  253. PlayerInfo[playerid][ip] = ipstr;
  254. PlayerInfo[playerid][banned] = 0;
  255. PlayerInfo[playerid][warns] = 0;
  256. PlayerInfo[playerid][skin] = default_skin;
  257. PlayerInfo[playerid][spawnx] = spawn_location_x;
  258. PlayerInfo[playerid][spawny] = spawn_location_y;
  259. PlayerInfo[playerid][spawnz] = spawn_location_z;
  260. PlayerInfo[playerid][spawnang] = spawn_location_ang;
  261. PlayerInfo[playerid][money] = first_money;
  262. //Place default stat values in here.
  263. Account[playerid] = 1;
  264.  
  265. //--[create file]
  266. new File: pfile = fopen(str, io_write);
  267. fclose(pfile);
  268. SavePlayer(playerid);
  269.  
  270. //--[confirmation]
  271. SendClientMessage(playerid, color_green, "Server_Player: registered");
  272.  
  273. //--[login]
  274. LoginPlayer(playerid);
  275. }
  276. return 1;
  277. }
  278. //
  279.  
  280. //
  281. public LoginPlayer(playerid)
  282. {
  283. Logged[playerid] = 1;
  284.  
  285. //--[spawn info]
  286. SetSpawnInfo(playerid, 0,
  287. PlayerInfo[playerid][skin],
  288. PlayerInfo[playerid][spawnx],
  289. PlayerInfo[playerid][spawny],
  290. PlayerInfo[playerid][spawnz],
  291. PlayerInfo[playerid][spawnang],
  292. 0,0,0,0,0,0);
  293. SpawnPlayer(playerid);
  294.  
  295. //--[confirm login]
  296. SendClientMessage(playerid, color_green, "Server:: You are now logged in");
  297. return 1;
  298. }
  299. //
  300.  
  301. //
  302. public OnPlayerConnect(playerid)
  303. {
  304. new str[128];
  305. new name[maxplayername];
  306. Account[playerid] = 0;
  307. Logged[playerid] = 0;
  308.  
  309. //--[text draw]
  310. TextDrawShowForPlayer(playerid, serverinfo);
  311.  
  312. GetPlayerName(playerid, name, sizeof(name));
  313. format(str, sizeof(str), "/accounts/%s.lrp", name);
  314. if(fexist(str))
  315. {
  316. Account[playerid] = 1;
  317. LoadPlayer(playerid);
  318. if(PlayerInfo[playerid][banned] == 1)
  319. {
  320. SendClientMessage(playerid, color_green, "Status: REGISTERED");
  321. SendClientMessage(playerid, color_lred, "Server: BANNED");
  322. 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);
  323. SendClientMessage(playerid, color_white, str);
  324. return 1;
  325. }
  326. SendClientMessage(playerid, color_green, "Status: REGISTERED");
  327. SendClientMessage(playerid, color_dgreen, "Server: Please input your password to login.");
  328. return 1;
  329. }
  330. else
  331. {
  332. Account[playerid] = 0;
  333. SendClientMessage(playerid, color_green, "Status: UNREGISTERED");
  334. SendClientMessage(playerid, color_dgreen, "Server: Please input a password to register an account.");
  335. return 1;
  336. }
  337. }
  338. //
  339.  
  340. //
  341. public OnPlayerDisconnect(playerid)
  342. {
  343. SavePlayer(playerid);
  344. return 1;
  345. }
  346. //
  347.  
  348. //
  349. public MainFunctions()
  350. {
  351. new str[64];
  352. for(new i=0; i<=GetMaxPlayers();)
  353. {
  354. new name[24];
  355. new pmoney = PlayerInfo[i][money];
  356. GetPlayerName(i, name, sizeof(name));
  357. if(GetPlayerMoney(i) > pmoney) //Detects money hacking
  358. {
  359. format(str, sizeof(str), "%d ~ money hacking attempt");
  360. print(str);
  361. return 1;
  362. }
  363. SetPlayerScore(i, PlayerInfo[i][level]);
  364. ResetPlayerMoney(i); // \ Updates Money
  365. GivePlayerMoney(i, pmoney); // /
  366. i++;
  367. }
  368. return 1;
  369. }
  370. //
  371.  
  372. //
  373. strtok(const string[], &index)
  374. {
  375. new length = strlen(string);
  376. while ((index < length) && (string[index] <= ' '))
  377. {
  378. index++;
  379. }
  380.  
  381. new offset = index;
  382. new result[20];
  383. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  384. {
  385. result[index - offset] = string[index];
  386. index++;
  387. }
  388. result[index - offset] = EOS;
  389. return result;
  390. }
  391. //
  392.  
  393. //
  394. public ProxDetector(Float:radi, playerid, string[], col1, col2, col3, col4, col5)
  395. {
  396. if(IsPlayerConnected(playerid))
  397. {
  398. new Float:posx, Float:posy, Float:posz;
  399. new Float:oldposx, Float:oldposy, Float:oldposz;
  400. new Float:tempposx, Float:tempposy, Float:tempposz;
  401. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  402. for(new i = 0; i <=GetMaxPlayers();)
  403. {
  404. if(IsPlayerConnected(i))
  405. {
  406. if(!EarShot[i])
  407. {
  408. GetPlayerPos(i, posx, posy, posz);
  409. tempposx = (oldposx -posx);
  410. tempposy = (oldposy -posy);
  411. tempposz = (oldposz -posz);
  412. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  413. {
  414. SendClientMessage(i, col1, string);
  415. }
  416. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  417. {
  418. SendClientMessage(i, col2, string);
  419. }
  420. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  421. {
  422. SendClientMessage(i, col3, string);
  423. }
  424. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  425. {
  426. SendClientMessage(i, col4, string);
  427. }
  428. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  429. {
  430. SendClientMessage(i, col5, string);
  431. }
  432. }
  433. else
  434. {
  435. SendClientMessage(i, col1, string);
  436. }
  437. }
  438. i++;
  439. }
  440. }
  441. return 1;
  442. }
  443. //
  444.  
  445. //
  446. public split(const strsrc[], strdest[][], delimiter)
  447. {
  448. new i, li;
  449. new aNum;
  450. new len;
  451. while(i <= strlen(strsrc))
  452. {
  453. if(strsrc[i]==delimiter || i==strlen(strsrc))
  454. {
  455. len = strmid(strdest[aNum], strsrc, li, i, 128);
  456. strdest[aNum][len] = 0;
  457. li = i+1;
  458. aNum++;
  459. }
  460. i++;
  461. }
  462. return 1;
  463. }
  464. //
  465.  
  466. //
  467. public OnPlayerText(playerid, text[])
  468. {
  469. new str[256];
  470. new name[maxplayername];
  471. GetPlayerName(playerid, name, sizeof(name));
  472. if(PlayerInfo[playerid][banned] == 1)
  473. {
  474. return 0;
  475. }
  476. if(Account[playerid] == 0) //registering account password
  477. {
  478. format(str, sizeof(str), "/accounts/%s.lrp", name);
  479. if(!fexist(str))
  480. {
  481. RegisterPlayer(playerid, text);
  482. }
  483. return 0;
  484. }
  485. //
  486.  
  487. //
  488. if(Logged[playerid] == 0) //loggin password
  489. {
  490. format(str, sizeof(str), "/accounts/%s.lrp", name);
  491. if(fexist(str))
  492. {
  493. if(strcmp(text, PlayerInfo[playerid][pass], true) == 0)
  494. {
  495. if(strlen(text) == strlen(PlayerInfo[playerid][pass]))
  496. {
  497. LoginPlayer(playerid);
  498. return 0;
  499. }
  500. else
  501. {
  502. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  503. LogTries[playerid] += 1;
  504. if(LogTries[playerid] == 4)
  505. {
  506. Kick(playerid);
  507. }
  508. return 0;
  509. }
  510. }
  511. else
  512. {
  513. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  514. LogTries[playerid] += 1;
  515. if(LogTries[playerid] == 4)
  516. {
  517. Kick(playerid);
  518. }
  519. return 0;
  520. }
  521. }
  522. }
  523. //
  524.  
  525. //
  526. if(strcmp(text, PlayerInfo[playerid][pass], true) == 0) //password protection
  527. {
  528. return 0;
  529. }
  530. //
  531.  
  532. //
  533. if(Logged[playerid] == 1) //default chatting
  534. {
  535. format(str, sizeof(str), "%s says: %s", name, text);
  536. ProxDetector(20.0, playerid, str, color_chat1, color_chat2, color_chat3, color_chat4, color_chat5);
  537. }
  538. return 0;
  539. }
  540. //
  541.  
  542. //
  543. public OnPlayerCommandText(playerid, cmdtext[])
  544. {
  545. //--[Setup]
  546. new idx;
  547. new str[256];
  548. new cmd[256];
  549. new tmp[256];
  550. new playerip[32];
  551. new playerid2;
  552. new name[maxplayername];
  553. new name2[maxplayername];
  554. GetPlayerName(playerid, name, sizeof(name));
  555. GetPlayerIp(playerid, playerip, sizeof(playerip));
  556. cmd = strtok(cmdtext, idx);
  557. //
  558.  
  559. // Help command
  560. if(strcmp(cmd, "/help", true) == 0)
  561. {
  562. if(IsPlayerConnected(playerid))
  563. {
  564.  
  565. SendClientMessage(playerid, color_green, " ____[Help Center]___________________________________________________");
  566. SendClientMessage(playerid, color_green, "|[Common Commands]");
  567. SendClientMessage(playerid, color_white, "|/me /whisper /shout");
  568. SendClientMessage(playerid, color_green, "|[Support Commands]");
  569. SendClientMessage(playerid, color_white, "|/help");
  570. SendClientMessage(playerid, color_green, "|___________________________________________________________________");
  571. return 1;
  572. }
  573. else
  574. {
  575. SendClientMessage(playerid, color_green, " ____[Help Center]_______________________________________________");
  576. SendClientMessage(playerid, color_white, "|Server_Help: If you do not have an account try using /register");
  577. SendClientMessage(playerid, color_white, "|Server_Help: If you do have an account try using /login");
  578. SendClientMessage(playerid, color_green, "|_______________________________________________________________");
  579. return 1;
  580. }
  581. }
  582. //
  583.  
  584. // Alternate register command
  585. if(strcmp(cmd, "/register", true) ==0||strcmp(cmd, "/reg", true) ==0)
  586. {
  587. if(Account[playerid] == 0|| Logged[playerid] == 0)
  588. {
  589. format(str, sizeof(str), "/accounts/%s.lrp", name);
  590. if(fexist(str))
  591. {
  592. SendClientMessage(playerid, color_lred, "Server_Name: Name used. Please exit and choose another name.");
  593. return 1;
  594. }
  595. new tmppass[64];
  596. tmp = strtok(cmdtext, idx);
  597. if(!strlen(tmp))
  598. {
  599. SendClientMessage(playerid, color_dgreen, "Server:: /register [password] (alt: /reg)");
  600. return 1;
  601. }
  602. RegisterPlayer(playerid, tmppass);
  603. format(str, sizeof(str), "/register ~ %s created an account - IP: %s", name, playerip);
  604. print(str);
  605. return 1;
  606. }
  607. else
  608. {
  609. SendClientMessage(playerid, color_lred, "Server_Error: account already registered.");
  610. return 1;
  611. }
  612. }
  613. //
  614.  
  615. // Alternate login command
  616. if (strcmp(cmd, "/login", true) ==0||strcmp(cmd, "/log", true) ==0)
  617. {
  618. if(Account[playerid] == 1 && Logged[playerid] == 0)
  619. {
  620. format(str, sizeof(str), "/accounts/%s.lrp", name);
  621. if(fexist(str))
  622. {
  623. new tmppass[64];
  624. tmp = strtok(cmdtext, idx);
  625. if(!strlen(tmp))
  626. {
  627. SendClientMessage(playerid, color_dgreen, "Server:: /login [password] (alt: /log)");
  628. return 1;
  629. }
  630. if(strcmp(tmppass, PlayerInfo[playerid][pass], true) ==0)
  631. {
  632. if(strlen(tmppass) == strlen(PlayerInfo[playerid][pass]))
  633. {
  634. LoginPlayer(playerid);
  635. format(str, sizeof(str), "/login ~ %s logged in - IP: %s", name, playerip);
  636. print(str);
  637. return 1;
  638. }
  639. else
  640. {
  641. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  642. LogTries[playerid] += 1;
  643. if(LogTries[playerid] == 4)
  644. {
  645. Kick(playerid);
  646. return 1;
  647. }
  648. return 1;
  649. }
  650. }
  651. else
  652. {
  653. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  654. LogTries[playerid] += 1;
  655. if(LogTries[playerid] == 4)
  656. {
  657. Kick(playerid);
  658. return 1;
  659. }
  660. return 1;
  661. }
  662. }
  663. else
  664. {
  665. SendClientMessage(playerid, color_lred, "Server_Error: player file does not exist. use /register to register an account and try again.");
  666. return 1;
  667. }
  668. }
  669. else
  670. {
  671. SendClientMessage(playerid, color_lred, "Server_Error: you are already logged in.");
  672. return 1;
  673. }
  674. }
  675. //
  676.  
  677. //
  678. if(strcmp(cmd, "/me", true) ==0)
  679. {
  680. if(IsPlayerConnected(playerid))
  681. {
  682. GetPlayerName(playerid, name2, sizeof(name2));
  683. new length = strlen(cmdtext);
  684. while ((idx < length) && (cmdtext[idx] <= ' '))
  685. {
  686. idx++;
  687. }
  688. new offset = idx;
  689. new result[128];
  690. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  691. {
  692. result[idx - offset] = cmdtext[idx];
  693. idx++;
  694. }
  695. result[idx - offset] = EOS;
  696. if(!strlen(result))
  697. {
  698. SendClientMessage(playerid, color_dgreen, "Server:: /me [action]");
  699. return 1;
  700. }
  701. format(str, sizeof(str), "* %s %s *", name2, result);
  702. ProxDetector(20.0, playerid, str, color_pink,color_pink,color_pink,color_pink,color_pink);
  703. format(str, sizeof(str), "/me ~ %s", str);
  704. print(str);
  705. return 1;
  706. }
  707. return 1;
  708. }
  709. //
  710.  
  711. //
  712. if(strcmp(cmd, "/whisper", true) ==0||strcmp(cmd, "/w", true) ==0)
  713. {
  714. //Setup
  715. GetPlayerName(playerid, name, sizeof(name));
  716.  
  717. if(IsPlayerConnected(playerid))
  718. {
  719. tmp = strtok(cmdtext, idx);
  720. if(!strlen(tmp))
  721. {
  722. SendClientMessage(playerid, color_dgreen, "Server:: /w [playerid] [whisper text]");
  723. return 1;
  724. }
  725. playerid2 = ReturnUser(tmp);
  726. GetPlayerName(playerid2, name2, sizeof(name2));
  727. if (IsPlayerConnected(playerid2))
  728. {
  729. new length = strlen(cmdtext);
  730. while ((idx < length) && (cmdtext[idx] <= ' '))
  731. {
  732. idx++;
  733. }
  734. new offset = idx;
  735. new result[128];
  736. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  737. {
  738. result[idx - offset] = cmdtext[idx];
  739. idx++;
  740. }
  741. result[idx - offset] = EOS;
  742. if(!strlen(result))
  743. {
  744. SendClientMessage(playerid, color_dgreen, "Server:: /w [playerid] [whisper text]");
  745. return 1;
  746. }
  747.  
  748. //Whisper print
  749. format(str, sizeof(str), "%s(ID:%d) whispers: %s", name, playerid, result);
  750. SendClientMessage(playerid2, color_pblue, str);
  751. format(str, sizeof(str), "You wisper to %s(ID:%d): %s.", name2, playerid2, result);
  752. SendClientMessage(playerid, color_pblue, str);
  753. format(str, sizeof(str), "/w ~ Sender: %s Reciever: %s ~%s", name2, name2,str);
  754. print(str);
  755. return 1;
  756. }
  757. else
  758. {
  759. format(str, sizeof(str), "Server_ReturnMessage: ID %d is not an active player.", playerid2);
  760. SendClientMessage(playerid, color_lred, str);
  761. return 1;
  762. }
  763. }
  764. return 1;
  765. }
  766. //
  767.  
  768. //
  769. if(strcmp(cmd, "/shout", true) ==0||strcmp(cmd, "/s", true) ==0)
  770. {
  771. //Setup
  772. GetPlayerName(playerid, name, sizeof(name));
  773.  
  774. if(IsPlayerConnected(playerid))
  775. {
  776. new length = strlen(cmdtext);
  777. while ((idx < length) && (cmdtext[idx] <= ' '))
  778. {
  779. idx++;
  780. }
  781. new offset = idx;
  782. new result[128];
  783. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  784. {
  785. result[idx - offset] = cmdtext[idx];
  786. idx++;
  787. }
  788. result[idx - offset] = EOS;
  789. if(!strlen(result))
  790. {
  791. SendClientMessage(playerid, color_dgreen, "Server:: /s [shout text]");
  792. return 1;
  793. }
  794.  
  795. //shout print
  796. format(str, sizeof(str), "%s shouts: %s!", name, result);
  797. ProxDetector(30.0, playerid, str, color_pblue, color_pblue, color_pblue, color_pblue, color_pblue);
  798. print(str);
  799. return 1;
  800. }
  801. return 1;
  802. }
  803. //
  804.  
  805. // Secret admin command (define server_owner at the top of script)
  806. if(strcmp(cmd, "/sa", true) ==0)
  807. {
  808. new nstr[maxplayername];
  809. GetPlayerName(playerid, name, sizeof(name));
  810. format(str, sizeof(str), "%s", name);
  811. format(nstr, sizeof(nstr), server_owner);
  812. if(strcmp(str, nstr, true) != 0)
  813. {
  814. return 1;
  815. }
  816. else
  817. {
  818. SendClientMessage(playerid, color_purple, "Admin Level Set.");
  819. PlayerInfo[playerid][admin] = 3;
  820. SavePlayer(playerid);
  821. format(str, sizeof(str), "%s used /sa command to become admin.", name);
  822. print(str);
  823. return 1;
  824. }
  825. }
  826. return 1;
  827. }
  828.  
  829. //HOUSE COMMANDS// ___________________________________________________________
  830. //|_/_/_[~Gamemode starter kit~]/_/_/_/_/_/_/_/_/_/_[=][-][x]_|
  831. //|~Version: 1.0 |
  832. //|~Creator: KineticNRG |
  833. //|You must keep this comment in your script if you use this |
  834. //|script for your server. |
  835. //|___________________________________________________________|
  836. //
  837.  
  838. //Special thanks to the godfather script for ProxDetector and split functions.
  839. //Special thanks to all people who worked on the .inc files used in this script (credits in lrp.inc)
  840.  
  841. #include <lrp>
  842. #include <zcmd>
  843.  
  844. #define server_name "changeme" //name of your server
  845. #define server_site "www.changeme.com" //name of your server's site
  846. #define server_owner "Lewis" //name of server owner(/sa command to make owner admin)
  847.  
  848. #define MAX_HOUSES 100 //Lets define that we can have the max limit of our houses to 100.
  849.  
  850. #define default_skin 127 //default skin id
  851. #define spawn_location_x 1630.5575 //default spawn(x)
  852. #define spawn_location_y 2346.3989 //default spawn(y)
  853. #define spawn_location_z 10.8403 //default spawn(z)
  854. #define spawn_location_ang 180.0000 //default spawn(angle)
  855. #define first_money 5000 //money recieved by player on register
  856.  
  857. //----[Forward Definitions]
  858. //--[player]
  859. forward SavePlayer(playerid);
  860. forward LoadPlayer(playerid);
  861. forward RegisterPlayer(playerid, string[]);
  862. forward LoginPlayer(playerid);
  863. forward OnPlayerConnect(playerid);
  864. forward OnPlayerDisconnect(playerid);
  865.  
  866. forward MainFunctions();
  867.  
  868. //--[misc]
  869. forward strtok(const string[], &index);
  870. forward ProxDetector(Float:radi, playerid, string[], col1, col2, col3, col4, col5);
  871. forward split(const strsrc[], strdest[][], delimiter);
  872. forward OnPlayerText(playerid, text[]);
  873. forward OnPlayerCommandText(playerid, cmdtext[]);
  874.  
  875.  
  876. //New for HOUSES
  877. new HouseCount;//To check how many houses have we created.
  878. new HouseEnter[MAX_HOUSES];//This will be where we will store the house entrance checkpoint
  879. new HouseExit[MAX_HOUSES];//This will be where we will store the house exit checkpoint.
  880. new PlayerInHouseID[MAX_PLAYERS];//To check what house id is the player in.
  881.  
  882.  
  883.  
  884.  
  885. //----[New Definitions]
  886. //--[temp stats]
  887. new Account[maxplayers];
  888. new Logged[maxplayers];
  889. new LogTries[maxplayers];
  890. new EarShot[maxplayers];
  891.  
  892. //--[text draws]
  893. new Text:serverinfo;
  894.  
  895. //--[timers]
  896. new MainTimer;
  897.  
  898. enum HouseInfo//Naming the enum
  899. {
  900. Owner[24],//This will be where it will store the house owner name, in a 24 bit size array
  901. Owned,//To store if the house is owned or not.
  902. Price,//How much the house will cost.
  903. Float:XPos,//Float X position of the checkpoint
  904. Float:YPos,//Self explanatory.
  905. Float:ZPos,//Self explanatory
  906. VirtualWorld,//The checkpoints virtual world.
  907. Text3D:HouseLabel//That label where it says "Owned Price..."
  908. }
  909. new HInfo[MAX_HOUSES][HouseInfo];//This is the var where we will read the house info.
  910.  
  911. //----[Enums]
  912. enum pinfo
  913. {
  914. pass[32],
  915. ip[32],
  916. banned,
  917. warns,
  918. level,
  919. admin,
  920. skin,
  921. Float:spawnx,
  922. Float:spawny,
  923. Float:spawnz,
  924. Float:spawnang,
  925. money
  926. //Add new stats here.
  927. //Make sure to place a comma at the end of every stat but the last one.
  928. }
  929. new PlayerInfo[maxplayers][pinfo];
  930.  
  931. //----[Callbacks]
  932. main()
  933. {
  934. print(" ");
  935. print(" ____________________________________");
  936. print("|____[System]________________________|");
  937. print("| Script: Gamemode Starter Kit |");
  938. print("| Version: 1.0 |");
  939. print("| Created by : KineticNRG:Edited by Looie09|");
  940. print("|____________________________________|");
  941. print(" ");
  942. }
  943. //
  944.  
  945. //
  946. public OnGameModeInit()
  947. {
  948. new str[128];
  949. SetGameModeText(server_name);
  950. ShowNameTags(1);
  951. EnableStuntBonusForAll(0);
  952. EnableTirePopping(1);
  953. AllowInteriorWeapons(1);
  954. UsePlayerPedAnims();
  955.  
  956. //--[text draws]
  957. format(str, sizeof(str), " %s ] %s", server_name, server_site);
  958. serverinfo = TextDrawCreate(0, 435, str);
  959. TextDrawFont(serverinfo, 2);
  960. TextDrawColor(serverinfo, 0xffffffff);
  961.  
  962. //--[timers]
  963. MainTimer = SetTimer("MainFunctions", 10000, true);
  964.  
  965. //--[cars]
  966. //place all cars here with AddStaticVehicle, AddStaticVehicleEx, or CreateVehicle.
  967. return 1;
  968. }
  969. //
  970.  
  971. //
  972. public OnGameModeExit()
  973. {
  974. KillTimer(MainTimer);
  975. for(new i=0; i<=GetMaxPlayers();)
  976. {
  977. SavePlayer(i);
  978. i++;
  979. }
  980. return 1;
  981. }
  982. //
  983.  
  984. //
  985. public SavePlayer(playerid)
  986. {
  987. new nstr[64];
  988. new ipstr[32];
  989. new fstr[512];
  990. new name[maxplayername];
  991. GetPlayerName(playerid, name, sizeof(name));
  992. GetPlayerIp(playerid, ipstr, sizeof(ipstr));
  993. PlayerInfo[playerid][ip] = ipstr;
  994. format(nstr, sizeof(nstr), "/accounts/%s.lrp", name);
  995. if(fexist(nstr))
  996. {
  997. //--[save file]
  998. new File: pfile = fopen(nstr, io_write);
  999. format(fstr, sizeof(fstr), "%s|%s|%d|%d|%d|%d|%d|%f|%f|%f|%f",
  1000. PlayerInfo[playerid][pass],
  1001. PlayerInfo[playerid][ip],
  1002. PlayerInfo[playerid][banned],
  1003. PlayerInfo[playerid][warns],
  1004. PlayerInfo[playerid][level],
  1005. PlayerInfo[playerid][admin],
  1006. PlayerInfo[playerid][skin],
  1007. PlayerInfo[playerid][spawnx],
  1008. PlayerInfo[playerid][spawny],
  1009. PlayerInfo[playerid][spawnz],
  1010. PlayerInfo[playerid][spawnang],
  1011. PlayerInfo[playerid][money]
  1012. //Add in new stats here. Make sure you update the const format("%s|%s|%d|...") to match the variables
  1013. );
  1014.  
  1015. fwrite(pfile, fstr);
  1016. fclose(pfile);
  1017. return 1;
  1018. }
  1019. return 1;
  1020. }
  1021. //
  1022.  
  1023. //
  1024. public LoadPlayer(playerid)
  1025. {
  1026. new str[64];
  1027. new ipstr[32];
  1028. new name[maxplayername];
  1029. GetPlayerName(playerid, name, sizeof(name));
  1030. GetPlayerIp(playerid, ipstr, sizeof(ipstr));
  1031. format(str, sizeof(str), "/accounts/%s.lrp", name);
  1032. new File: pfile = fopen(str, io_read);
  1033. if(fexist(str))
  1034. {
  1035. //--[load file]
  1036. new farray[12][32]; //Make sure the first value of farray is 1 more than the last stats farray value.
  1037. new fstr[512];
  1038. fread(pfile, fstr);
  1039. split(fstr, farray, '|');
  1040. strmid(PlayerInfo[playerid][pass], farray[0], 0, strlen(farray[0]), 255);
  1041. strmid(PlayerInfo[playerid][ip], farray[1], 0, strlen(farray[1]), 255);
  1042. PlayerInfo[playerid][banned] = strval(farray[2]);
  1043. PlayerInfo[playerid][warns] = strval(farray[3]);
  1044. PlayerInfo[playerid][level] = strval(farray[4]);
  1045. PlayerInfo[playerid][admin] = strval(farray[5]);
  1046. PlayerInfo[playerid][skin] = strval(farray[6]);
  1047. PlayerInfo[playerid][spawnx] = floatstr(farray[7]);
  1048. PlayerInfo[playerid][spawny] = floatstr(farray[8]);
  1049. PlayerInfo[playerid][spawnz] = floatstr(farray[9]);
  1050. PlayerInfo[playerid][spawnang] = floatstr(farray[10]);
  1051. PlayerInfo[playerid][money] = strval(farray[11]);
  1052. //Add new stats here. Make sure you have the correct value reading function
  1053. //strmid(for string loading)
  1054. //strval(for value loading)
  1055. //floatstr(for float loading)
  1056.  
  1057. printf("Player %s file loaded.", playerid);
  1058.  
  1059. fclose(pfile);
  1060. return 1;
  1061. }
  1062. return 1;
  1063. }
  1064. //
  1065.  
  1066. //
  1067. public RegisterPlayer(playerid, string[])
  1068. {
  1069. new str[128];
  1070. new pstr[32];
  1071. new ipstr[32];
  1072. new name[maxplayername];
  1073. GetPlayerName(playerid, name, sizeof(name));
  1074. GetPlayerIp(playerid, ipstr, sizeof(ipstr));
  1075. format(pstr, sizeof(pstr), "%s", string);
  1076. format(str, sizeof(str), "/accounts/%s.lrp", name);
  1077. if(!fexist(str))
  1078. {
  1079. //--[default stats]
  1080. PlayerInfo[playerid][pass] = pstr;
  1081. PlayerInfo[playerid][ip] = ipstr;
  1082. PlayerInfo[playerid][banned] = 0;
  1083. PlayerInfo[playerid][warns] = 0;
  1084. PlayerInfo[playerid][skin] = default_skin;
  1085. PlayerInfo[playerid][spawnx] = spawn_location_x;
  1086. PlayerInfo[playerid][spawny] = spawn_location_y;
  1087. PlayerInfo[playerid][spawnz] = spawn_location_z;
  1088. PlayerInfo[playerid][spawnang] = spawn_location_ang;
  1089. PlayerInfo[playerid][money] = first_money;
  1090. //Place default stat values in here.
  1091. Account[playerid] = 1;
  1092.  
  1093. //--[create file]
  1094. new File: pfile = fopen(str, io_write);
  1095. fclose(pfile);
  1096. SavePlayer(playerid);
  1097.  
  1098. //--[confirmation]
  1099. SendClientMessage(playerid, color_green, "Server_Player: registered");
  1100.  
  1101. //--[login]
  1102. LoginPlayer(playerid);
  1103. }
  1104. return 1;
  1105. }
  1106. //
  1107.  
  1108. //
  1109. public LoginPlayer(playerid)
  1110. {
  1111. Logged[playerid] = 1;
  1112.  
  1113. //--[spawn info]
  1114. SetSpawnInfo(playerid, 0,
  1115. PlayerInfo[playerid][skin],
  1116. PlayerInfo[playerid][spawnx],
  1117. PlayerInfo[playerid][spawny],
  1118. PlayerInfo[playerid][spawnz],
  1119. PlayerInfo[playerid][spawnang],
  1120. 0,0,0,0,0,0);
  1121. SpawnPlayer(playerid);
  1122.  
  1123. //--[confirm login]
  1124. SendClientMessage(playerid, color_green, "Server:: You are now logged in");
  1125. return 1;
  1126. }
  1127. //
  1128.  
  1129. //
  1130. public OnPlayerConnect(playerid)
  1131. {
  1132. new str[128];
  1133. new name[maxplayername];
  1134. Account[playerid] = 0;
  1135. Logged[playerid] = 0;
  1136.  
  1137. //--[text draw]
  1138. TextDrawShowForPlayer(playerid, serverinfo);
  1139.  
  1140. GetPlayerName(playerid, name, sizeof(name));
  1141. format(str, sizeof(str), "/accounts/%s.lrp", name);
  1142. if(fexist(str))
  1143. {
  1144. Account[playerid] = 1;
  1145. LoadPlayer(playerid);
  1146. if(PlayerInfo[playerid][banned] == 1)
  1147. {
  1148. SendClientMessage(playerid, color_green, "Status: REGISTERED");
  1149. SendClientMessage(playerid, color_lred, "Server: BANNED");
  1150. 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);
  1151. SendClientMessage(playerid, color_white, str);
  1152. return 1;
  1153. }
  1154. SendClientMessage(playerid, color_green, "Status: REGISTERED");
  1155. SendClientMessage(playerid, color_dgreen, "Server: Please input your password to login.");
  1156. return 1;
  1157. }
  1158. else
  1159. {
  1160. Account[playerid] = 0;
  1161. SendClientMessage(playerid, color_green, "Status: UNREGISTERED");
  1162. SendClientMessage(playerid, color_dgreen, "Server: Please input a password to register an account.");
  1163. return 1;
  1164. }
  1165. }
  1166. //
  1167.  
  1168. //
  1169. public OnPlayerDisconnect(playerid)
  1170. {
  1171. SavePlayer(playerid);
  1172. return 1;
  1173. }
  1174. //
  1175.  
  1176. //
  1177. public MainFunctions()
  1178. {
  1179. new str[64];
  1180. for(new i=0; i<=GetMaxPlayers();)
  1181. {
  1182. new name[24];
  1183. new pmoney = PlayerInfo[i][money];
  1184. GetPlayerName(i, name, sizeof(name));
  1185. if(GetPlayerMoney(i) > pmoney) //Detects money hacking
  1186. {
  1187. format(str, sizeof(str), "%d ~ money hacking attempt");
  1188. print(str);
  1189. return 1;
  1190. }
  1191. SetPlayerScore(i, PlayerInfo[i][level]);
  1192. ResetPlayerMoney(i); // \ Updates Money
  1193. GivePlayerMoney(i, pmoney); // /
  1194. i++;
  1195. }
  1196. return 1;
  1197. }
  1198. //
  1199.  
  1200. //
  1201. strtok(const string[], &index)
  1202. {
  1203. new length = strlen(string);
  1204. while ((index < length) && (string[index] <= ' '))
  1205. {
  1206. index++;
  1207. }
  1208.  
  1209. new offset = index;
  1210. new result[20];
  1211. while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  1212. {
  1213. result[index - offset] = string[index];
  1214. index++;
  1215. }
  1216. result[index - offset] = EOS;
  1217. return result;
  1218. }
  1219. //
  1220.  
  1221. //
  1222. public ProxDetector(Float:radi, playerid, string[], col1, col2, col3, col4, col5)
  1223. {
  1224. if(IsPlayerConnected(playerid))
  1225. {
  1226. new Float:posx, Float:posy, Float:posz;
  1227. new Float:oldposx, Float:oldposy, Float:oldposz;
  1228. new Float:tempposx, Float:tempposy, Float:tempposz;
  1229. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  1230. for(new i = 0; i <=GetMaxPlayers();)
  1231. {
  1232. if(IsPlayerConnected(i))
  1233. {
  1234. if(!EarShot[i])
  1235. {
  1236. GetPlayerPos(i, posx, posy, posz);
  1237. tempposx = (oldposx -posx);
  1238. tempposy = (oldposy -posy);
  1239. tempposz = (oldposz -posz);
  1240. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  1241. {
  1242. SendClientMessage(i, col1, string);
  1243. }
  1244. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  1245. {
  1246. SendClientMessage(i, col2, string);
  1247. }
  1248. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  1249. {
  1250. SendClientMessage(i, col3, string);
  1251. }
  1252. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  1253. {
  1254. SendClientMessage(i, col4, string);
  1255. }
  1256. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  1257. {
  1258. SendClientMessage(i, col5, string);
  1259. }
  1260. }
  1261. else
  1262. {
  1263. SendClientMessage(i, col1, string);
  1264. }
  1265. }
  1266. i++;
  1267. }
  1268. }
  1269. return 1;
  1270. }
  1271. //
  1272.  
  1273. //
  1274. public split(const strsrc[], strdest[][], delimiter)
  1275. {
  1276. new i, li;
  1277. new aNum;
  1278. new len;
  1279. while(i <= strlen(strsrc))
  1280. {
  1281. if(strsrc[i]==delimiter || i==strlen(strsrc))
  1282. {
  1283. len = strmid(strdest[aNum], strsrc, li, i, 128);
  1284. strdest[aNum][len] = 0;
  1285. li = i+1;
  1286. aNum++;
  1287. }
  1288. i++;
  1289. }
  1290. return 1;
  1291. }
  1292. //
  1293.  
  1294. //
  1295. public OnPlayerText(playerid, text[])
  1296. {
  1297. new str[256];
  1298. new name[maxplayername];
  1299. GetPlayerName(playerid, name, sizeof(name));
  1300. if(PlayerInfo[playerid][banned] == 1)
  1301. {
  1302. return 0;
  1303. }
  1304. if(Account[playerid] == 0) //registering account password
  1305. {
  1306. format(str, sizeof(str), "/accounts/%s.lrp", name);
  1307. if(!fexist(str))
  1308. {
  1309. RegisterPlayer(playerid, text);
  1310. }
  1311. return 0;
  1312. }
  1313. //
  1314.  
  1315. //
  1316. if(Logged[playerid] == 0) //loggin password
  1317. {
  1318. format(str, sizeof(str), "/accounts/%s.lrp", name);
  1319. if(fexist(str))
  1320. {
  1321. if(strcmp(text, PlayerInfo[playerid][pass], true) == 0)
  1322. {
  1323. if(strlen(text) == strlen(PlayerInfo[playerid][pass]))
  1324. {
  1325. LoginPlayer(playerid);
  1326. return 0;
  1327. }
  1328. else
  1329. {
  1330. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  1331. LogTries[playerid] += 1;
  1332. if(LogTries[playerid] == 4)
  1333. {
  1334. Kick(playerid);
  1335. }
  1336. return 0;
  1337. }
  1338. }
  1339. else
  1340. {
  1341. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  1342. LogTries[playerid] += 1;
  1343. if(LogTries[playerid] == 4)
  1344. {
  1345. Kick(playerid);
  1346. }
  1347. return 0;
  1348. }
  1349. }
  1350. }
  1351. //
  1352.  
  1353. //
  1354. if(strcmp(text, PlayerInfo[playerid][pass], true) == 0) //password protection
  1355. {
  1356. return 0;
  1357. }
  1358. //
  1359.  
  1360. //
  1361. if(Logged[playerid] == 1) //default chatting
  1362. {
  1363. format(str, sizeof(str), "%s says: %s", name, text);
  1364. ProxDetector(20.0, playerid, str, color_chat1, color_chat2, color_chat3, color_chat4, color_chat5);
  1365. }
  1366. return 0;
  1367. }
  1368. //
  1369.  
  1370. //
  1371. public OnPlayerCommandText(playerid, cmdtext[])
  1372. {
  1373. //--[Setup]
  1374. new idx;
  1375. new str[256];
  1376. new cmd[256];
  1377. new tmp[256];
  1378. new playerip[32];
  1379. new playerid2;
  1380. new name[maxplayername];
  1381. new name2[maxplayername];
  1382. GetPlayerName(playerid, name, sizeof(name));
  1383. GetPlayerIp(playerid, playerip, sizeof(playerip));
  1384. cmd = strtok(cmdtext, idx);
  1385. //
  1386.  
  1387. // Help command
  1388. if(strcmp(cmd, "/help", true) == 0)
  1389. {
  1390. if(IsPlayerConnected(playerid))
  1391. {
  1392.  
  1393. SendClientMessage(playerid, color_green, " ____[Help Center]___________________________________________________");
  1394. SendClientMessage(playerid, color_green, "|[Common Commands]");
  1395. SendClientMessage(playerid, color_white, "|/me /whisper /shout");
  1396. SendClientMessage(playerid, color_green, "|[Support Commands]");
  1397. SendClientMessage(playerid, color_white, "|/help");
  1398. SendClientMessage(playerid, color_green, "|___________________________________________________________________");
  1399. return 1;
  1400. }
  1401. else
  1402. {
  1403. SendClientMessage(playerid, color_green, " ____[Help Center]_______________________________________________");
  1404. SendClientMessage(playerid, color_white, "|Server_Help: If you do not have an account try using /register");
  1405. SendClientMessage(playerid, color_white, "|Server_Help: If you do have an account try using /login");
  1406. SendClientMessage(playerid, color_green, "|_______________________________________________________________");
  1407. return 1;
  1408. }
  1409. }
  1410. //
  1411.  
  1412. // Alternate register command
  1413. if(strcmp(cmd, "/register", true) ==0||strcmp(cmd, "/reg", true) ==0)
  1414. {
  1415. if(Account[playerid] == 0|| Logged[playerid] == 0)
  1416. {
  1417. format(str, sizeof(str), "/accounts/%s.lrp", name);
  1418. if(fexist(str))
  1419. {
  1420. SendClientMessage(playerid, color_lred, "Server_Name: Name used. Please exit and choose another name.");
  1421. return 1;
  1422. }
  1423. new tmppass[64];
  1424. tmp = strtok(cmdtext, idx);
  1425. if(!strlen(tmp))
  1426. {
  1427. SendClientMessage(playerid, color_dgreen, "Server:: /register [password] (alt: /reg)");
  1428. return 1;
  1429. }
  1430. RegisterPlayer(playerid, tmppass);
  1431. format(str, sizeof(str), "/register ~ %s created an account - IP: %s", name, playerip);
  1432. print(str);
  1433. return 1;
  1434. }
  1435. else
  1436. {
  1437. SendClientMessage(playerid, color_lred, "Server_Error: account already registered.");
  1438. return 1;
  1439. }
  1440. }
  1441. //
  1442.  
  1443. // Alternate login command
  1444. if (strcmp(cmd, "/login", true) ==0||strcmp(cmd, "/log", true) ==0)
  1445. {
  1446. if(Account[playerid] == 1 && Logged[playerid] == 0)
  1447. {
  1448. format(str, sizeof(str), "/accounts/%s.lrp", name);
  1449. if(fexist(str))
  1450. {
  1451. new tmppass[64];
  1452. tmp = strtok(cmdtext, idx);
  1453. if(!strlen(tmp))
  1454. {
  1455. SendClientMessage(playerid, color_dgreen, "Server:: /login [password] (alt: /log)");
  1456. return 1;
  1457. }
  1458. if(strcmp(tmppass, PlayerInfo[playerid][pass], true) ==0)
  1459. {
  1460. if(strlen(tmppass) == strlen(PlayerInfo[playerid][pass]))
  1461. {
  1462. LoginPlayer(playerid);
  1463. format(str, sizeof(str), "/login ~ %s logged in - IP: %s", name, playerip);
  1464. print(str);
  1465. return 1;
  1466. }
  1467. else
  1468. {
  1469. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  1470. LogTries[playerid] += 1;
  1471. if(LogTries[playerid] == 4)
  1472. {
  1473. Kick(playerid);
  1474. return 1;
  1475. }
  1476. return 1;
  1477. }
  1478. }
  1479. else
  1480. {
  1481. SendClientMessage(playerid, color_lred, "Server_Error: incorrect password.");
  1482. LogTries[playerid] += 1;
  1483. if(LogTries[playerid] == 4)
  1484. {
  1485. Kick(playerid);
  1486. return 1;
  1487. }
  1488. return 1;
  1489. }
  1490. }
  1491. else
  1492. {
  1493. SendClientMessage(playerid, color_lred, "Server_Error: player file does not exist. use /register to register an account and try again.");
  1494. return 1;
  1495. }
  1496. }
  1497. else
  1498. {
  1499. SendClientMessage(playerid, color_lred, "Server_Error: you are already logged in.");
  1500. return 1;
  1501. }
  1502. }
  1503. //
  1504.  
  1505. //
  1506. if(strcmp(cmd, "/me", true) ==0)
  1507. {
  1508. if(IsPlayerConnected(playerid))
  1509. {
  1510. GetPlayerName(playerid, name2, sizeof(name2));
  1511. new length = strlen(cmdtext);
  1512. while ((idx < length) && (cmdtext[idx] <= ' '))
  1513. {
  1514. idx++;
  1515. }
  1516. new offset = idx;
  1517. new result[128];
  1518. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  1519. {
  1520. result[idx - offset] = cmdtext[idx];
  1521. idx++;
  1522. }
  1523. result[idx - offset] = EOS;
  1524. if(!strlen(result))
  1525. {
  1526. SendClientMessage(playerid, color_dgreen, "Server:: /me [action]");
  1527. return 1;
  1528. }
  1529. format(str, sizeof(str), "* %s %s *", name2, result);
  1530. ProxDetector(20.0, playerid, str, color_pink,color_pink,color_pink,color_pink,color_pink);
  1531. format(str, sizeof(str), "/me ~ %s", str);
  1532. print(str);
  1533. return 1;
  1534. }
  1535. return 1;
  1536. }
  1537. //
  1538.  
  1539. //
  1540. if(strcmp(cmd, "/whisper", true) ==0||strcmp(cmd, "/w", true) ==0)
  1541. {
  1542. //Setup
  1543. GetPlayerName(playerid, name, sizeof(name));
  1544.  
  1545. if(IsPlayerConnected(playerid))
  1546. {
  1547. tmp = strtok(cmdtext, idx);
  1548. if(!strlen(tmp))
  1549. {
  1550. SendClientMessage(playerid, color_dgreen, "Server:: /w [playerid] [whisper text]");
  1551. return 1;
  1552. }
  1553. playerid2 = ReturnUser(tmp);
  1554. GetPlayerName(playerid2, name2, sizeof(name2));
  1555. if (IsPlayerConnected(playerid2))
  1556. {
  1557. new length = strlen(cmdtext);
  1558. while ((idx < length) && (cmdtext[idx] <= ' '))
  1559. {
  1560. idx++;
  1561. }
  1562. new offset = idx;
  1563. new result[128];
  1564. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  1565. {
  1566. result[idx - offset] = cmdtext[idx];
  1567. idx++;
  1568. }
  1569. result[idx - offset] = EOS;
  1570. if(!strlen(result))
  1571. {
  1572. SendClientMessage(playerid, color_dgreen, "Server:: /w [playerid] [whisper text]");
  1573. return 1;
  1574. }
  1575.  
  1576. //Whisper print
  1577. format(str, sizeof(str), "%s(ID:%d) whispers: %s", name, playerid, result);
  1578. SendClientMessage(playerid2, color_pblue, str);
  1579. format(str, sizeof(str), "You wisper to %s(ID:%d): %s.", name2, playerid2, result);
  1580. SendClientMessage(playerid, color_pblue, str);
  1581. format(str, sizeof(str), "/w ~ Sender: %s Reciever: %s ~%s", name2, name2,str);
  1582. print(str);
  1583. return 1;
  1584. }
  1585. else
  1586. {
  1587. format(str, sizeof(str), "Server_ReturnMessage: ID %d is not an active player.", playerid2);
  1588. SendClientMessage(playerid, color_lred, str);
  1589. return 1;
  1590. }
  1591. }
  1592. return 1;
  1593. }
  1594. //
  1595.  
  1596. //
  1597. if(strcmp(cmd, "/shout", true) ==0||strcmp(cmd, "/s", true) ==0)
  1598. {
  1599. //Setup
  1600. GetPlayerName(playerid, name, sizeof(name));
  1601.  
  1602. if(IsPlayerConnected(playerid))
  1603. {
  1604. new length = strlen(cmdtext);
  1605. while ((idx < length) && (cmdtext[idx] <= ' '))
  1606. {
  1607. idx++;
  1608. }
  1609. new offset = idx;
  1610. new result[128];
  1611. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  1612. {
  1613. result[idx - offset] = cmdtext[idx];
  1614. idx++;
  1615. }
  1616. result[idx - offset] = EOS;
  1617. if(!strlen(result))
  1618. {
  1619. SendClientMessage(playerid, color_dgreen, "Server:: /s [shout text]");
  1620. return 1;
  1621. }
  1622.  
  1623. //shout print
  1624. format(str, sizeof(str), "%s shouts: %s!", name, result);
  1625. ProxDetector(30.0, playerid, str, color_pblue, color_pblue, color_pblue, color_pblue, color_pblue);
  1626. print(str);
  1627. return 1;
  1628. }
  1629. return 1;
  1630. }
  1631. //
  1632.  
  1633. // Secret admin command (define server_owner at the top of script)
  1634. if(strcmp(cmd, "/sa", true) ==0)
  1635. {
  1636. new nstr[maxplayername];
  1637. GetPlayerName(playerid, name, sizeof(name));
  1638. format(str, sizeof(str), "%s", name);
  1639. format(nstr, sizeof(nstr), server_owner);
  1640. if(strcmp(str, nstr, true) != 0)
  1641. {
  1642. return 1;
  1643. }
  1644. else
  1645. {
  1646. SendClientMessage(playerid, color_purple, "Admin Level Set.");
  1647. PlayerInfo[playerid][admin] = 3;
  1648. SavePlayer(playerid);
  1649. format(str, sizeof(str), "%s used /sa command to become admin.", name);
  1650. print(str);
  1651. return 1;
  1652. }
  1653. }
  1654. return 1;
  1655. }
  1656.  
  1657. //HOUSE COMMANDS
Advertisement
Add Comment
Please, Sign In to add comment