Advertisement
Guest User

my prooblem

a guest
Mar 17th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <ZCMD>
  3. #include <sscanf2>
  4. #include <dini>
  5. #include <dudb>
  6. #include <utils>
  7. #pragma unused IsNumeric
  8. #pragma unused ReturnUser
  9.  
  10. #define MOD_IME eSport
  11. #define red 0xAA3333AA
  12.  
  13. main()
  14. {
  15. print("e-Sport.hr RolePlay 1.0 je ucitan!");
  16. }
  17. forward ProvjeriVrijeme(playerid);
  18. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  19. // Admin leveli
  20. enum pData
  21. {
  22. pAdminLevel
  23. };
  24. // kraj admin leveli
  25.  
  26. // Login/reg i sistem spremanja
  27. #pragma unused ret_memcpy
  28. #pragma unused strtok
  29.  
  30. #define COLOR_GREY 0xAFAFAFAA
  31. #define COLOR_GREEN 0x33AA33AA
  32. #define COLOR_ORANGE 0xFF9900AA
  33. #define COLOR_RED 0xAA3333AA
  34. #define COLOR_YELLOW 0xFFFF00AA
  35.  
  36. enum pInfo
  37. {
  38. pAdminLevel,
  39. pCash,
  40. pLevel,
  41. pTimeOnline,
  42. pMute,
  43. }
  44.  
  45. new levels,Nam[MAX_PLAYER_NAME],pname[MAX_PLAYER_NAME],str[128],ID;
  46. new PlayerData[MAX_PLAYERS][pData];
  47. new PlayerInfo[MAX_PLAYERS][pInfo];
  48. new gPlayerLogged[MAX_PLAYERS];
  49. new VrijemeOnline;
  50.  
  51. #define SERVER_USER_FILE "Korisnici/%s.ini"
  52.  
  53. public OnPlayerConnect(playerid)
  54. {
  55. gPlayerLogged[playerid] = 0;
  56. new name[MAX_PLAYER_NAME], file[256];
  57. GetPlayerName(playerid, name, sizeof(name));
  58. format(file, sizeof(file), SERVER_USER_FILE, name);
  59. if (!dini_Exists(file))
  60. {
  61. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not registered mate, input your registration pw below", "Register", "Leave");
  62. }
  63. if(fexist(file))
  64. {
  65. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave");
  66. }
  67. return 1;
  68. }
  69.  
  70. public OnPlayerDisconnect(playerid, reason)
  71. {
  72. new name[MAX_PLAYER_NAME], file[256];
  73. GetPlayerName(playerid, name, sizeof(name));
  74. format(file, sizeof(file), SERVER_USER_FILE, name);
  75. if(gPlayerLogged[playerid] == 1)
  76. {
  77. dini_IntSet(file, "Level", PlayerInfo[playerid][pLevel]);
  78. dini_IntSet(file, "Money", PlayerInfo[playerid][pCash]);
  79. dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel]);
  80. dini_IntSet(file, "Mute",PlayerInfo[playerid][pMute]);
  81. dini_IntSet(file, "VrijemeOnline",PlayerInfo[playerid][pTimeOnline]);
  82. }
  83. gPlayerLogged[playerid] = 0;
  84. return 1;
  85. }
  86.  
  87. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  88. {
  89. if (dialogid == 1)
  90. {
  91. new name[MAX_PLAYER_NAME], file[256], string[128];
  92. GetPlayerName(playerid, name, sizeof(name));
  93. format(file, sizeof(file), SERVER_USER_FILE, name);
  94. if(!response) return Kick(playerid);
  95. if (!strlen(inputtext)) return
  96. ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not registered mate, input your registration pw below", "Register", "Leave");
  97. dini_Create(file);
  98. dini_IntSet(file, "Password", udb_hash(inputtext));
  99. dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
  100. dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 0);
  101. dini_IntSet(file, "Level",PlayerInfo[playerid][pLevel] = 1);
  102. dini_IntSet(file, "Mute",PlayerInfo[playerid][pMute] = 0);
  103. dini_IntSet(file, "VrijemeOnline",PlayerInfo[playerid][pTimeOnline] = 0);
  104. format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
  105. SendClientMessage(playerid, COLOR_YELLOW, string);
  106. gPlayerLogged[playerid] = 1;
  107. }
  108. if (dialogid == 2)
  109. {
  110. new name[MAX_PLAYER_NAME], file[256];
  111. new Levscore;
  112. GetPlayerName(playerid, name, sizeof(name));
  113. format(file, sizeof(file), SERVER_USER_FILE, name);
  114. if(!response) return Kick(playerid);
  115. if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave");
  116. new tmp;
  117. tmp = dini_Int(file, "Password");
  118. if(udb_hash(inputtext) != tmp) {
  119. SendClientMessage(playerid, COLOR_RED, "Wrong PW sir.");
  120. ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Fucken awesome mate, your registered :D. Inpute your pw below", "Login", "Leave");
  121. }
  122. else
  123. {
  124. gPlayerLogged[playerid] = 1;
  125. PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
  126. PlayerInfo[playerid][pMute] = dini_Int(file, "Mute");
  127. PlayerData[ID][pAdminLevel] = dini_Int(file, "AdminLevel");
  128. PlayerInfo[playerid][pLevel] = dini_Int(file, "Level");
  129. Levscore = PlayerInfo[playerid][pLevel];
  130. SetPlayerScore(playerid, Levscore);
  131. PlayerInfo[playerid][pTimeOnline] = dini_Int(file, "VrijemeOnline");
  132. GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
  133. SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!");
  134. }
  135. }
  136. return 1;
  137. }
  138. // kraj Login/reg i sistem spremanja
  139.  
  140. // Admin komande
  141. CMD:postaviadmina(playerid, params[])
  142. {
  143.  
  144. if(!IsPlayerAdmin(playerid))return 0; //Ova komanda radi samo sa rconom
  145. if(sscanf(params,"ui",ID,levels)) return SendClientMessage(playerid,0xFF9900AA, "Koristenje: /postaviadmina [ID/dio imena] [Level 1-4]");// Pokazat ce ovo ako ne koristi komandu pravilno
  146. if(levels > 4) return SendClientMessage(playerid,0xFF0000FF,"Greska: Moguci su leveli 1-4.");// Dostupni leveli
  147. if(!IsPlayerConnected(ID))return SendClientMessage(playerid,0xFF0000FF,"Greska: ID/dio imena koji ste upisali nije ispravan.");//Detektira ako je ID/dioimena online
  148. if(PlayerData[ID][pAdminLevel] == levels) return SendClientMessage(playerid,0xFF0000FF, "Greska: Taj korisnik vec ima taj admin level.");// Detektira ako je osoba vec taj level
  149. GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);// Dobiva ime iz id
  150. GetPlayerName(ID,pname,MAX_PLAYER_NAME);// Dobiva ime druge osobe
  151. if(levels == 0)
  152. {
  153. format(str, sizeof(str),"%s ti je postavio Admin Level %d.",Nam,levels);
  154. SendClientMessage(ID,0xFF9900AA,str);
  155. format(str, sizeof(str),"Postavio si %s Admin Level %d.",pname,levels);
  156. SendClientMessage(playerid,0xFF9900AA,str);
  157. PlayerData[ID][pAdminLevel] = levels;//ovo postavlja igracev level
  158. PlayerInfo[playerid][pAdminLevel] = levels;
  159. return 1;
  160. }
  161. format(str, sizeof(str),"%s ti je postavio Admin Level %d.",Nam,levels);
  162. SendClientMessage(ID,0xFF9900AA,str);
  163. format(str, sizeof(str),"Postavio si %s Admin Level %d.",pname,levels);
  164. SendClientMessage(playerid,0xFF9900AA,str);
  165. PlayerData[ID][pAdminLevel] = levels;
  166. PlayerInfo[playerid][pAdminLevel] = levels;
  167. return 1;
  168. }
  169. CMD:mute(playerid,params[]) {
  170. new
  171. id,
  172. name1[30],
  173. name2[30],
  174. reason[512],
  175. reason2[512],
  176. text[512];
  177. if(sscanf(params,"us",id, reason))
  178. return SendClientMessage(playerid, 0xFF9900AA,"Koristenje: /mute [ID/dio imena] [Razlog]");
  179. if(PlayerInfo[playerid][pAdminLevel] >= 2) {
  180. if(IsPlayerConnected(id)) {
  181. if(PlayerInfo[id][pAdminLevel] <= PlayerInfo[playerid][pAdminLevel]) {
  182. if(PlayerInfo[playerid][pMute] == 0) {
  183. GetPlayerName(playerid,name1,sizeof(name1));
  184. GetPlayerName(id,name2,sizeof(name2));
  185. format(text,sizeof(text),"{00DDFF}Administrator {FFEA00}%s{00DDFF} je oduzeo pravo govora igracu {FFEA00}%s{00DDFF}.",name1,name2);
  186. format(reason2,sizeof(reason2),"{00DDFF}[Razlog: {FFEA00}%s{00DDFF}]", reason);
  187. SendClientMessageToAll(0xFFEA00,text);
  188. SendClientMessageToAll(0xFFEA00,reason2);
  189. PlayerInfo[id][pMute] = 1;
  190. new command[30];
  191. format(command,sizeof(command),"unmute(%i)",id);
  192. } else {
  193. return SendClientMessage(playerid, 0xFF0000FF,"Greska: Igracu je vec oduzeto pravo govora.");
  194. }
  195. } else {
  196. return SendClientMessage(playerid, 0xFF0000FF,"Greska: Nemozete oduzeti pravo govora adminu veceg levela.");
  197. }
  198. } else {
  199. return SendClientMessage(playerid,0xFF0000FF,"Greska: ID/dio imena koji ste upisali nije ispravan.");
  200. }
  201. } else {
  202. return SendClientMessage(playerid, 0xFF0000FF,"Greska: Ovu komandu mogu koristiti samo admini level 2 ili vise.");
  203. }
  204. return 1;
  205. }
  206.  
  207.  
  208. CMD:unmute(playerid,params[]) {
  209. new
  210. id,
  211. name1[30],
  212. name2[30],
  213. text[128];
  214. if(sscanf(params,"u",id))
  215. return SendClientMessage(playerid,0xFF9900AA,"Koristenje: /unmute [ID/dio imena]");
  216. if(PlayerInfo[playerid][pAdminLevel] >= 2) {
  217. if(IsPlayerConnected(id)) {
  218. if(PlayerInfo[id][pAdminLevel] <= PlayerInfo[playerid][pAdminLevel]) {
  219. if(PlayerInfo[playerid][pMute] == 1) {
  220. GetPlayerName(playerid,name1,sizeof(name1));
  221. GetPlayerName(id,name2,sizeof(name2));
  222. format(text,sizeof(text),"{00DDFF}Administrator {FFEA00}%s{00DDFF} je vratio pravo govora igracu {FFEA00}%s{00DDFF}.",name1,name2);
  223. SendClientMessageToAll(0xFFEA00,text);
  224. PlayerInfo[id][pMute] = 0;
  225. } else {
  226. return SendClientMessage(playerid,0xFF0000FF,"Greska: Igrac vec ima pravo govora.");
  227. }
  228. } else {
  229. return SendClientMessage(playerid,0xFF0000FF,"Greska: Nemozete vratiti pravo govora adminu veceg levela.");
  230. }
  231. } else {
  232. return SendClientMessage(playerid,0xFF0000FF,"Greska: ID/dio imena koji ste upisali nije ispravan.");
  233. }
  234. } else {
  235. return SendClientMessage(playerid,0xFF0000FF,"Greska: Ovu komandu mogu koristiti samo admini level 2 ili vise.");
  236. }
  237. return 1;
  238. }
  239. //unmute timer:
  240.  
  241. forward unmute(id);
  242.  
  243. public unmute(id) {
  244. PlayerInfo[id][pMute] = 0;
  245. SendClientMessage(id,COLOR_GREEN,"Your mute time is over. You can talk again :]");
  246. }
  247. // kraj Admin komande
  248. // igrac komande
  249. // kraj igrac komande
  250.  
  251. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  252. {
  253. if(IsPlayerConnected(playerid))
  254. {
  255. new Float:posx, Float:posy, Float:posz;
  256. new Float:oldposx, Float:oldposy, Float:oldposz;
  257. new Float:tempposx, Float:tempposy, Float:tempposz;
  258. GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  259. for(new i = 0; i < MAX_PLAYERS; i++)
  260. {
  261. if(IsPlayerConnected(i) && (GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i)))
  262. {
  263. GetPlayerPos(i, posx, posy, posz);
  264. tempposx = (oldposx -posx);
  265. tempposy = (oldposy -posy);
  266. tempposz = (oldposz -posz);
  267. if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  268. {
  269. SendClientMessage(i, col1, string);
  270. }
  271. else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  272. {
  273. SendClientMessage(i, col2, string);
  274. }
  275. else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  276. {
  277. SendClientMessage(i, col3, string);
  278. }
  279. else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  280. {
  281. SendClientMessage(i, col4, string);
  282. }
  283. else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  284. {
  285. SendClientMessage(i, col5, string);
  286. }
  287. }
  288. else
  289. {
  290. SendClientMessage(i, col1, string);
  291. }
  292. }
  293. }
  294. return 1;
  295. }
  296. #define COLOR_CHAT1 0xFFFFFFFF
  297. #define COLOR_CHAT2 0xC8C8C8C8
  298. #define COLOR_CHAT3 0xAAAAAAAA
  299. #define COLOR_CHAT4 0x8C8C8C8C
  300. #define COLOR_CHAT5 0x6E6E6E6E
  301. #define COLOR_WHITE 0xFFFFFFFF
  302.  
  303. public OnPlayerText(playerid, text[])
  304. {
  305. new string [128];
  306. new sendername[MAX_PLAYER_NAME];
  307. GetPlayerName(playerid, sendername, sizeof(sendername));
  308. if(PlayerInfo[playerid][pMute] == 1)
  309. {
  310. SendClientMessage(playerid, 0xFF0000FF, "Greska: Ne mozete pricati, oduzeto vam je pravo govora.");
  311. return 0;
  312. }
  313. if(PlayerInfo[playerid][pMute] == 0)
  314. {
  315. format(string, sizeof(string), "%s: %s ", sendername, text);
  316. ProxDetector(25.0, playerid, string,COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
  317. return 0;
  318. }
  319. return 0;
  320. }
  321. public OnGameModeInit()
  322. {
  323. VrijemeOnline = SetTimer("ProvjeriVrijeme",60000,1);
  324. return 1;
  325. }
  326. public OnGameModeExit()
  327. {
  328. KillTimer(VrijemeOnline);
  329. return 1;
  330. }
  331. public ProvjeriVrijeme(playerid)
  332. {
  333. if(IsPlayerConnected(ID)) {
  334. PlayerInfo[playerid][pTimeOnline]++;
  335. }
  336. return 1;
  337. }
  338. forward AddLevel2(playerid);
  339. public AddLevel2(playerid)
  340. {
  341. if(playerid, PlayerInfo[playerid][pTimeOnline] == 300) {
  342. PlayerInfo[playerid][pLevel]+1;
  343. return SendClientMessage(playerid,0xFF0000FF,"Info: Congratz! Now you are level 2.");
  344. }
  345. return 1;
  346. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement