Advertisement
Guest User

SistemaVip

a guest
Mar 1st, 2012
755
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.88 KB | None | 0 0
  1. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
  2. // Desenvolvimento: Eduardo
  3. // Tempo de desenvolvimento: 2 Dias.
  4. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
  5.  
  6.  
  7. #include a_samp
  8. #include zcmd
  9. #include dof2
  10.  
  11. new pVip [ MAX_PLAYERS ] ;
  12. forward SalvarVip ( playerid ) ;
  13. forward CarregarVip ( playerid ) ;
  14.  
  15. public OnFilterScriptInit ( )
  16. {
  17. print ( "** Filterscript de VIP ligado com sucesso! **" ) ;
  18. return 1;
  19. }
  20.  
  21. public OnFilterScriptExit ( )
  22. {
  23. print ( "** Filterscript de VIP desligado com sucesso! **" ) ;
  24. DOF2_Exit();
  25. return 1;
  26. }
  27.  
  28. public OnPlayerConnect ( playerid )
  29. {
  30. CarregarVip ( playerid ) ;
  31. return 1;
  32. }
  33.  
  34. public OnPlayerDisconnect ( playerid )
  35. {
  36. SalvarVip ( playerid ) ;
  37. return 1;
  38. }
  39.  
  40. public OnPlayerCommandPerformed ( playerid , cmdtext [ ] , success )
  41. {
  42. return 1;
  43. }
  44.  
  45. // * Inicio dos comandos * //
  46. CMD :darvip ( playerid , params [ ] )
  47. {
  48. if ( IsPlayerConnected ( playerid ) )
  49. {
  50. if ( IsPlayerAdmin ( playerid ) )
  51. {
  52. new
  53. nom [ MAX_PLAYER_NAME ] ,
  54. str [ 79 ] ,
  55. pid ,
  56. level
  57. ;
  58.  
  59. if ( sscanf ( params, "ui" , pid , level ) ) return SendClientMessage ( playerid , 0xBEBEBEAA , "USO CORRETO: /darvip [playerid] [level ~ 0 - 3]" ) ;
  60. if ( level <= 0 && level >= 3 ) return SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Level de 0 à 3!" ) ;
  61. if ( level >= 0 && level < 4)
  62. {
  63. pVip [ pid ] = level ;
  64. GetPlayerName ( playerid , nom , sizeof ( nom ) ) ;
  65. GetPlayerName ( pid , nom , sizeof ( nom ) ) ;
  66. format ( str , sizeof ( str ) , "* Você setou o level vip de %s para %d." , pid , level ) ;
  67. SendClientMessage ( playerid , 0x00FF00AA , str ) ;
  68. format ( str , sizeof ( str ) , "* %s setou seu level vip para %d." , nom , level ) ;
  69. SendClientMessage ( playerid , 0x00FF00AA , str ) ;
  70. }
  71. }
  72. else
  73. SendClientMessage ( playerid, 0x8B1A1AAA , "[ERRO] Você não está logado na RCON!" ) ;
  74. }
  75. else
  76. SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Player não conectado!" ) ;
  77. return 1;
  78. }
  79. CMD :vips ( playerid , params [ ] )
  80. {
  81. if ( IsPlayerConnected ( playerid ) )
  82. {
  83. new
  84. pn [ MAX_PLAYER_NAME ] ,
  85. str [ 56 ],
  86. Count = 0
  87. ;
  88.  
  89. SendClientMessage ( playerid , 0x00FF00AA , "~~~~~~~~~~~~~~~~ Vips ~~~~~~~~~~~~~~~~~~" ) ;
  90.  
  91. for ( new i = 0 ; i < MAX_PLAYERS; i++ )
  92. {
  93. if ( IsPlayerConnected ( i ) )
  94. {
  95. GetPlayerName ( i , pn , sizeof ( pn ) ) ;
  96. if ( pVip [ i ] >= 1 )
  97. {
  98. Count ++ ;
  99. format ( str , sizeof ( str ) , "* Vips Online Level %d: %s" , pVip[i] , pn ) ;
  100. SendClientMessage ( playerid , -1 , str ) ;
  101. }
  102. }
  103. }
  104. if ( Count == 0 )
  105. {
  106. SendClientMessage ( playerid , 0x8B1A1AAA , "* Nenhum player VIP Online" ) ;
  107. }
  108. SendClientMessage ( playerid , 0x00FF00AA , "~~~~~~~~~~~~~~~~ Vips ~~~~~~~~~~~~~~~~~~" ) ;
  109. }
  110. return 1;
  111. }
  112.  
  113. CMD :cvip ( playerid , params [ ] )
  114. {
  115. if ( IsPlayerConnected ( playerid ) )
  116. {
  117. new
  118. pnom [ MAX_PLAYER_NAME ] ,
  119. texto [ 128 ] ,
  120. str [ 79 ]
  121. ;
  122.  
  123. if ( pVip [ playerid ] >= 1 )
  124. {
  125. GetPlayerName ( playerid , pnom , sizeof ( pnom ) ) ;
  126. if ( sscanf ( params, "s" , texto ) ) return SendClientMessage ( playerid , 0x8B1A1AAA , "USO CORRETO: /cvip [texto]" ) ;
  127. format ( str , sizeof ( str ) , "I CHAT I Vip %s: %s" , pnom , texto ) ;
  128. for ( new i = 0 ; i < MAX_PLAYERS; i++ )
  129. {
  130. if ( pVip [ i ] > 0 )
  131. {
  132. SendClientMessage ( i , 0x00FF00AA, str ) ;
  133. }
  134. }
  135. }
  136. }
  137. else
  138. SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Você não é Vip!" ) ;
  139. return 1;
  140. }
  141.  
  142. CMD :ajudavip ( playerid , params [ ] )
  143. {
  144. if ( pVip [ playerid ] >= 1 )
  145. {
  146. new
  147. dial [ 500 ]
  148. ;
  149.  
  150. format ( dial , sizeof ( dial ) , "{6495ED}Todos comandos vip\n{EE82EE}Kit Vip: {FFFFFF}/kitvip\n{EE82EE}Para vêr vips online: {FFFFFF}/vips\n{EE82EE}Chat vip: {FFFFFF}/cvip \n{EE82EE}Enche vida: {FFFFFF}/vidav \n{EE82EE}Enche Colete: {FFFFFF}/coletev\n{EE82EE}Jetpack: {FFFFFF}/jetpackv\n{EE82EE}Reparar Veiculo: {FFFFFF}/repararv" ) ;
  151. ShowPlayerDialog ( playerid , 999 , DIALOG_STYLE_MSGBOX , "{FFFF00}Comandos Vip" , dial , "OK" , "" ) ;
  152. }
  153. else
  154. SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Você não é VIP!" ) ;
  155. return 1;
  156. }
  157.  
  158. CMD :kitvip ( playerid , params [ ] )
  159. {
  160. if ( IsPlayerConnected ( playerid ) )
  161. {
  162. new
  163. pnom [ MAX_PLAYER_NAME ] ,
  164. texto [ 128 ] ,
  165. str [ 79 ]
  166. ;
  167.  
  168. if ( pVip [ playerid ] >= 1 )
  169. {
  170. GivePlayerWeapon ( playerid , 24 , 9999 );
  171. GivePlayerWeapon ( playerid , 26 , 9999 );
  172. GivePlayerWeapon ( playerid , 28 , 9999 );
  173. GivePlayerWeapon ( playerid , 31 , 9999 );
  174. GivePlayerWeapon ( playerid , 34 , 9999 );
  175. GetPlayerName ( playerid , pnom , sizeof ( pnom ) ) ;
  176. format ( str , sizeof ( str ) , "Vip %s pego o kit VIP" , pnom , texto ) ;
  177. for ( new i = 0 ; i < MAX_PLAYERS; i++ )
  178. {
  179. if ( pVip [ i ] > 1 )
  180. {
  181. SendClientMessage ( i , 0x00FFFFAA, str ) ;
  182. }
  183. }
  184. }
  185. }
  186. else
  187. SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Você não é VIP" ) ;
  188. return 1;
  189. }
  190.  
  191. CMD :coletev ( playerid , params [ ] )
  192. {
  193. if ( IsPlayerConnected ( playerid ) )
  194. {
  195. new
  196. pnom [ MAX_PLAYER_NAME ] ,
  197. texto [ 128 ] ,
  198. str [ 79 ]
  199. ;
  200.  
  201. if ( pVip [ playerid ] >= 1 )
  202. {
  203. SetPlayerArmour(playerid, 100);
  204. GetPlayerName ( playerid , pnom , sizeof ( pnom ) ) ;
  205. format ( str , sizeof ( str ) , "Vip %s encheu o colete!" , pnom , texto ) ;
  206. for ( new i = 0 ; i < MAX_PLAYERS; i++ )
  207. {
  208. if ( pVip [ i ] > 1 )
  209. {
  210. SendClientMessage ( i , 0x00FFFFAA, str ) ;
  211. }
  212. }
  213. }
  214. }
  215. else
  216. SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Você não é VIP" ) ;
  217. return 1;
  218. }
  219.  
  220. CMD :vidav ( playerid , params [ ] )
  221. {
  222. if ( IsPlayerConnected ( playerid ) )
  223. {
  224. new
  225. pnom [ MAX_PLAYER_NAME ] ,
  226. texto [ 128 ] ,
  227. str [ 79 ]
  228. ;
  229.  
  230. if ( pVip [ playerid ] >= 1 )
  231. {
  232. SetPlayerHealth ( playerid , 100 );
  233. GetPlayerName ( playerid , pnom , sizeof ( pnom ) ) ;
  234. format ( str , sizeof ( str ) , "Vip %s encheu a vida!" , pnom , texto ) ;
  235. for ( new i = 0 ; i < MAX_PLAYERS; i++ )
  236. {
  237. if ( pVip [ i ] > 1 )
  238. {
  239. SendClientMessage ( i , 0x00FFFFAA, str ) ;
  240. }
  241. }
  242. }
  243. }
  244. else
  245. SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Você não é VIP" ) ;
  246. return 1;
  247. }
  248.  
  249. CMD :jetpackv ( playerid , params [ ] )
  250. {
  251. if ( IsPlayerConnected ( playerid ) )
  252. {
  253. new
  254. pnom [ MAX_PLAYER_NAME ] ,
  255. texto [ 128 ] ,
  256. str [ 79 ]
  257. ;
  258.  
  259. if ( pVip [ playerid ] >= 1 )
  260. {
  261. if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0x8B1A1AAA, "Você Não Pode Usar JetPack em Um Veiculo !");
  262. new Float:X, Float:Y, Float:Z;
  263. GetPlayerPos(playerid, X, Y, Z);
  264. CreatePickup(370, 3, X, Y, Z);
  265. GetPlayerName ( playerid , pnom , sizeof ( pnom ) ) ;
  266. format ( str , sizeof ( str ) , "Vip %s pegou JetPack!" , pnom , texto ) ;
  267. for ( new i = 0 ; i < MAX_PLAYERS; i++ )
  268. {
  269. if ( pVip [ i ] > 1 )
  270. {
  271. SendClientMessage ( i , 0x00FFFFAA, str ) ;
  272. }
  273. }
  274. }
  275. }
  276. else
  277. SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Você não é VIP" ) ;
  278. return 1;
  279. }
  280.  
  281. CMD :repararv ( playerid , params [ ] )
  282. {
  283. if ( IsPlayerConnected ( playerid ) )
  284. {
  285. new
  286. pnom [ MAX_PLAYER_NAME ] ,
  287. texto [ 128 ] ,
  288. str [ 79 ]
  289. ;
  290.  
  291. if ( pVip [ playerid ] >= 1 )
  292. {
  293. if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0x8B1A1AAA, "Você não está em um veiculo!");
  294. RepairVehicle(GetPlayerVehicleID(playerid));
  295. GetPlayerName ( playerid , pnom , sizeof ( pnom ) ) ;
  296. format ( str , sizeof ( str ) , "Vip %s pegou JetPack!" , pnom , texto ) ;
  297. for ( new i = 0 ; i < MAX_PLAYERS; i++ )
  298. {
  299. if ( pVip [ i ] > 1 )
  300. {
  301. SendClientMessage ( i , 0x00FFFFAA, str ) ;
  302. }
  303. }
  304. }
  305. }
  306. else
  307. SendClientMessage ( playerid , 0x8B1A1AAA , "[ERRO] Você não é VIP" ) ;
  308. return 1;
  309. }
  310. // * Fim dos comandos * //
  311.  
  312. public SalvarVip ( playerid )
  313. {
  314. new
  315. ArquivoVIP [ 50 ] ,
  316. NomeP [ MAX_PLAYER_NAME ]
  317. ;
  318.  
  319. GetPlayerName ( playerid , NomeP , MAX_PLAYER_NAME ) ;
  320. format ( ArquivoVIP , 50 , "Vips/%s" , NomeP ) ;
  321. if ( !DOF2_FileExists ( ArquivoVIP ) ) return DOF2_CreateFile ( ArquivoVIP ) ;
  322. DOF2_SetInt ( ArquivoVIP , "VipLevel" , pVip [ playerid ] ) ;
  323. DOF2_SaveFile ( ) ;
  324. return 1;
  325. }
  326.  
  327. public CarregarVip ( playerid )
  328. {
  329. new
  330. ArquivoVIP [ 50 ] ,
  331. NomeP [ MAX_PLAYER_NAME ]
  332. ;
  333.  
  334. GetPlayerName ( playerid, NomeP, MAX_PLAYER_NAME ) ;
  335. format ( ArquivoVIP , 50 , "Vips/%s" , NomeP ) ;
  336. if ( DOF2_FileExists ( ArquivoVIP ) )
  337. {
  338. pVip [ playerid ] = ( playerid , DOF2_GetInt ( ArquivoVIP , "VipLevel" ) ) ;
  339. }
  340. return 1;
  341. }
  342.  
  343. stock sscanf(string[], format[], {Float,_}:...)
  344. {
  345. #if defined isnull
  346. if (isnull(string))
  347. #else
  348. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  349. #endif
  350. {
  351. return format[0];
  352. }
  353. #pragma tabsize 4
  354. new
  355. formatPos = 0,
  356. stringPos = 0,
  357. paramPos = 2,
  358. paramCount = numargs(),
  359. delim = ' ';
  360. while (string[stringPos] && string[stringPos] <= ' ')
  361. {
  362. stringPos++;
  363. }
  364. while (paramPos < paramCount && string[stringPos])
  365. {
  366. switch (format[formatPos++])
  367. {
  368. case '\0':
  369. {
  370. return 0;
  371. }
  372. case 'i', 'd':
  373. {
  374. new
  375. neg = 1,
  376. num = 0,
  377. ch = string[stringPos];
  378. if (ch == '-')
  379. {
  380. neg = -1;
  381. ch = string[++stringPos];
  382. }
  383. do
  384. {
  385. stringPos++;
  386. if ('0' <= ch <= '9')
  387. {
  388. num = (num * 10) + (ch - '0');
  389. }
  390. else
  391. {
  392. return -1;
  393. }
  394. }
  395. while ((ch = string[stringPos]) > ' ' && ch != delim);
  396. setarg(paramPos, 0, num * neg);
  397. }
  398. case 'h', 'x':
  399. {
  400. new
  401. num = 0,
  402. ch = string[stringPos];
  403. do
  404. {
  405. stringPos++;
  406. switch (ch)
  407. {
  408. case 'x', 'X':
  409. {
  410. num = 0;
  411. continue;
  412. }
  413. case '0' .. '9':
  414. {
  415. num = (num << 4) | (ch - '0');
  416. }
  417. case 'a' .. 'f':
  418. {
  419. num = (num << 4) | (ch - ('a' - 10));
  420. }
  421. case 'A' .. 'F':
  422. {
  423. num = (num << 4) | (ch - ('A' - 10));
  424. }
  425. default:
  426. {
  427. return -1;
  428. }
  429. }
  430. }
  431. while ((ch = string[stringPos]) > ' ' && ch != delim);
  432. setarg(paramPos, 0, num);
  433. }
  434. case 'c':
  435. {
  436. setarg(paramPos, 0, string[stringPos++]);
  437. }
  438. case 'f':
  439. {
  440.  
  441. new changestr[16], changepos = 0, strpos = stringPos;
  442. while(changepos < 16 && string[strpos] && string[strpos] != delim)
  443. {
  444. changestr[changepos++] = string[strpos++];
  445. }
  446. changestr[changepos] = '\0';
  447. setarg(paramPos,0,_:floatstr(changestr));
  448. }
  449. case 'p':
  450. {
  451. delim = format[formatPos++];
  452. continue;
  453. }
  454. case '\'':
  455. {
  456. new
  457. end = formatPos - 1,
  458. ch;
  459. while ((ch = format[++end]) && ch != '\'') {}
  460. if (!ch)
  461. {
  462. return -1;
  463. }
  464. format[end] = '\0';
  465. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  466. {
  467. if (format[end + 1])
  468. {
  469. return -1;
  470. }
  471. return 0;
  472. }
  473. format[end] = '\'';
  474. stringPos = ch + (end - formatPos);
  475. formatPos = end + 1;
  476. }
  477. case 'u':
  478. {
  479. new
  480. end = stringPos - 1,
  481. id = 0,
  482. bool:num = true,
  483. ch;
  484. while ((ch = string[++end]) && ch != delim)
  485. {
  486. if (num)
  487. {
  488. if ('0' <= ch <= '9')
  489. {
  490. id = (id * 10) + (ch - '0');
  491. }
  492. else
  493. {
  494. num = false;
  495. }
  496. }
  497. }
  498. if (num && IsPlayerConnected(id))
  499. {
  500. setarg(paramPos, 0, id);
  501. }
  502. else
  503. {
  504. #if !defined foreach
  505. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  506. #define __SSCANF_FOREACH__
  507. #endif
  508. string[end] = '\0';
  509. num = false;
  510. new
  511. name[MAX_PLAYER_NAME];
  512. id = end - stringPos;
  513. foreach (Player, playerid)
  514. {
  515. GetPlayerName(playerid, name, sizeof (name));
  516. if (!strcmp(name, string[stringPos], true, id))
  517. {
  518. setarg(paramPos, 0, playerid);
  519. num = true;
  520. break;
  521. }
  522. }
  523. if (!num)
  524. {
  525. setarg(paramPos, 0, INVALID_PLAYER_ID);
  526. }
  527. string[end] = ch;
  528. #if defined __SSCANF_FOREACH__
  529. #undef foreach
  530. #undef __SSCANF_FOREACH__
  531. #endif
  532. }
  533. stringPos = end;
  534. }
  535. case 's', 'z':
  536. {
  537. new
  538. i = 0,
  539. ch;
  540. if (format[formatPos])
  541. {
  542. while ((ch = string[stringPos++]) && ch != delim)
  543. {
  544. setarg(paramPos, i++, ch);
  545. }
  546. if (!i)
  547. {
  548. return -1;
  549. }
  550. }
  551. else
  552. {
  553. while ((ch = string[stringPos++]))
  554. {
  555. setarg(paramPos, i++, ch);
  556. }
  557. }
  558. stringPos--;
  559. setarg(paramPos, i, '\0');
  560. }
  561. default:
  562. {
  563. continue;
  564. }
  565. }
  566. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  567. {
  568. stringPos++;
  569. }
  570. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  571. {
  572. stringPos++;
  573. }
  574. paramPos++;
  575. }
  576. do
  577. {
  578. if ((delim = format[formatPos++]) > ' ')
  579. {
  580. if (delim == '\'')
  581. {
  582. while ((delim = format[formatPos++]) && delim != '\'') {}
  583. }
  584. else if (delim != 'z')
  585. {
  586. return delim;
  587. }
  588. }
  589. }
  590. while (delim > ' ');
  591. return 0;
  592. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement