Advertisement
Guest User

Untitled

a guest
Sep 10th, 2011
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.89 KB | None | 0 0
  1. #include <a_samp>
  2. #include <core>
  3. #include <float>
  4. #include <Dini>
  5.  
  6. #pragma tabsize 0
  7.  
  8. main()
  9. {
  10.     print("\n----------------------------------");
  11.     print("  BIKE GAME MOD LOADING\n");
  12.     print("----------------------------------\n");
  13. }
  14.  
  15. //CORES
  16. #define COR_ADMINAVISO 0xE5273FFF
  17. #define COR_BRANCO 0xF6F6F6AA
  18. #define TEAM_GROVE 0x33AA33AA
  19. #define TEAM_BALLAS 0xFF00FFAA
  20. #define TEAM_LOS 0x00FFFFAA
  21. #define TEAM_VAGOS 0xFFFF00AA
  22. #define COR_AZUL 0x00FFFF
  23. #define COR_PRETO 0x0000FF
  24. #define COR_VERMELHO 0xFF0000AA
  25. #define COR_ROXO 0x9900FFAA
  26. #define COR_LARANJA 0xF6B347AA
  27. #define COR_INICIAL 0x7B68EE
  28. #define COR_ASSALTO1 0x008586AA
  29. #define COR_ASSALTO2 0xF6BD75AA
  30. #define COR_DROGA1 0xBF4847AA
  31. #define COR_DROGA2 0xC28400AA
  32. #define COR_MATS1 0x366239AA
  33. #define COR_MATS2 0xD9F6ADAA
  34. #define COLOR_PURPLE 0xC2A2DAAA
  35. #define COR_RADIO 0x006BF6AA
  36. #define COR_VERDE 0x009900AA
  37. #define COR_AMARELO 0xF6E659AA
  38. #define COR_CINZENTO 0xB4B4B4CD
  39.  
  40. //define pra salvar
  41. #define ARQUIVO_PLAYER "Players/%s.ini"
  42.  
  43. //define para quantas rwos existem
  44. #define numerorwo 5
  45.  
  46. public OnGameModeInit()
  47. {
  48.     // Don't use these lines if it's a filterscript
  49.     SetGameModeText("Blank Script");
  50.     ShowPlayerMarkers(1);
  51.     ShowNameTags(1);
  52.     AllowAdminTeleport(1);
  53.     AddPlayerClass(0,670.4485,889.5360,-40.3449,121.8850,0,0,0,0,-1,-1);
  54.     AddPlayerClass(1,670.4485,889.5360,-40.3449,121.8850,0,0,0,0,-1,-1);
  55.     AddPlayerClass(2,670.4485,889.5360,-40.3449,121.8850,0,0,0,0,-1,-1);
  56.     AddPlayerClass(3,670.4485,889.5360,-40.3449,121.8850,0,0,0,0,-1,-1);
  57.     AddPlayerClass(4,670.4485,889.5360,-40.3449,121.8850,0,0,0,0,-1,-1);
  58.     AddPlayerClass(5,670.4485,889.5360,-40.3449,121.8850,0,0,0,0,-1,-1);
  59.     AddPlayerClass(6,670.4485,889.5360,-40.3449,121.8850,0,0,0,0,-1,-1);
  60.     AddPlayerClass(7,670.4485,889.5360,-40.3449,121.8850,0,0,0,0,-1,-1);
  61.     AddPlayerClass(8,670.4485,889.5360,-40.3449,121.8850,0,0,0,0,-1,-1);
  62.     AddPlayerClass(9,670.4485,889.5360,-40.3449,121.8850,0,0,0,0,-1,-1);
  63.     UsePlayerPedAnims();
  64.     return 1;
  65. }
  66.  
  67. new _bikeid[MAX_PLAYERS];
  68. new _playerbike[MAX_PLAYERS];
  69. new _onrace[MAX_PLAYERS];
  70. new _valrwo[numerorwo][2] =
  71. {
  72.     {0,0},
  73.     {1,5},
  74.     {6,10},
  75.     {0,0},
  76.     {0,0}
  77. };
  78. new Stats[MAX_PLAYERS][numerorwo];
  79. new Float:Checkpoints[11][4] =
  80. {
  81.     {0.0,0.0,0.0,0.0},
  82.     //rwo 1 , 1 ate 5
  83.     {0.0,2157.1760,-1184.9639,23.3362},
  84.     {0.0,2124.3694,-1203.2394,27.6699},
  85.     {0.0,2099.3826,-1187.6034,30.0747},
  86.     {0.0,2039.3665,-1114.3225,29.3787},
  87.     {0.0,2027.1888,-1115.5092,33.7415},
  88.     //rwo 2 , 6 ate 10
  89.     {0.0,2068.1426,-1140.7107,23.7332},
  90.     {0.0,2068.0876,-1157.7153,23.6974},
  91.     {0.0,2068.2061,-1176.7998,23.6583},
  92.     {0.0,2068.5181,-1195.3827,23.7019},
  93.     {0.0,2068.7502,-1213.3203,23.8166}
  94. };
  95.  
  96. public OnGameModeExit()
  97. {
  98.     return 1;
  99. }
  100.  
  101. SetupPlayerForClassSelection(playerid)
  102. {
  103.     SetPlayerInterior(playerid,14);
  104.     SetPlayerPos(playerid,258.4893,-41.4008,1002.0234);
  105.     SetPlayerFacingAngle(playerid, 270.0);
  106.     SetPlayerCameraPos(playerid,256.0815,-43.0475,1004.0234);
  107.     SetPlayerCameraLookAt(playerid,258.4893,-41.4008,1002.0234);
  108. }
  109.  
  110. public OnPlayerRequestClass(playerid, classid)
  111. {
  112.     SetupPlayerForClassSelection(playerid);
  113.     return 1;
  114. }
  115.  
  116. public OnPlayerConnect(playerid)
  117. {
  118.     setvalzero(playerid);
  119.     GameTextForPlayer(playerid,"BIKE MODE !",5000,5);
  120.     new Name[24],FileP[64];
  121.     GetPlayerName(playerid,Name,24);
  122.     format(FileP, sizeof(FileP), ARQUIVO_PLAYER, Name);
  123.     if(!UsuarioExiste(playerid))
  124.     {
  125.             dini_Create(FileP);
  126.             dini_IntSet(FileP,"Nivel",0);
  127.             dini_IntSet(FileP,"Bike",509);
  128.     }
  129.     _playerbike[playerid] = dini_Int(FileP,"Bike");
  130.     return 1;
  131. }
  132.  
  133. public OnPlayerDisconnect(playerid, reason)
  134. {
  135.     return 1;
  136. }
  137.  
  138. public OnPlayerSpawn(playerid)
  139. {
  140.     SetPlayerHealth(playerid,99999);
  141.     SetPlayerArmour(playerid,99999);
  142.     SetPlayerInterior(playerid,0);
  143.     TogglePlayerClock(playerid,0);
  144.     return 1;
  145. }
  146.  
  147. public OnPlayerDeath(playerid, killerid, reason)
  148. {
  149.     return 1;
  150. }
  151.  
  152. public OnVehicleSpawn(vehicleid)
  153. {
  154.     return 1;
  155. }
  156.  
  157. public OnVehicleDeath(vehicleid, killerid)
  158. {
  159.     return 1;
  160. }
  161.  
  162. public OnPlayerText(playerid, text[])
  163. {
  164.     return 1;
  165. }
  166.  
  167. public OnPlayerCommandText(playerid, cmdtext[])
  168. {
  169.     if (strcmp("/bike", cmdtext, true, 10) == 0)
  170.     {
  171.         setbike(playerid);
  172.         return 1;
  173.     }
  174.     else if (strcmp("/menurwo", cmdtext, true, 10) == 0)
  175.     {
  176.         new str[64] = "RWO 1\nRWO 2\nRWO 3\nRWO 4";
  177.         ShowPlayerDialog(playerid, 0, DIALOG_STYLE_LIST, "Menu de RWO", str, "Selecionar", "Cancelar");
  178.         return 1;
  179.     }
  180.     else if (strcmp("/comprarbike", cmdtext, true, 10) == 0)
  181.     {
  182.         new str[100] = "BMX - MELHOR PARA EMPINAR\nBIKE DE CORRIDA - MAIS RAPIDA \nBIKE PADRAO - MAIS AGIL EM MANOBRAS";
  183.         ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Compra de bicicletas", str, "Comprar", "Cancelar");
  184.         return 1;
  185.     }
  186.     return 0;
  187. }
  188.  
  189. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  190. {
  191.     return 1;
  192. }
  193.  
  194. public OnPlayerExitVehicle(playerid, vehicleid)
  195. {
  196.     return 1;
  197. }
  198.  
  199. public OnPlayerStateChange(playerid, newstate, oldstate)
  200. {
  201.     if(_onrace[playerid] > 0)
  202.     {
  203.         SendClientMessage(playerid, COR_VERMELHO, "Voce caiu, entao a rwo foi desativada");
  204.         DisablePlayerRaceCheckpoint(playerid);
  205.         setvalzero(playerid);
  206.     }
  207.     return 1;
  208. }
  209.  
  210. public OnPlayerEnterCheckpoint(playerid)
  211. {
  212.     return 1;
  213. }
  214.  
  215. public OnPlayerLeaveCheckpoint(playerid)
  216. {
  217.     return 1;
  218. }
  219.  
  220. public OnPlayerEnterRaceCheckpoint(playerid)
  221. {
  222.     new oldrwo , newrwo;
  223.     if(_onrace[playerid] > 0)
  224.     {
  225.         new racenumero;
  226.         racenumero = _onrace[playerid];
  227.         if(Stats[playerid][racenumero] < _valrwo[racenumero][1]-1)
  228.         {
  229.             DisablePlayerRaceCheckpoint(playerid);
  230.             oldrwo = Stats[playerid][racenumero] + 1;
  231.             newrwo = Stats[playerid][racenumero] + 2;
  232.             new string[300];
  233.             format(string,60,"stats %i , _valrwo %i , oldrwo %i",Stats[playerid][racenumero], _valrwo[racenumero][1],oldrwo);
  234.             SendClientMessage(playerid, COR_VERMELHO, string);
  235.             setracecheck(playerid, 0, oldrwo, newrwo, 0);
  236.             Stats[playerid][racenumero] = oldrwo;
  237.         }
  238.         else if(Stats[playerid][racenumero] == _valrwo[racenumero][1]-1)
  239.         {
  240.             DisablePlayerRaceCheckpoint(playerid);
  241.             oldrwo = Stats[playerid][racenumero] + 1;
  242.             newrwo = Stats[playerid][racenumero] + 1;
  243.             setracecheck(playerid, 1, oldrwo, newrwo, 5);
  244.             Stats[playerid][racenumero] = oldrwo;
  245.         }
  246.         else if(Stats[playerid][racenumero] == _valrwo[racenumero][1])
  247.         {
  248.             SendClientMessage(playerid, COR_VERMELHO, "Voce passou essa e ganhou 3 pontos");
  249.             GivePlayerMoney(playerid, 10000);
  250.             Stats[playerid][racenumero] = 0;
  251.             _onrace[playerid] = 0;
  252.             setlevel(playerid, 2);
  253.             DisablePlayerRaceCheckpoint(playerid);
  254.         }
  255.         else
  256.         {
  257.             SendClientMessage(playerid, COR_VERMELHO, "OCORREU UM ERRO , CONTATE UM ADMIN, CODIGO DO ERRO: 21864");
  258.         }
  259.     }
  260.     return 1;
  261. }
  262.  
  263. public OnPlayerLeaveRaceCheckpoint(playerid)
  264. {
  265.     return 1;
  266. }
  267.  
  268. public OnRconCommand(cmd[])
  269. {
  270.     return 1;
  271. }
  272.  
  273. public OnPlayerRequestSpawn(playerid)
  274. {
  275.     return 1;
  276. }
  277.  
  278. public OnObjectMoved(objectid)
  279. {
  280.     return 1;
  281. }
  282.  
  283. public OnPlayerObjectMoved(playerid, objectid)
  284. {
  285.     return 1;
  286. }
  287.  
  288. public OnPlayerPickUpPickup(playerid, pickupid)
  289. {
  290.     return 1;
  291. }
  292.  
  293. public OnVehicleMod(playerid, vehicleid, componentid)
  294. {
  295.     return 1;
  296. }
  297.  
  298. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  299. {
  300.     return 1;
  301. }
  302.  
  303. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  304. {
  305.     return 1;
  306. }
  307.  
  308. public OnPlayerSelectedMenuRow(playerid, row)
  309. {
  310.     return 1;
  311. }
  312.  
  313. public OnPlayerExitedMenu(playerid)
  314. {
  315.     return 1;
  316. }
  317.  
  318. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  319. {
  320.     return 1;
  321. }
  322.  
  323. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  324. {
  325.     return 1;
  326. }
  327.  
  328. public OnRconLoginAttempt(ip[], password[], success)
  329. {
  330.     return 1;
  331. }
  332.  
  333. public OnPlayerUpdate(playerid)
  334. {
  335.     return 1;
  336. }
  337.  
  338. public OnPlayerStreamIn(playerid, forplayerid)
  339. {
  340.     return 1;
  341. }
  342.  
  343. public OnPlayerStreamOut(playerid, forplayerid)
  344. {
  345.     return 1;
  346. }
  347.  
  348. public OnVehicleStreamIn(vehicleid, forplayerid)
  349. {
  350.     return 1;
  351. }
  352.  
  353. public OnVehicleStreamOut(vehicleid, forplayerid)
  354. {
  355.     return 1;
  356. }
  357.  
  358. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  359. {
  360.     if(dialogid == 0)
  361.     {
  362.         if(response)
  363.         {
  364.             if(listitem >= 0)
  365.             {
  366.                 new valrwo;
  367.                 valrwo = listitem;
  368.                 valrwo = ++valrwo;
  369.                 setrwo(playerid, valrwo);
  370.             }
  371.         }
  372.     }
  373.     else if(dialogid == 1)
  374.     {
  375.         if(response)
  376.         {
  377.             if(listitem == 0)
  378.             {
  379.                 new nivel,FileP[64];
  380.                 nivel = getlevel(playerid);
  381.                 if(nivel >= 50)
  382.                 {
  383.                     FileP = getplayerlocal(playerid);
  384.                     dini_IntSet(FileP,"Bike",481);
  385.                     _playerbike[playerid] = 481;
  386.                     setlevel(playerid, -50);
  387.                     setbike(playerid);
  388.                 }
  389.                 else
  390.                 {
  391.                     new level,str[300];
  392.                     level = getlevel(playerid);
  393.                     format(str,200,"Voce nao tem pontos suficientes, nessesarios : 50 , seus pontos : %i",level);
  394.                     SendClientMessage(playerid, COR_VERMELHO, str);
  395.                 }
  396.             }
  397.             else if(listitem == 1)
  398.             {
  399.                 new nivel,FileP[64];
  400.                 nivel = getlevel(playerid);
  401.                 if(nivel >= 30)
  402.                 {
  403.                     FileP = getplayerlocal(playerid);
  404.                     dini_IntSet(FileP,"Bike",510);
  405.                     _playerbike[playerid] = 510;
  406.                     setlevel(playerid, -50);
  407.                     setbike(playerid);
  408.                 }
  409.                 else
  410.                 {
  411.                     new level,str[300];
  412.                     level = getlevel(playerid);
  413.                     format(str,200,"Voce nao tem pontos suficientes, nessesarios : 30 , seus pontos : %i",level);
  414.                     SendClientMessage(playerid, COR_VERMELHO, str);
  415.                 }
  416.             }
  417.             else if(listitem == 2)
  418.             {
  419.                 new nivel,FileP[64];
  420.                 nivel = getlevel(playerid);
  421.                 if(nivel >= 10)
  422.                 {
  423.                     FileP = getplayerlocal(playerid);
  424.                     dini_IntSet(FileP,"Bike",509);
  425.                     _playerbike[playerid] = 509;
  426.                     setlevel(playerid, -50);
  427.                     setbike(playerid);
  428.                 }
  429.                 else
  430.                 {
  431.                     new level,str[300];
  432.                     level = getlevel(playerid);
  433.                     format(str,200,"Voce nao tem pontos suficientes, nessesarios : 10 , seus pontos : %i",level);
  434.                     SendClientMessage(playerid, COR_VERMELHO, str);
  435.                 }
  436.             }
  437.         }
  438.     }
  439.     return 1;
  440. }
  441.  
  442. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  443. {
  444.     return 1;
  445. }
  446.  
  447. stock getlevel(playerid)
  448. {
  449.     new Local[64], valnivel;
  450.     Local = getplayerlocal(playerid);
  451.     valnivel = dini_Int(Local,"Nivel");
  452.     return valnivel;
  453. }
  454.  
  455. stock setlevel(playerid, level)
  456. {
  457.     new valnivel;
  458.     valnivel = getlevel(playerid);
  459.     if(level > 0)
  460.     {
  461.         valnivel = valnivel + level;
  462.         new local[64];
  463.         local = getplayerlocal(playerid);
  464.         dini_IntSet(local,"Nivel",valnivel);
  465.     }
  466.     else if(level < 0)
  467.     {
  468.         valnivel = valnivel - level;
  469.         new local[64];
  470.         local = getplayerlocal(playerid);
  471.         dini_IntSet(local,"Nivel",valnivel);
  472.     }
  473. }
  474.  
  475. stock setrwo(playerid, valrwo)
  476. {
  477.     new currentvehicle , modelvehicle;
  478.     currentvehicle = GetPlayerVehicleID(playerid);
  479.     modelvehicle = GetVehicleModel(currentvehicle);
  480.     if(modelvehicle == 481)
  481.     {
  482.         _onrace[playerid] = valrwo;
  483.         Stats[playerid][valrwo] = _valrwo[valrwo][0]+1;
  484.         valrwo = _valrwo[valrwo][0];
  485.         SetVehiclePos(currentvehicle, Checkpoints[valrwo][1], Checkpoints[valrwo][2], Checkpoints[valrwo][3]);
  486.         PutPlayerInVehicle(playerid, currentvehicle, 0);
  487.         new valrwo2, valrwo3;
  488.         valrwo2 = valrwo + 1;
  489.         valrwo3 = valrwo + 2;
  490.         SetPlayerRaceCheckpoint(playerid, 0, Checkpoints[valrwo2][1], Checkpoints[valrwo2][2], Checkpoints[valrwo2][3], Checkpoints[valrwo3][1], Checkpoints[valrwo3][2], Checkpoints[valrwo3][3], 2);
  491.     }
  492.     else
  493.     {
  494.         SendClientMessage(playerid, COR_VERDE, "Voce nao esta com uma bicicleta !");
  495.     }
  496. }
  497.  
  498. stock getvalrwo(valrwo)
  499. {
  500.     valrwo = _valrwo[valrwo][0];
  501.     return valrwo;
  502. }
  503.  
  504. stock getplayerlocal(playerid)
  505. {
  506.     new Name[24],FileP[64];
  507.     GetPlayerName(playerid,Name,24);
  508.     format(FileP, sizeof(FileP), ARQUIVO_PLAYER, Name);
  509.     return FileP;
  510. }
  511.  
  512.  
  513. stock setracecheck(playerid, style, val1, val2, final)
  514. {
  515.     SetPlayerRaceCheckpoint(playerid, style, Checkpoints[val1][1], Checkpoints[val1][2], Checkpoints[val1][3], Checkpoints[val2][1], Checkpoints[val2][2], Checkpoints[val2][3]-final, 2);
  516. }
  517.  
  518. stock setvalzero(playerid)
  519. {
  520.     _onrace[playerid] = 0;
  521.     _bikeid[playerid] = 0;
  522.     for(new p;p==numerorwo;p++)
  523.     {
  524.             Stats[playerid][p] = 0;
  525.     }
  526. }
  527.  
  528. stock UsuarioExiste(playerid)
  529. {
  530.     new name[MAX_PLAYER_NAME],checarp[30];
  531.     GetPlayerName(playerid, name, sizeof(name));
  532.     format(checarp, sizeof(checarp),ARQUIVO_PLAYER,name);
  533.     if(fexist(checarp)) return true;
  534.     return false;
  535. }
  536.  
  537. stock setbike(playerid)
  538. {
  539.         new currentveh;
  540.         currentveh = GetPlayerVehicleID(playerid);
  541.         if(currentveh>0)
  542.         {
  543.             DestroyVehicle(currentveh);
  544.         }
  545.         if(_bikeid[playerid] > 0)
  546.         {
  547.             DestroyVehicle(_bikeid[playerid]);
  548.         }
  549.         new Float:x, Float:y, Float:z, Float:angle;
  550.         GivePlayerWeapon(playerid,32,99999);
  551.         GetPlayerPos(playerid, x, y, z);
  552.         GetPlayerFacingAngle(playerid, angle);
  553.         new vehicleid = CreateVehicle(_playerbike[playerid], x, y, z, angle, -1, -1, -1);
  554.         _bikeid[playerid] = vehicleid;
  555.         PutPlayerInVehicle(playerid, vehicleid, 0);
  556. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement