whiplk

[FS] - TruckingJob

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