Advertisement
cesar_google

Trabalho de caminhoneiro 0.1x RC 2

Sep 15th, 2013
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 14.45 KB | None | 0 0
  1. /*
  2.     Trabalho de caminhoneiro
  3.     By Parka
  4.     Desenvolvido 03:19 a.m. 19/07/2013
  5.     Versão: 0.1x RC 2 -    Desenvolvido 03:19 a.m. 15/09/2013
  6.  
  7.  
  8.                                Introdução
  9.  
  10. O presente trabalho, é um sistema Trabalho de caminhoneiro você pode criar suas
  11. próprias posições de carregamento e descarregamento automaticamente armazenados
  12. na scriptfiles/Trucking/Locations para quando você tem a necessidade de reiniciar
  13. seu servidor, não perderá os locais, tem também a nome carga e nome do alvo graças
  14. a Include a_zones.
  15.  
  16.                               Desenvolvimento
  17.  
  18. /Carregar :
  19. Para começar a trabalhar.
  20.  
  21. /tutolc:
  22. Para os administradores sabem como usar /createlc.
  23.  
  24. /createlc <Player> :
  25. Usar /createlc para criar a Localidade onde o jogador carregar o trailer.
  26. Sua posição: é onde carregar o trailer.
  27. Player posição: é onde descer o trailer.
  28.  
  29. Neste sistema, o reboques são divididos em três tipos de cargas, Exigir nível
  30. necessário para realizar.
  31.  
  32. 1- Easy
  33. 2-Medium 4-6
  34. 3-Hard   7 >
  35.  
  36. caminhoneiro:
  37. A restrição é baseada na pele, deve colocar a skin do caminhoneiro na segue variable:
  38. SkinTruckDriver[4]
  39. e onde está localizada a quatro adicioná mais.
  40.  
  41. */
  42. #include    < a_samp  >// SAMP-TEAM
  43. #include    < sscanf2 >// Y_Less
  44. #include    < A_ZONES >// By ~Cueball~
  45. #include    < ZCMD    >// Zeex
  46. #include    < DOF2    >// Double-o-Seven
  47.  
  48. #define Locations_Save    "Trucking/Locations/%d.txt"
  49. #define Save_ID           "Trucking/Quantidade.txt"
  50.  
  51. #undef MAX_PLAYERS
  52. #define MAX_PLAYERS 100
  53.  
  54. new p_Get_Quantidade;
  55. new p_Quantidade;
  56. new p_ForID;
  57. new p_JopStatus[MAX_PLAYERS];
  58. new bool:p_Jop[MAX_PLAYERS];
  59.  
  60. new Float:p_OldPos[MAX_PLAYERS][3];
  61.  
  62. enum p_LAU
  63. {
  64. Float:Carregar_Posx,
  65. Float:Carregar_Posy,
  66. Float:Carregar_Posz,
  67. Float:Baixar_Posx,
  68. Float:Baixar_Posy,
  69. Float:Baixar_Posz
  70. }
  71. new LoadAndUnload[][p_LAU];
  72.  
  73. new SkinTruckDriver[4] =// adicionar a pele do seu GM (de Truck Driver)
  74. {
  75. 133,
  76. 202,
  77. 206,
  78. 261
  79. };
  80. //                  ========[Trucking Job By Parka]========                   //
  81. forward p_StopWork_LostTrailer( playerid );
  82. public p_StopWork_LostTrailer( playerid )
  83. {
  84.     DisablePlayerCheckpoint(playerid);
  85.     SendClientMessage(playerid, 0xFF0000AA, "Você perdido o Trailer, descontado -$1000.");
  86.     SendClientMessage(playerid, 0xFF0000AA, "Você está demitido.");
  87.     GivePlayerMoney(playerid, -1000);
  88.     p_JopStatus[playerid] = 0;
  89.     p_Jop[ playerid ] = false;
  90.     return 1;
  91. }
  92. //                  ========[Trucking Job By Parka]========                   //
  93. forward p_StopWork( playerid );
  94. public p_StopWork( playerid )
  95. {
  96.     DisablePlayerCheckpoint(playerid);
  97.     SendClientMessage(playerid, 0xFF0000AA, "Você escapou de seu trabalho é descontado -$1000");
  98.     GivePlayerMoney(playerid, -1000);
  99.     p_JopStatus[playerid] = 0;
  100.     p_Jop[ playerid ] = false;
  101.     return 1;
  102. }
  103. //                  ========[Trucking Job By Parka]========                   //
  104. forward p_LoadAndUnload( playerid );
  105. public p_LoadAndUnload( playerid )
  106. {
  107.     new v = GetPlayerVehicleID(playerid);
  108.     new p_All, p_Pay, Float:p_THealth, Float:p_CHealth, string[256];
  109.     GetVehicleHealth(v, p_CHealth);
  110.     GetVehicleHealth(GetVehicleTrailer(v),p_THealth);
  111.  
  112.     switch(p_JopStatus[ playerid ])
  113.     {
  114.         case 1:
  115.         {
  116.             DisablePlayerCheckpoint( playerid );
  117.             SetPlayerCheckpoint( playerid, p_OldPos[ playerid ][ 0 ], p_OldPos[ playerid ][ 1 ], p_OldPos[ playerid ][ 2 ], 7);
  118.             SendClientMessage( playerid, 0xFFFF00AA, "Caminhão carregado referem-se a e ponto de descarga");
  119.             TogglePlayerControllable( playerid , true );
  120.             p_JopStatus[ playerid ] = 2;
  121.         }
  122.         case 2:
  123.         {
  124.             switch(GetVehicleModel(GetVehicleTrailer(v)))
  125.             {
  126.             case 450://Easy   Level 1 a 3
  127.             {
  128.             p_All = floatround(p_CHealth) + floatround(p_THealth);
  129.             p_Pay = p_All * 2;
  130.             format( string, sizeof string,
  131.             "{00ff00}[!]==========[Detalhes do pagamento]==========[!]\n\
  132.             {00ff00}Danos do Trailer: %d\n\
  133.             {00ff00}Danos do Camion: %d\n\
  134.             {00ff00}Total a pagar: %d", floatround(p_THealth), floatround(p_CHealth), p_Pay);
  135.             ShowPlayerDialog( playerid, 0x00100, DIALOG_STYLE_MSGBOX,"[Detalhes do pagamento]", string, "Aceptar", "");
  136.             GivePlayerMoney( playerid , p_Pay );
  137.             TogglePlayerControllable( playerid , true );
  138.             p_JopStatus[ playerid ] = 2;
  139.             p_Jop      [ playerid ] = true;
  140.             }
  141.             case 435,591://Medium Level 4 a 6
  142.             {
  143.             p_All = floatround(p_CHealth) + floatround(p_THealth);
  144.             p_Pay = p_All * 3;
  145.             format( string, sizeof string,
  146.             "{00ff00}[!]==========[Detalhes do pagamento]==========[!]\n\
  147.             {00ff00}Danos do Trailer: %d\n\
  148.             {00ff00}Danos do Camion: %d\n\
  149.             {00ff00}Total a pagar: %d", floatround(p_THealth), floatround(p_CHealth), p_Pay);
  150.             ShowPlayerDialog( playerid, 0x00100, DIALOG_STYLE_MSGBOX,"[Detalhes do pagamento]", string, "Aceptar", "");
  151.             GivePlayerMoney( playerid , p_Pay );
  152.             TogglePlayerControllable( playerid , true );
  153.             p_JopStatus[ playerid ] = 2;
  154.             p_Jop      [ playerid ] = true;
  155.             }
  156.             case 584://Hard   Level 7 a 9
  157.             {
  158.             p_All = floatround(p_CHealth) + floatround(p_THealth);
  159.             p_Pay = p_All * 4;
  160.             format( string, sizeof string,
  161.             "{00ff00}[!]==========[Detalhes do pagamento]==========[!]\n\
  162.             {00ff00}Danos do Trailer: %d\n\
  163.             {00ff00}Danos do Camion: %d\n\
  164.             {00ff00}Total a pagar: %d", floatround(p_THealth), floatround(p_CHealth), p_Pay);
  165.             ShowPlayerDialog( playerid, 0x00100, DIALOG_STYLE_MSGBOX,"[Detalhes do pagamento]", string, "Aceptar", "");
  166.             GivePlayerMoney( playerid , p_Pay );
  167.             TogglePlayerControllable( playerid , true );
  168.             p_JopStatus[ playerid ] = 2;
  169.             p_Jop      [ playerid ] = true;
  170.             }
  171.             }
  172.         }
  173.     }
  174.     return 1;
  175. }
  176. //                  ========[Trucking Job By Parka]========                   //
  177. forward GetTruckDriver( playerid );
  178. public GetTruckDriver( playerid )
  179. {
  180.     for(new i; i < sizeof SkinTruckDriver; i++)
  181.     {
  182.     if( GetPlayerSkin(playerid) == SkinTruckDriver[i])
  183.     {
  184.  
  185.     return 1;
  186.     }
  187.     }
  188.     return 0;
  189. }
  190. //                  ========[Trucking Job By Parka]========                   //
  191. forward PosForID();
  192. public PosForID()
  193. {
  194.     if(DOF2_FileExists( Save_ID ) )
  195.     {
  196.     p_Quantidade = DOF2_GetInt( Save_ID , "Quantidade" ) + 1;
  197.     DOF2_SetInt( Save_ID , "Quantidade" , p_Quantidade );
  198.     DOF2_SaveFile();
  199.     }
  200.     return p_Quantidade;
  201. }
  202. //                  ========[Trucking Job By Parka]========                   //
  203. forward PlayerStartWork( playerid );
  204. public PlayerStartWork( playerid )
  205. {
  206.     new v = GetPlayerVehicleID(playerid);
  207.     if(GetVehicleModel(v)==403||GetVehicleModel(v)==515||GetVehicleModel(v)==514)
  208.     {
  209.         if(IsTrailerAttachedToVehicle(v))
  210.         {
  211.             switch(GetVehicleModel(GetVehicleTrailer(v)))
  212.             {
  213.             case 450://Easy   Level 1 a 3
  214.             {
  215.             SetPosDestination( playerid );
  216.             }
  217.             case 435,591://Medium Level 4 a 6
  218.             {
  219.             if(GetPlayerScore(playerid) <= 3) return SendClientMessage( playerid, 0xFF0000AA, "Deve ser Nível 4 para transportar carga de mídia");
  220.             SetPosDestination( playerid );
  221.             }
  222.             case 584://Hard   Level 7 a 9
  223.             {
  224.             if(GetPlayerScore(playerid) <= 6) return SendClientMessage( playerid, 0xFF0000AA, "Deve ser Nível 7 para transportar carga de pesado");
  225.             SetPosDestination( playerid );
  226.             }
  227.             }
  228.         }else return SendClientMessage( playerid, 0xFF0000AA, "Você não tem um trailer viciado");
  229.     }
  230.     else return SendClientMessage( playerid, 0xFF0000AA, "Você deve estar dentro de um caminhão");
  231.     return true;
  232. }
  233. //                  ========[Trucking Job By Parka]========                   //
  234. forward SetPosDestination( playerid );
  235. public SetPosDestination( playerid )
  236. {
  237.     if(DOF2_FileExists( Save_ID ) ){
  238.     p_Get_Quantidade = DOF2_GetInt( Save_ID , "Quantidade");
  239.     }
  240.  
  241.     new p_random = random(p_Get_Quantidade);
  242.     new Float:p_LastPos[MAX_PLAYERS][3];
  243.  
  244.     new string[32];
  245.     format( string, sizeof string, Locations_Save, p_random);
  246.  
  247.     if( !DOF2_FileExists( string ) )
  248.         return SendClientMessage( playerid, 0xFF0000AA, "Isso nunca deveria aparecer");
  249.  
  250.     LoadAndUnload[ p_random ][ Carregar_Posx] = DOF2_GetFloat(  string, "Carregar_X");
  251.     LoadAndUnload[ p_random ][ Carregar_Posy] = DOF2_GetFloat(  string, "Carregar_Y");
  252.     LoadAndUnload[ p_random ][ Carregar_Posz] = DOF2_GetFloat(  string, "Carregar_Z");
  253.     LoadAndUnload[ p_random ][ Baixar_Posx] = DOF2_GetFloat (   string, "Baixar_X"  );
  254.     LoadAndUnload[ p_random ][ Baixar_Posy] = DOF2_GetFloat (   string, "Baixar_Y"  );
  255.     LoadAndUnload[ p_random ][ Baixar_Posz] = DOF2_GetFloat (   string, "Baixar_Z"  );
  256.  
  257.     p_LastPos[ playerid ][ 0 ] = LoadAndUnload[ p_random ][ Carregar_Posx ];
  258.     p_LastPos[ playerid ][ 1 ] = LoadAndUnload[ p_random ][ Carregar_Posy ];
  259.     p_LastPos[ playerid ][ 2 ] = LoadAndUnload[ p_random ][ Carregar_Posz ];
  260.  
  261.     p_OldPos[ playerid ][ 0 ] = LoadAndUnload[ p_random ][ Baixar_Posx ];
  262.     p_OldPos[ playerid ][ 1 ] = LoadAndUnload[ p_random ][ Baixar_Posy ];
  263.     p_OldPos[ playerid ][ 2 ] = LoadAndUnload[ p_random ][ Baixar_Posz ];
  264.  
  265.     SetPlayerCheckpoint(playerid, p_LastPos[ playerid ][ 0 ], p_LastPos[ playerid ][ 1 ], p_LastPos[ playerid ][ 2 ], 7);
  266.  
  267.     new StrIng_Text[256];
  268.     format( StrIng_Text, sizeof StrIng_Text, "%s", DOF2_GetString( string, "Localidade"));
  269.     SendClientMessage( playerid, 0x00FF00AA, StrIng_Text);
  270.  
  271.     p_JopStatus[ playerid ] = 1;
  272.     p_Jop      [ playerid ] = true;
  273.  
  274.     return 1;
  275. }
  276. //                  ========[Trucking Job By Parka]========                   //
  277. forward SaveLocations( LocationName[], Float:Carregar_x, Float:Carregar_y, Float:Carregar_z, Float:Baixar_x, Float:Baixar_y, Float:Baixar_z );
  278. public SaveLocations( LocationName[], Float:Carregar_x, Float:Carregar_y, Float:Carregar_z, Float:Baixar_x, Float:Baixar_y, Float:Baixar_z )
  279. {
  280.     if(!DOF2_FileExists(TKSave()))
  281.     {
  282.     DOF2_CreateFile (   TKSave());
  283.     DOF2_SetString  (   TKSave(),   "Localidade",   LocationName);
  284.     DOF2_SetFloat   (   TKSave(),   "Carregar_X",   Carregar_x  );
  285.     DOF2_SetFloat   (   TKSave(),   "Carregar_Y",   Carregar_y  );
  286.     DOF2_SetFloat   (   TKSave(),   "Carregar_Z",   Carregar_z  );
  287.     DOF2_SetFloat   (   TKSave(),   "Baixar_X"  ,   Baixar_x    );
  288.     DOF2_SetFloat   (   TKSave(),   "Baixar_Y"  ,   Baixar_y    );
  289.     DOF2_SetFloat   (   TKSave(),   "Baixar_Z"  ,   Baixar_z    );
  290.     DOF2_SaveFile();
  291.     }
  292.     return 1;
  293. }
  294. //                  ========[Trucking Job By Parka]========                   //
  295. stock TKSave()
  296. {
  297.     new string[32];
  298.     format( string, sizeof string, Locations_Save, p_ForID);
  299.     return string;
  300. }
  301. //                  ========[Trucking Job By Parka]========                   //
  302. CMD:createlc(playerid,params[])
  303. {
  304.     if( !IsPlayerAdmin( playerid ) ) return SendClientMessage( playerid, 0xFF0000AA, "Você não é administrador /RCON");
  305.     new Target;
  306.     if( sscanf( params, "d", Target) ) return SendClientMessage( playerid, 0xFF0000AA, "Use: '/createlc <Player>' ajuda = (/tutolc)");
  307.  
  308.     if( !IsPlayerConnected(Target) || Target == INVALID_PLAYER_ID ) return SendClientMessage( playerid, 0xFF0000AA, "Jogador não conectado");
  309.     //if( Target == playerid ) return SendClientMessage( playerid, 0xFF0000AA, "Você não pode ser você mesmo");
  310.  
  311.     new Float:TargetPos[3];
  312.     new Float:PlayerPos[3];
  313.  
  314.     GetPlayerPos( playerid, PlayerPos[0], PlayerPos[1], PlayerPos[2]);
  315.     GetPlayerPos( Target,   TargetPos[0], TargetPos[1], TargetPos[2]);
  316.  
  317.     p_ForID = PosForID();
  318.  
  319.     new Zone_Target[32];
  320.     new Zone_Player[32];
  321.  
  322.     GetPlayer3DZone( Target,   Zone_Target, 32);
  323.     GetPlayer3DZone( playerid, Zone_Player, 32);
  324.  
  325.     new Str_Ing[256];
  326.     format( Str_Ing, sizeof Str_Ing, "Trabalhar: Carregar em %s e Transportar a %s", Zone_Player, Zone_Target);
  327.     SaveLocations( Str_Ing, PlayerPos[0], PlayerPos[1], PlayerPos[2], TargetPos[0], TargetPos[1], TargetPos[2] );
  328.     SendClientMessage( playerid, 0x00FF00AA, "a Localidade foi salva satisfatoriamente");
  329.     SendClientMessage( Target, 0x00FF00AA, "a Localidade foi salva satisfatoriamente");
  330.     return 1;
  331. }
  332. //                  ========[Trucking Job By Parka]========                   //
  333. CMD:tutolc(playerid,params[])
  334. {
  335.     SendClientMessage( playerid, 0xFFFF00AA, "Usar /createlc para criar a Localidade onde o jogador carregar o trailer.");
  336.     SendClientMessage( playerid, 0xFFFF00AA, "Sua posição: é onde carregar o trailer.");
  337.     SendClientMessage( playerid, 0xFFFF00AA, "Player posição: é onde descer o trailer.");
  338.     return 1;
  339. }
  340. //                  ========[Trucking Job By Parka]========                   //
  341. CMD:carregar(playerid,params[])
  342. {
  343.     SetPlayerScore(playerid, 4);
  344.     if( IsPlayerConnected( playerid ) )
  345.     {
  346.         if( p_Jop[ playerid ] == false )
  347.         {
  348.             if(GetTruckDriver(playerid))
  349.             {
  350.                 PlayerStartWork( playerid );
  351.             }
  352.             else return SendClientMessage( playerid, 0xFF0000AA, "Você não é truck driver.");
  353.         }
  354.         else return SendClientMessage( playerid, 0xFF0000AA, "Você já está trabalhando.");
  355.     }
  356.     return 1;
  357. }
  358. //                  ========[Trucking Job By Parka]========                   //
  359. public OnFilterScriptInit()
  360. {
  361.     if(!DOF2_FileExists( Save_ID ) )
  362.     {
  363.     DOF2_CreateFile( Save_ID );
  364.     DOF2_SetInt( Save_ID , "Quantidade" , -1);
  365.     DOF2_SaveFile();
  366.     }
  367.     return 1;
  368. }
  369. //                  ========[Trucking Job By Parka]========                   //
  370. public OnFilterScriptExit()
  371. {
  372.     DOF2_Exit();
  373.     return 1;
  374. }
  375. //                  ========[Trucking Job By Parka]========                   //
  376. public OnPlayerConnect(playerid)
  377. {
  378.     p_Jop      [ playerid ] = false;
  379.     p_JopStatus[ playerid ] = 0;
  380.  
  381.     return 1;
  382. }
  383. //                  ========[Trucking Job By Parka]========                   //
  384. public OnPlayerEnterCheckpoint(playerid)
  385. {
  386.     if( IsPlayerConnected( playerid ) )
  387.     {
  388.         switch(p_JopStatus[ playerid ])
  389.         {
  390.             case 1:
  391.             {
  392.                 GameTextForPlayer( playerid, "~y~~h~Carregar os produtos~n~~p~Espere por favor..", 10000, 1);
  393.                 TogglePlayerControllable( playerid, false);
  394.                 SetTimerEx("p_LoadAndUnload", 10000, false, "d", playerid);
  395.             }
  396.             case 2:
  397.             {
  398.                 GameTextForPlayer( playerid, "~g~~h~Baixando os produtos~n~~p~Espere por favor..", 10000, 1);
  399.                 TogglePlayerControllable( playerid, false);
  400.                 SetTimerEx("p_LoadAndUnload", 10000, false, "d", playerid);
  401.             }
  402.         }
  403.     }
  404.     return 1;
  405. }
  406. //                  ========[Trucking Job By Parka]========                   //
  407. public OnPlayerLeaveCheckpoint(playerid)
  408. {
  409.     if( IsPlayerConnected( playerid ) )
  410.     {
  411.     DisablePlayerCheckpoint(playerid);
  412.     }
  413.     return 1;
  414. }
  415. //                  ========[Trucking Job By Parka]========                   //
  416. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  417. {
  418.     new v = GetPlayerVehicleID(playerid);
  419.     if(!IsTrailerAttachedToVehicle(v) && p_JopStatus[ playerid ] >= 1)
  420.     {
  421.         p_StopWork_LostTrailer(playerid);
  422.     }
  423.     return 1;
  424. }
  425. /*
  426.                              Trucking Job
  427.                                By Parka
  428.                     Desenvolvido 03:19 a.m. 19/07/2013
  429.                           Versão: 0.1a[BETA]
  430. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement