badjhbzi

Nade Parkouring v1.2

Jul 15th, 2013
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.08 KB | None | 0 0
  1. /*
  2. 888888888888888888888888888888888888888888
  3. 88           NADE-PARKOURING            88
  4. 888888888888888888888888888888888888888888
  5. 88 - AUTHOR: Badjouras                  88
  6. 88         (aka hbzi @ forum.sa-mp.com) 88
  7. 88 - VERSION: 1.2                       88
  8. 88 - LAST UPDATE: 15/07                 88
  9. 888888888888888888888888888888888888888888
  10. 88 - CHANGELOG:                         88
  11. 88   - Added time and attempt counters  88
  12. 888888888888888888888888888888888888888888
  13. */
  14.  
  15. // * INCLUDES * //
  16. #include <a_samp>
  17. #include <core>
  18. #include <Dini>
  19. #include <float>
  20. #include <zcmd>
  21.  
  22. // * DEFINES FUNCS * //
  23. #define Msg SendClientMessage
  24. #define MsgAll SendClientMessageToAll
  25.  
  26. // * CONSTANTES * //
  27. #define MAX_FILES 100
  28.  
  29. // * VARS * //
  30. new bool:isPark[MAX_PLAYERS+1] = false;
  31. new nivelPark[MAX_PLAYERS+1] = 1;
  32. new tentsPark[MAX_PLAYERS+1] = 0;
  33. new str[150];
  34. new timers[MAX_PLAYERS+1];
  35. new contador[2][MAX_PLAYERS+1];
  36. new Text:tempo[MAX_PLAYERS+1];
  37. new pFirstL[MAX_PLAYERS+1];
  38.  
  39. // * STOCKS * //
  40. stock GetPlayerN(playerid)
  41. {
  42.    new nomeJog[MAX_PLAYER_NAME];
  43.    GetPlayerName(playerid, nomeJog, MAX_PLAYER_NAME);
  44.    return nomeJog;
  45. }
  46.  
  47. stock DarNadesVida(playerid)
  48. {
  49.     ResetPlayerWeapons(playerid);
  50.     GivePlayerWeapon(playerid, 16, 9999);
  51.     SetPlayerHealth(playerid, 9999999);
  52.     return 1;
  53. }
  54.  
  55. stock FirstLevel(playerid)
  56. {
  57.     pFirstL[playerid] = 1;
  58.     format(str, sizeof(str), "You are now at level {00FF00}1{FFFFFF}!");
  59.     Msg(playerid, -1, str);
  60.     new tmps[64];
  61.     format(tmps, sizeof(tmps), "parkour/1.txt");
  62.     new Float:pos[7];
  63.     pos[0] = dini_Float(tmps, "posIX");
  64.     pos[1] = dini_Float(tmps, "posIY");
  65.     pos[2] = dini_Float(tmps, "posIZ");
  66.     pos[3] = dini_Float(tmps, "angI");
  67.     pos[4] = dini_Float(tmps, "posFX");
  68.     pos[5] = dini_Float(tmps, "posFY");
  69.     pos[6] = dini_Float(tmps, "posFZ");
  70.     SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  71.     SetPlayerFacingAngle(playerid, pos[3]);
  72.     SetPlayerCheckpoint(playerid, pos[4], pos[5], pos[6], 1.5);
  73.     DarNadesVida(playerid);
  74.     //Iniciar contador
  75.    
  76.     timers[playerid] = SetTimerEx("TimeCount", 1000, 1, "d", playerid);
  77.     return 1;
  78. }
  79.  
  80. stock NextLevel(playerid)
  81. {
  82.     new lvl = nivelPark[playerid];
  83.     new tmps[64];
  84.     format(tmps, sizeof(tmps), "parkour/%d.txt", lvl);
  85.     if(!dini_Exists(tmps))
  86.     {
  87.         KillTimer(timers[playerid]);
  88.         format(str, sizeof(str), "You did it to the {00FF00}last{FFFFFF} level. Congratulations!");
  89.         Msg(playerid, -1, str);
  90.         format(str, sizeof(str), "{00FF00}%s{FFFFFF} completed all levels in Nade Parkour ({00FF00}%d{FFFF00}m:{00FF00}%d{FFFF00}s - {00FF00}%d {FFFF00}attempts{FFFFFF})", GetPlayerN(playerid), contador[0][playerid], contador[1][playerid], tentsPark[playerid]);
  91.        
  92.         contador[0][playerid] = 0;
  93.         contador[1][playerid] = 0;
  94.         return MsgAll(-1, str);
  95.     }
  96.     format(str, sizeof(str), "You are now in level {00FF00}%d{FFFFFF}!", lvl);
  97.     Msg(playerid, -1, str);
  98.     new Float:pos[7];
  99.     pos[0] = dini_Float(tmps, "posIX");
  100.     pos[1] = dini_Float(tmps, "posIY");
  101.     pos[2] = dini_Float(tmps, "posIZ");
  102.     pos[3] = dini_Float(tmps, "angI");
  103.     pos[4] = dini_Float(tmps, "posFX");
  104.     pos[5] = dini_Float(tmps, "posFY");
  105.     pos[6] = dini_Float(tmps, "posFZ");
  106.     SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  107.     SetPlayerFacingAngle(playerid, pos[3]);
  108.     SetPlayerCheckpoint(playerid, pos[4], pos[5], pos[6], 1.5);
  109.     DarNadesVida(playerid);
  110.     return 1;
  111. }
  112.  
  113. // * CMDS * //
  114. CMD:nade(playerid, params[])
  115. {
  116.     if(isPark[playerid] == false)
  117.     {
  118.         isPark[playerid] = true;
  119.         format(str, sizeof(str), "{00FF00}%s{FFFFFF} entered the Nade Parkour ({00FF00}/nade{FFFFFF})", GetPlayerN(playerid));
  120.         MsgAll(-1, str);
  121.         format(str, sizeof(str), "Use {00FF00}/try{FFFFFF} to repeat the level if you fell!");
  122.         Msg(playerid, -1, str);
  123.         format(str, sizeof(str), "Use {00FF00}/exitnade{FFFFFF} to leave the Nade Parkour!");
  124.         Msg(playerid, -1, str);
  125.     }
  126.     else return Msg(playerid, -1, "You are already in the Nade Parkour!");
  127.    
  128.     FirstLevel(playerid);
  129.     return 1;
  130. }
  131.  
  132. CMD:exitnade(playerid, params[])
  133. {
  134.     if(isPark[playerid] == true)
  135.     {
  136.         KillTimer(timers[playerid]);
  137.         contador[1][playerid] = 0;
  138.         contador[0][playerid] = 0;
  139.         pFirstL[playerid] = 0;
  140.         TextDrawHideForPlayer(playerid, tempo[playerid]);
  141.  
  142.         SetPlayerHealth(playerid, 0);
  143.         isPark[playerid] = false;
  144.         nivelPark[playerid] = 1;
  145.         tentsPark[playerid] = 0;
  146.         format(str, sizeof(str), "{00FF00}%s{FFFFFF} left the Nade Parkour ({00FF00}/nade{FFFFFF})", GetPlayerN(playerid));
  147.         MsgAll(-1, str);
  148.     }
  149.     return 1;
  150. }
  151.  
  152. CMD:try(playerid, params[])
  153. {
  154.     if(isPark[playerid] == true)
  155.     {
  156.         new lvl = nivelPark[playerid];
  157.         new tmps[64];
  158.         format(tmps, sizeof(tmps), "parkour/%d.txt", lvl);
  159.         new Float:pos[7];
  160.         pos[0] = dini_Float(tmps, "posIX");
  161.         pos[1] = dini_Float(tmps, "posIY");
  162.         pos[2] = dini_Float(tmps, "posIZ");
  163.         pos[3] = dini_Float(tmps, "angI");
  164.         pos[4] = dini_Float(tmps, "posFX");
  165.         pos[5] = dini_Float(tmps, "posFY");
  166.         pos[6] = dini_Float(tmps, "posFZ");
  167.         SetPlayerPos(playerid, pos[0], pos[1], pos[2]);
  168.         SetPlayerFacingAngle(playerid, pos[3]);
  169.         SetPlayerCheckpoint(playerid, pos[4], pos[5], pos[6], 1.5);
  170.         DarNadesVida(playerid);
  171.         tentsPark[playerid]++;
  172.     }
  173.     return 1;
  174. }
  175.  
  176. // * FUNCS * //
  177. forward TimeCount(playerid);
  178. public TimeCount(playerid)
  179. {
  180.     contador[1][playerid]++;
  181.     if (contador[1][playerid] == 60)
  182.     {
  183.         contador[1][playerid] = 0;
  184.         contador[0][playerid]++;
  185.     }
  186.  
  187.     new string[36];
  188.     format(string, sizeof(string), "~y~~w~%d~r~m~w~ :%d~r~s", contador[0][playerid], contador[1][playerid]);
  189.     if(pFirstL[playerid] == 1)
  190.     {
  191.         pFirstL[playerid] = 0;
  192.         TextDrawSetString(tempo[playerid], string);
  193.         TextDrawShowForPlayer(playerid, tempo[playerid]);
  194.     }
  195.     else    return TextDrawSetString(tempo[playerid], string);
  196.     return 1;
  197. }
  198.  
  199. public OnFilterScriptInit()
  200. {
  201.     print("\n--------------------------------------");
  202.     print("    Nade Parkouring v1.2 by Badjouras");
  203.     print("--------------------------------------\n");
  204.     return 1;
  205. }
  206.  
  207. public OnFilterScriptExit()
  208. {
  209.     return 1;
  210. }
  211.  
  212. public OnPlayerConnect(playerid)
  213. {
  214.     pFirstL[playerid] = 1;
  215.     isPark[playerid] = false;
  216.     nivelPark[playerid] = 1;
  217.     tentsPark[playerid] = 0;
  218.     contador[0][playerid] = 0;
  219.     contador[1][playerid] = 0;
  220.     tempo[playerid] = TextDrawCreate(490 ,396 , "123");
  221.     TextDrawFont(tempo[playerid] , 1);
  222.     TextDrawLetterSize(tempo[playerid] , 0.6, 2);
  223.     TextDrawColor(tempo[playerid] , 0x000000FF);
  224.     TextDrawSetOutline(tempo[playerid] , false);
  225.     TextDrawSetProportional(tempo[playerid] , false);
  226.     TextDrawHideForPlayer(playerid, tempo[playerid]);
  227.     return 1;
  228. }
  229.  
  230. public OnPlayerDisconnect(playerid, reason)
  231. {
  232.     pFirstL[playerid] = 1;
  233.     isPark[playerid] = false;
  234.     nivelPark[playerid] = 1;
  235.     tentsPark[playerid] = 0;
  236.     contador[0][playerid] = 0;
  237.     contador[1][playerid] = 0;
  238.     KillTimer(timers[playerid]);
  239.     TextDrawDestroy(tempo[playerid]);
  240.     return 1;
  241. }
  242.  
  243. public OnPlayerEnterCheckpoint(playerid)
  244. {
  245.     if(isPark[playerid] == false) return 1;
  246.     DisablePlayerCheckpoint(playerid);
  247.     PlayerPlaySound(playerid, 17802, 0, 0, 0);
  248.     nivelPark[playerid]++;
  249.     NextLevel(playerid);
  250.     return 1;
  251. }
Advertisement
Add Comment
Please, Sign In to add comment