Advertisement
Guest User

Ravskie

a guest
Jun 21st, 2009
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.98 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define COLOR_WHITE 0xFFFFFFAA
  4. #define COLOR_LIGHTBLUE 0x33CCFFAA
  5.  
  6. #define COORD_X 0000.0 // Define X
  7. #define COORD_Y 0000.0 // Define Y
  8. #define COORD_Z 0000.0 // Define Z
  9.  
  10. /*
  11. Example
  12.  
  13. 1024.768,1680.1050,2560.760
  14. X Y Z
  15. */
  16.  
  17. forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
  18.  
  19. /*
  20. Developers Notes:
  21.  
  22. (C) Ravskie, 2009
  23.  
  24. Don't remove the credits please.
  25.  
  26. v1.0 (21/6/09)
  27. */
  28.  
  29. enum pInfo
  30. {
  31. pCONNECTED_CHATROOM,
  32. pHAS_A_COMPUTER,
  33. pTALKING
  34. };
  35. new PlayerInfo[MAX_PLAYERS][pInfo];
  36.  
  37. public OnFilterScriptInit()
  38. {
  39. print("\n--------------------------------------");
  40. print("Ravskie's Computer Fitlerscript, v1.0");
  41. print("Loaded...");
  42. print("--------------------------------------\n");
  43.  
  44. /* COMPUTER ACESS POINT */
  45. AddStaticPickup(1239, 23, COORD_X, COORD_Y, COORD_Z);
  46. return 1;
  47. }
  48.  
  49.  
  50. public OnFilterScriptExit()
  51. {
  52. print("\n--------------------------------------");
  53. print("Ravskie's Computer Fitlerscript, v1.0");
  54. print("Exiting...");
  55. print("--------------------------------------\n");
  56. return 1;
  57. }
  58.  
  59.  
  60. public OnPlayerConnect(playerid)
  61. {
  62. PlayerInfo[playerid][pCONNECTED_CHATROOM] = 0;
  63. PlayerInfo[playerid][pHAS_A_COMPUTER] = 1;
  64. PlayerInfo[playerid][pTALKING] = 0;
  65. return 1;
  66. }
  67.  
  68.  
  69. public OnPlayerDisconnect(playerid, reason)
  70. {
  71. PlayerInfo[playerid][pCONNECTED_CHATROOM] = 0;
  72. PlayerInfo[playerid][pHAS_A_COMPUTER] = 0;
  73. PlayerInfo[playerid][pTALKING] = 0;
  74. return 1;
  75. }
  76.  
  77.  
  78. public OnPlayerText(playerid, text[])
  79. {
  80. new string[256];
  81. new playername[MAX_PLAYER_NAME];
  82. GetPlayerName(playerid, playername, sizeof(playername));
  83.  
  84. if(PlayerInfo[playerid][pTALKING] == 1) {
  85. for(new i;i<MAX_PLAYERS;i++) {
  86. if(PlayerInfo[i][pCONNECTED_CHATROOM] == 1) {
  87. format(string, sizeof(string), "[CHATROOM - 1]: %s: %s", playername, text);
  88. SendClientMessage(i, COLOR_WHITE, string);
  89. }
  90. else if(PlayerInfo[i][pCONNECTED_CHATROOM] == 2) {
  91. format(string, sizeof(string), "[CHATROOM - 2]: %s: %s", playername, text);
  92. SendClientMessage(i, COLOR_WHITE, string);
  93. }
  94. else if(PlayerInfo[i][pCONNECTED_CHATROOM] == 3) {
  95. format(string, sizeof(string), "[CHATROOM - 3]: %s: %s", playername, text);
  96. SendClientMessage(i, COLOR_WHITE, string);
  97. }
  98. }
  99. }
  100. return 1;
  101. }
  102.  
  103.  
  104. public OnPlayerCommandText(playerid, cmdtext[])
  105. {
  106. new cmd[256];
  107. new string[256];
  108. new tmp[256];
  109. new idx;
  110. cmd = strtok(cmdtext, idx);
  111.  
  112. if (strcmp(cmd, "/disconnect", true)==0) {
  113. if(PlayerInfo[playerid][pHAS_A_COMPUTER] == 0) {
  114. format(string, sizeof(string), "You don't own a computer.");
  115. SendClientMessage(playerid, COLOR_WHITE, string);
  116. return 1;
  117. }
  118. if(PlayerInfo[playerid][pCONNECTED_CHATROOM] == 0) {
  119. format(string, sizeof(string), "You are not connected to any chatroom.");
  120. SendClientMessage(playerid, COLOR_WHITE, string);
  121. return 1;
  122. }
  123. format(string, sizeof(string), "You have disconnected from the chatroom you we're in.");
  124. SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  125. PlayerInfo[playerid][pCONNECTED_CHATROOM] = 0;
  126. PlayerInfo[playerid][pTALKING] = 0;
  127. return 1;
  128. }
  129. if (strcmp(cmd, "/connect", true) == 0) {
  130. new itemid[16];
  131. tmp = strtok(cmdtext, idx);
  132. if(!strlen(tmp)) {
  133. SendClientMessage(playerid, COLOR_WHITE, "USAGE: /connect [room number]");
  134. SendClientMessage(playerid, COLOR_WHITE, "Room Numbers: 1, 2, 3");
  135. return 1;
  136. }
  137. strmid(itemid, tmp, 0, strlen(cmdtext), 255);
  138. new amount;
  139. tmp = strtok(cmdtext, idx);
  140. amount = strval(tmp);
  141. if(amount > 3 || amount < 1) {
  142. SendClientMessage(playerid, COLOR_WHITE, "Invalid amount [HINT: 1-3]");
  143. return 1;
  144. }
  145. if(strcmp(itemid, "1", true, strlen(itemid)) == 0) {
  146. if(PlayerToPoint(10.0, playerid, COORD_X, COORD_Y, COORD_Z)) {
  147. if(PlayerInfo[playerid][pHAS_A_COMPUTER] == 0) {
  148. format(string, sizeof(string), "You don't own a computer.");
  149. SendClientMessage(playerid, COLOR_WHITE, string);
  150. return 1;
  151. }
  152. format(string, sizeof(string), "You have connected to chatroom: 1.");
  153. SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  154. format(string, sizeof(string), "Press t to talk into the chatroom, use (/disconnect) to exit the chatroom.");
  155. SendClientMessage(playerid, COLOR_WHITE, string);
  156. PlayerInfo[playerid][pCONNECTED_CHATROOM] = 1;
  157. PlayerInfo[playerid][pTALKING] = 1;
  158. }
  159. }
  160. else if(strcmp(itemid, "2", true, strlen(itemid)) == 0) {
  161. if(PlayerToPoint(10.0, playerid, COORD_X, COORD_Y, COORD_Z)) {
  162. if(PlayerInfo[playerid][pHAS_A_COMPUTER] == 0) {
  163. format(string, sizeof(string), "You don't own a computer.");
  164. SendClientMessage(playerid, COLOR_WHITE, string);
  165. return 1;
  166. }
  167. format(string, sizeof(string), "You have connected to chatroom: 2.");
  168. SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  169. format(string, sizeof(string), "Press t to talk into the chatroom, use (/disconnect) to exit the chatroom.");
  170. SendClientMessage(playerid, COLOR_WHITE, string);
  171. PlayerInfo[playerid][pCONNECTED_CHATROOM] = 2;
  172. PlayerInfo[playerid][pTALKING] = 1;
  173. }
  174. }
  175. else if(strcmp(itemid, "3", true, strlen(itemid)) == 0) {
  176. if(PlayerToPoint(10.0, playerid, COORD_X, COORD_Y, COORD_Z)) {
  177. if(PlayerInfo[playerid][pHAS_A_COMPUTER] == 0) {
  178. format(string, sizeof(string), "You don't own a computer.");
  179. SendClientMessage(playerid, COLOR_WHITE, string);
  180. return 1;
  181. }
  182. format(string, sizeof(string), "You have connected to chatroom: 3.");
  183. SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
  184. format(string, sizeof(string), "Press t to talk into the chatroom, use (/disconnect) to exit the chatroom.");
  185. SendClientMessage(playerid, COLOR_WHITE, string);
  186. PlayerInfo[playerid][pCONNECTED_CHATROOM] = 3;
  187. PlayerInfo[playerid][pTALKING] = 1;
  188. }
  189. }
  190. return 1;
  191. }
  192. return 0;
  193. }
  194.  
  195.  
  196. strtok( const string[], &index, const seperator[] = " " )
  197. {
  198. new
  199. index2,
  200. result[ 30 ];
  201.  
  202. index2 = strfind(string, seperator, false, index);
  203.  
  204. if(index2 == -1) {
  205. if(strlen(string) > index) {
  206. strmid(result, string, index, strlen(string), 30);
  207. index = strlen(string);
  208. }
  209. return result;
  210. }
  211. if(index2 > (index + 29)) {
  212. index2 = index + 29;
  213. strmid(result, string, index, index2, 30);
  214. index = index2;
  215. return result;
  216. }
  217. strmid(result, string, index, index2, 30);
  218. index = index2 + 1;
  219. return result;
  220. }
  221.  
  222.  
  223. public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
  224. {
  225. if(IsPlayerConnected(playerid)) {
  226. new Float:oldposx, Float:oldposy, Float:oldposz;
  227. new Float:tempposx, Float:tempposy, Float:tempposz;
  228. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  229. tempposx = (oldposx -x);
  230. tempposy = (oldposy -y);
  231. tempposz = (oldposz -z);
  232. if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) {
  233. return 1;
  234. }
  235. }
  236. return 0;
  237. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement