Advertisement
Julian90

InGame PickUp Creator v0.5.

Sep 21st, 2011
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 18.73 KB | None | 0 0
  1. /*
  2.            - [InGame]: PickUp Creator ( v0.5 ).
  3.              - Script: [J]ulián.
  4.              - Idea: Nicolás Harrinston.
  5.              - Tiempo de Trabajo: 7hs.
  6.          ---------------------------------
  7.          @  Si no te gusta que te roben  @
  8.          @ no robés créditos vos tampoco @
  9.          ---------------------------------
  10. */
  11.  
  12. main(){}
  13. #include <a_samp>
  14.  
  15. #define MAX_PICKUP                          50
  16. #define COLOR_MSG                           0xFF0000
  17.  
  18. #define DIALOG_PICKUP_ACCION                499
  19. #define DIALOG_PICKUP_SENDMENSSAGE          500
  20. #define DIALOG_PICKUP_PLAYERHEALTH          501
  21. #define DIALOG_PICKUP_PLAYERARMOUR          502
  22. #define DIALOG_PICKUP_POS_X                 503
  23. #define DIALOG_PICKUP_POS_Y                 504
  24. #define DIALOG_PICKUP_POS_Z                 505
  25. #define DIALOG_PICKUP_WEA_ID                506
  26. #define DIALOG_PICKUP_WEA_MUN               507
  27. #define DIALOG_PICKUP_MODELO                508
  28. #define DIALOG_PICKUP_TIPO                  509
  29.  
  30. enum iPick
  31. {
  32.     pick,
  33.     accion,
  34.     accionar[128],
  35.     modelo,
  36.     tipo,
  37.     Float:pos_x,
  38.     Float:pos_y,
  39.     Float:pos_z,
  40.     mundo,
  41. };
  42. new InfoPickUp[MAX_PICKUP][iPick];
  43. static  File:archivo, str[128], cargador[8][128], id, temp_x[15], temp_y[15];
  44.  
  45. public OnFilterScriptInit()
  46. {
  47.     if(!fexist("pickup.cfg"))
  48.     {
  49.         archivo = fopen("pickup.cfg", io_write);
  50.         fclose(archivo);
  51.         printf("** File: pickup.cfg fue creado con éxito. **");
  52.     }
  53.     else if(fexist("pickup.cfg"))
  54.     {
  55.         archivo = fopen("pickup.cfg", io_read);
  56.         if(archivo)
  57.         {
  58.             id = 0;
  59.             while(fread(archivo, str))
  60.             {
  61.                 if(id < MAX_PICKUP)
  62.                 {
  63.                     if(strlen(str) > 1) printf("[PICKUP(%d)]: %s", id, str);
  64.                     split(str, cargador);
  65.                     InfoPickUp[id][pick] = CreatePickup(strval(cargador[2]), strval(cargador[3]), floatstr(cargador[4]), floatstr(cargador[5]), floatstr(cargador[6]), strval(cargador[7]));
  66.                     InfoPickUp[id][accion] = strval(cargador[0]);
  67.                     strmid(InfoPickUp[id][accionar], cargador[1], 0, strlen(cargador[1]), sizeof(InfoPickUp));
  68.                     id++;
  69.                 }
  70.             }
  71.         }
  72.         fclose(archivo);
  73.     }
  74.     return 1;
  75. }
  76.  
  77. public OnFilterScriptExit()
  78. {
  79.     new p1;
  80.     for(new p = 0; p < MAX_PICKUP; p++)
  81.     {
  82.         if(InfoPickUp[p][pick] != 0) DestroyPickup(InfoPickUp[p][pick]), p1 = p;
  83.     }
  84.     printf("[PICKUP]: Se han eliminado %d pickups.", p1+1);
  85.     return 1;
  86. }
  87.  
  88. public OnPlayerCommandText(playerid, cmdtext[])
  89. {
  90.     new cmd[256], idx;
  91.     cmd = strtok(cmdtext, idx);
  92.     if(!strcmp(cmd, "/pickup", true))
  93.     {
  94.         if(!IsPlayerAdmin(playerid))
  95.         {
  96.             SendClientMessage(playerid, COLOR_MSG, "* Sólo administradores 'rcon' están autorizados a utilizar este comando.");
  97.             return 1;
  98.         }
  99.         cmd = strtok(cmdtext, idx);
  100.         if(!strlen(cmd))
  101.         {
  102.             SendClientMessage(playerid, COLOR_MSG, "Utilizá: /pickup [opcion(crear-recargar-eliminar)]");
  103.             return 1;
  104.         }
  105.         if(!strcmp(cmd, "crear", true))
  106.         {
  107.             if(InfoPickUp[MAX_PICKUP-1][pick] != 0)
  108.             {
  109.                 SendClientMessage(playerid, COLOR_MSG, "* Has superado el límite de pickups a crear.");
  110.                 return 1;
  111.             }
  112.             ShowPlayerDialog(playerid, DIALOG_PICKUP_ACCION, DIALOG_STYLE_LIST, "Seleccioná la Acción", "1. SendClientMessage.\n2. SetPlayerHealth.\n3. SetPlayerArmour.\n4. SetPlayerPos.\n5. GivePlayerWeapon.", "Continuar", "Salir");
  113.             return 1;
  114.         }
  115.         else if(!strcmp(cmd, "eliminar", true))
  116.         {
  117.             SendClientMessage(playerid, COLOR_MSG, "* Esta opción no está aún disponible.");
  118.             return 1;
  119.         }
  120.         else if(!strcmp(cmd, "recargar", true))
  121.         {
  122.             for(new p = 0; p < MAX_PICKUP; p++)
  123.             {
  124.                 DestroyPickup(InfoPickUp[p][pick]);
  125.             }
  126.             if(fexist("pickup.cfg"))
  127.             {
  128.                 archivo = fopen("pickup.cfg", io_read);
  129.                 if(archivo)
  130.                 {
  131.                     id = 0;
  132.                     while(fread(archivo, str))
  133.                     {
  134.                         if(id < MAX_PICKUP)
  135.                         {
  136.                             if(strlen(str) > 1) printf("[RE-PICKUP(%d)]: %s", id, str);
  137.                             split(str, cargador);
  138.                             InfoPickUp[id][pick] = CreatePickup(strval(cargador[2]), strval(cargador[3]), floatstr(cargador[4]), floatstr(cargador[5]), floatstr(cargador[6]), strval(cargador[7]));
  139.                             InfoPickUp[id][accion] = strval(cargador[0]);
  140.                             strmid(InfoPickUp[id][accionar], cargador[1], 0, strlen(cargador[1]), sizeof(InfoPickUp));
  141.                             id++;
  142.                         }
  143.                     }
  144.                 }
  145.                 fclose(archivo);
  146.             }
  147.             SendClientMessage(playerid, COLOR_MSG, "* Has recargado la lista de pickups.");
  148.             return 1;
  149.         }
  150.         return 1;
  151.     }
  152.     return 0;
  153. }
  154.  
  155.  
  156. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  157. {
  158.     switch(dialogid)
  159.     {
  160.         case DIALOG_PICKUP_ACCION:
  161.         {
  162.             if(response)
  163.             {
  164.                 id = id+1;
  165.                 switch(listitem)
  166.                 {
  167.                     case 0:
  168.                     {
  169.                         InfoPickUp[id][accion] = 0;
  170.                         ShowPlayerDialog(playerid, DIALOG_PICKUP_SENDMENSSAGE, DIALOG_STYLE_INPUT, "SendClientMessage", "Ingrese el texto que desea que muestre el pickup:\n", "Continuar", "Salir");
  171.                         return 1;
  172.                     }
  173.                     case 1:
  174.                     {
  175.                         InfoPickUp[id][accion] = 1;
  176.                         ShowPlayerDialog(playerid, DIALOG_PICKUP_PLAYERHEALTH, DIALOG_STYLE_INPUT, "SetPlayerHealth", "Ingrese la cantidad de vida que desea que adicione el pickup:\n", "Continuar", "Salir");
  177.                         return 1;
  178.                     }
  179.                     case 2:
  180.                     {
  181.                         ShowPlayerDialog(playerid, DIALOG_PICKUP_PLAYERARMOUR, DIALOG_STYLE_INPUT, "SetPlayerArmour", "Ingrese la cantidad de chaleco que desea que adicione el pickup:\n", "Continuar", "Salir");
  182.                         InfoPickUp[id][accion] = 2;
  183.                         return 1;
  184.                     }
  185.                     case 3:
  186.                     {
  187.                         ShowPlayerDialog(playerid, DIALOG_PICKUP_POS_X, DIALOG_STYLE_INPUT, "SetPlayerPos ( x )", "Ingrese la coordenada del eje X que actualizará el pickup:\n", "Continuar", "Salir");
  188.                         InfoPickUp[id][accion] = 3;
  189.                         return 1;
  190.                     }
  191.                     case 4:
  192.                     {
  193.                         ShowPlayerDialog(playerid, DIALOG_PICKUP_WEA_ID, DIALOG_STYLE_INPUT, "GivePlayerWeapon", "Ingrese el id del arma que desea que proveerá el pickup:\n", "Continuar", "Salir");
  194.                         InfoPickUp[id][accion] = 4;
  195.                         return 1;
  196.                     }
  197.                 }
  198.             }
  199.             return 1;
  200.         }
  201.         case DIALOG_PICKUP_SENDMENSSAGE:
  202.         {
  203.             if(response)
  204.             {
  205.                 new leng = strlen(inputtext);
  206.                 for(new l = 0; l < leng; l++)
  207.                 {
  208.                     if(inputtext[l] == '|')
  209.                     {
  210.                         SendClientMessage(playerid, COLOR_MSG, "No puedes utilizar el caracter ' | ' en el mensaje.");
  211.                         return 1;
  212.                     }
  213.                 }
  214.                 if(!strlen(inputtext))
  215.                 {
  216.                     ShowPlayerDialog(playerid, DIALOG_PICKUP_SENDMENSSAGE, DIALOG_STYLE_INPUT, "SendClientMessage", "Ingrese el texto, obligatoriamente, que desea que muestre el pickup:\n", "Continuar", "Salir");
  217.                     return 1;
  218.                 }
  219.                 strmid(InfoPickUp[id][accionar], inputtext, 0, strlen(inputtext), sizeof(InfoPickUp));
  220.                 format(str, sizeof(str), "* Has establecido el texto a: \"%s\".", InfoPickUp[id][accionar]);
  221.                 SendClientMessage(playerid, COLOR_MSG, str);
  222.                 ShowPlayerDialog(playerid, DIALOG_PICKUP_MODELO, DIALOG_STYLE_LIST, "Creador de PickUps", "Maletin.\nDinero.\nInformación.\nCorazón.\nPíldora.\nChaleco.\nEstrella.\nLogo del GTA3.\nBomba Gris.\nCráneo.\nCráneo x2.\nCasa Azul.\nCasa Verde.\nDolar.\nCamiseta Azul.\nVice City.\nDiscket.\nDroga.\n2 Jugadores.\nFlecha Blanca.\nLibro de Rimas.", "Siguiente", "Salir");
  223.             }
  224.             return 1;
  225.         }
  226.         case DIALOG_PICKUP_PLAYERHEALTH:
  227.         {
  228.             if(response)
  229.             {
  230.                 if(!strlen(inputtext))
  231.                 {
  232.                     ShowPlayerDialog(playerid, DIALOG_PICKUP_PLAYERHEALTH, DIALOG_STYLE_INPUT, "SetPlayerHealth", "Ingrese la cantidad de vida, obligatoriamente, que desea que adicione el pickup:\n", "Continuar", "Salir");
  233.                     return 1;
  234.                 }
  235.                 strmid(InfoPickUp[id][accionar], inputtext, 0, strlen(inputtext), sizeof(InfoPickUp));
  236.                 format(str, sizeof(str), "* Has establecido el valor de la vida a: \"%s\".", InfoPickUp[id][accionar]);
  237.                 SendClientMessage(playerid, COLOR_MSG, str);
  238.                 ShowPlayerDialog(playerid, DIALOG_PICKUP_MODELO, DIALOG_STYLE_LIST, "Creador de PickUps", "Maletin.\nDinero.\nInformación.\nCorazón.\nPíldora.\nChaleco.\nEstrella.\nLogo del GTA3.\nBomba Gris.\nCráneo.\nCráneo x2.\nCasa Azul.\nCasa Verde.\nDolar.\nCamiseta Azul.\nVice City.\nDiscket.\nDroga.\n2 Jugadores.\nFlecha Blanca.\nLibro de Rimas.", "Siguiente", "Salir");
  239.             }
  240.             return 1;
  241.         }
  242.         case DIALOG_PICKUP_PLAYERARMOUR:
  243.         {
  244.             if(response)
  245.             {
  246.                 if(!strlen(inputtext))
  247.                 {
  248.                     ShowPlayerDialog(playerid, DIALOG_PICKUP_PLAYERARMOUR, DIALOG_STYLE_INPUT, "SetPlayerArmour", "Ingrese la cantidad de chaleco, obligatoriamente, que desea que adicione el pickup:\n", "Continuar", "Salir");
  249.                     return 1;
  250.                 }
  251.                 strmid(InfoPickUp[id][accionar], inputtext, 0, strlen(inputtext), sizeof(InfoPickUp));
  252.                 format(str, sizeof(str), "* Has establecido el valor de el chaleco a: \"%s\".", InfoPickUp[id][accionar]);
  253.                 SendClientMessage(playerid, COLOR_MSG, str);
  254.                 ShowPlayerDialog(playerid, DIALOG_PICKUP_MODELO, DIALOG_STYLE_LIST, "Creador de PickUps", "Maletin.\nDinero.\nInformación.\nCorazón.\nPíldora.\nChaleco.\nEstrella.\nLogo del GTA3.\nBomba Gris.\nCráneo.\nCráneo x2.\nCasa Azul.\nCasa Verde.\nDolar.\nCamiseta Azul.\nVice City.\nDiscket.\nDroga.\n2 Jugadores.\nFlecha Blanca.\nLibro de Rimas.", "Siguiente", "Salir");
  255.             }
  256.             return 1;
  257.         }
  258.         case DIALOG_PICKUP_POS_X:
  259.         {
  260.             if(response)
  261.             {
  262.                 if(!strlen(inputtext))
  263.                 {
  264.                     ShowPlayerDialog(playerid, DIALOG_PICKUP_POS_X, DIALOG_STYLE_INPUT, "SetPlayerPos ( x )", "Ingrese la coordenada del eje X, obligatoriamente, que actualizará el pickup:\n", "Continuar", "Salir");
  265.                     return 1;
  266.                 }
  267.                 format(temp_x, sizeof(temp_x), "%s", inputtext);
  268.                 format(str, sizeof(str), "* Has establecido la coordenada ( x ) del teleport a: \"%s\".", temp_x);
  269.                 SendClientMessage(playerid, COLOR_MSG, str);
  270.                 ShowPlayerDialog(playerid, DIALOG_PICKUP_POS_Y, DIALOG_STYLE_INPUT, "SetPlayerPos ( y )", "Ingrese la coordenada del eje Y que actualizará el pickup:\n", "Continuar", "Salir");
  271.             }
  272.             return 1;
  273.         }
  274.         case DIALOG_PICKUP_POS_Y:
  275.         {
  276.             if(response)
  277.             {
  278.                 if(!strlen(inputtext))
  279.                 {
  280.                     ShowPlayerDialog(playerid, DIALOG_PICKUP_POS_Y, DIALOG_STYLE_INPUT, "SetPlayerPos ( y )", "Ingrese la coordenada del eje Y, obligatoriamente, que actualizará el pickup:\n", "Continuar", "Salir");
  281.                     return 1;
  282.                 }
  283.                 format(temp_y, sizeof(temp_y), "%s", inputtext);
  284.                 format(str, sizeof(str), "* Has establecido la coordenada ( y ) del teleport a: \"%s\".", temp_y);
  285.                 SendClientMessage(playerid, COLOR_MSG, str);
  286.                 ShowPlayerDialog(playerid, DIALOG_PICKUP_POS_Z, DIALOG_STYLE_INPUT, "SetPlayerPos ( z )", "Ingrese la coordenada del eje Z que actualizará el pickup:\n", "Continuar", "Salir");
  287.             }
  288.             return 1;
  289.         }
  290.         case DIALOG_PICKUP_POS_Z:
  291.         {
  292.             if(response)
  293.             {
  294.                 if(!strlen(inputtext))
  295.                 {
  296.                     ShowPlayerDialog(playerid, DIALOG_PICKUP_POS_Z, DIALOG_STYLE_INPUT, "SetPlayerPos ( z )", "Ingrese la coordenada del eje Z, obligatoriamente, que actualizará el pickup:\n", "Continuar", "Salir");
  297.                     return 1;
  298.                 }
  299.                 new strito[50];
  300.                 format(strito, sizeof(strito), "%s,%s,%s", temp_x, temp_x, inputtext);
  301.                 strmid(InfoPickUp[id][accionar], strito, 0, strlen(strito), sizeof(InfoPickUp));
  302.                 format(str, sizeof(str), "* Has establecido la coordenada ( y ) del teleport a: \"%s\". ( teleport: %s. )", inputtext, InfoPickUp[id][accionar]);
  303.                 SendClientMessage(playerid, COLOR_MSG, str);
  304.                 ShowPlayerDialog(playerid, DIALOG_PICKUP_MODELO, DIALOG_STYLE_LIST, "Creador de PickUps", "Maletin.\nDinero.\nInformación.\nCorazón.\nPíldora.\nChaleco.\nEstrella.\nLogo del GTA3.\nBomba Gris.\nCráneo.\nCráneo x2.\nCasa Azul.\nCasa Verde.\nDolar.\nCamiseta Azul.\nVice City.\nDiscket.\nDroga.\n2 Jugadores.\nFlecha Blanca.\nLibro de Rimas.", "Siguiente", "Salir");
  305.             }
  306.             return 1;
  307.         }
  308.         case DIALOG_PICKUP_WEA_ID:
  309.         {
  310.             if(response)
  311.             {
  312.                 if(!strlen(inputtext))
  313.                 {
  314.                     ShowPlayerDialog(playerid, DIALOG_PICKUP_WEA_ID, DIALOG_STYLE_INPUT, "GivePlayerWeapon", "Ingrese el id del arma, obligatoriamente, que desea que regale el pickup:\n", "Continuar", "Salir");
  315.                     return 1;
  316.                 }
  317.                 format(temp_x, sizeof(temp_x), "%s", inputtext);
  318.                 format(str, sizeof(str), "* Has establecido el arma que proveerá este pickup a: \"%s\".", inputtext);
  319.                 SendClientMessage(playerid, COLOR_MSG, str);
  320.                 ShowPlayerDialog(playerid, DIALOG_PICKUP_WEA_MUN, DIALOG_STYLE_INPUT, "GivePlayerWeapon", "Ingrese la munisión del arma que proveerá el pickup:\n", "Continuar", "Salir");
  321.             }
  322.             return 1;
  323.         }
  324.         case DIALOG_PICKUP_WEA_MUN:
  325.         {
  326.             if(response)
  327.             {
  328.                 if(!strlen(inputtext))
  329.                 {
  330.                     ShowPlayerDialog(playerid, DIALOG_PICKUP_WEA_MUN, DIALOG_STYLE_INPUT, "GivePlayerWeapon", "Ingrese la munisión del arma, obligatoriamente, que proveerá el pickup:\n", "Continuar", "Salir");
  331.                     return 1;
  332.                 }
  333.                 new strito[50];
  334.                 format(strito, sizeof(strito), "%s,%s", temp_x, inputtext);
  335.                 format(str, sizeof(str), "* Has establecido la munisión que proveerá este pickup a: \"%s\".", inputtext);
  336.                 SendClientMessage(playerid, COLOR_MSG, str);
  337.                 strmid(InfoPickUp[id][accionar], strito, 0, strlen(strito), sizeof(InfoPickUp));
  338.                 ShowPlayerDialog(playerid, DIALOG_PICKUP_MODELO, DIALOG_STYLE_LIST, "Creador de PickUps", "Maletin.\nDinero.\nInformación.\nCorazón.\nPíldora.\nChaleco.\nEstrella.\nLogo del GTA3.\nBomba Gris.\nCráneo.\nCráneo x2.\nCasa Azul.\nCasa Verde.\nDolar.\nCamiseta Azul.\nVice City.\nDiscket.\nDroga.\n2 Jugadores.\nFlecha Blanca.\nLibro de Rimas.", "Siguiente", "Salir");
  339.             }
  340.             return 1;
  341.         }
  342.         case DIALOG_PICKUP_MODELO:
  343.         {
  344.             if(response)
  345.             {
  346.                 switch(listitem)
  347.                 {
  348.                     case  0: InfoPickUp[id][modelo] = 1210;
  349.                     case  1: InfoPickUp[id][modelo] = 1212;
  350.                     case  2: InfoPickUp[id][modelo] = 1239;
  351.                     case  3: InfoPickUp[id][modelo] = 1240;
  352.                     case  4: InfoPickUp[id][modelo] = 1241;
  353.                     case  5: InfoPickUp[id][modelo] = 1242;
  354.                     case  6: InfoPickUp[id][modelo] = 1247;
  355.                     case  7: InfoPickUp[id][modelo] = 1248;
  356.                     case  8: InfoPickUp[id][modelo] = 1252;
  357.                     case  9: InfoPickUp[id][modelo] = 1254;
  358.                     case 10: InfoPickUp[id][modelo] = 1313;
  359.                     case 11: InfoPickUp[id][modelo] = 1272;
  360.                     case 12: InfoPickUp[id][modelo] = 1273;
  361.                     case 13: InfoPickUp[id][modelo] = 1274;
  362.                     case 14: InfoPickUp[id][modelo] = 1275;
  363.                     case 15: InfoPickUp[id][modelo] = 1276;
  364.                     case 16: InfoPickUp[id][modelo] = 1277;
  365.                     case 17: InfoPickUp[id][modelo] = 1279;
  366.                     case 18: InfoPickUp[id][modelo] = 1314;
  367.                     case 19: InfoPickUp[id][modelo] = 1318;
  368.                     case 20: InfoPickUp[id][modelo] = 2894;
  369.                 }
  370.                 format(str, sizeof(str), "Has elegido el item número %i. ( modelo: %i )", listitem, InfoPickUp[id][modelo]);
  371.                 SendClientMessage(playerid, COLOR_MSG, str);
  372.                 ShowPlayerDialog(playerid, DIALOG_PICKUP_TIPO, DIALOG_STYLE_LIST, "Creador de PickUps", "El pickup no es visible.\nExiste todo el tiempo.\nReaparece luego de un tiempo.\nReaparece luego de morir.\nDesaparece un poco después de ser creado.\nNo tiene efecto, desaparece automáticamente.\nExplota un poco después de ser creado.\nDesciende poco a poco hacia el suelo\nSólo funciona en vehículo\nNo tiene efecto ( íconos de información ).", "Siguiente", "Salir");
  373.             }
  374.             return 1;
  375.         }
  376.         case DIALOG_PICKUP_TIPO:
  377.         {
  378.             if(response)
  379.             {
  380.                 switch(listitem)
  381.                 {
  382.                     case 0: InfoPickUp[id][tipo] =  0;
  383.                     case 1: InfoPickUp[id][tipo] =  1;
  384.                     case 2: InfoPickUp[id][tipo] =  2;
  385.                     case 3: InfoPickUp[id][tipo] =  3;
  386.                     case 4: InfoPickUp[id][tipo] =  4;
  387.                     case 5: InfoPickUp[id][tipo] =  5;
  388.                     case 6: InfoPickUp[id][tipo] = 11;
  389.                     case 7: InfoPickUp[id][tipo] = 13;
  390.                     case 8: InfoPickUp[id][tipo] = 14;
  391.                     case 9: InfoPickUp[id][tipo] = 19;
  392.                 }
  393.                 format(str, sizeof(str), "Has elegido el item número %i ( tipo: %i )", listitem, InfoPickUp[id][tipo]);
  394.                 SendClientMessage(playerid, COLOR_MSG, str);
  395.                 InfoPickUp[id][mundo] = GetPlayerVirtualWorld(playerid);
  396.                 GetPlayerPos(playerid, InfoPickUp[id][pos_x], InfoPickUp[id][pos_y], InfoPickUp[id][pos_z]);
  397.                 archivo = fopen("pickup.cfg", io_append);
  398.                 format(str, sizeof(str), "%i|%s|%i|%i|%f|%f|%f|%i\n",
  399.                 InfoPickUp[id][accion], InfoPickUp[id][accionar], InfoPickUp[id][modelo], InfoPickUp[id][tipo],
  400.                 InfoPickUp[id][pos_x], InfoPickUp[id][pos_y], InfoPickUp[id][pos_z], InfoPickUp[id][mundo]);
  401.                 fwrite(archivo, str);
  402.                 fclose(archivo);
  403.             }
  404.             return 1;
  405.         }
  406.     }
  407.     return 1;
  408. }
  409.  
  410. public OnPlayerPickUpPickup(playerid, pickupid)
  411. {
  412.     new po[3][15];
  413.     switch(InfoPickUp[pickupid][accion])
  414.     {
  415.         case 0:
  416.         {
  417.             format(str, sizeof(str), "%s", InfoPickUp[pickupid][accionar]);
  418.             SendClientMessage(playerid, COLOR_MSG, str);
  419.         }
  420.         case 1:
  421.         {
  422.             new Float:vid; GetPlayerHealth(playerid, vid);
  423.             SetPlayerHealth(playerid, vid+strval(InfoPickUp[pickupid][accionar]));
  424.             format(str, sizeof(str), "* Se te agregó %s puntos de vida.", InfoPickUp[pickupid][accionar]);
  425.             SendClientMessage(playerid, COLOR_MSG, str);
  426.         }
  427.         case 2:
  428.         {
  429.             new Float:cha; GetPlayerArmour(playerid, cha);
  430.             SetPlayerArmour(playerid, cha+strval(InfoPickUp[pickupid][accionar]));
  431.             format(str, sizeof(str), "* Se te agregó %s puntos de chaleco.", InfoPickUp[pickupid][accionar]);
  432.             SendClientMessage(playerid, COLOR_MSG, str);
  433.         }
  434.         case 3:
  435.         {
  436.             split(InfoPickUp[pickupid][accionar], po, ',');
  437.             SetPlayerPos(playerid, floatstr(po[0]), floatstr(po[1]), floatstr(po[2]));
  438.             SendClientMessage(playerid, COLOR_MSG, "* Has sido teletransportado a través del pickup.");
  439.         }
  440.         case 4:
  441.         {
  442.             split(InfoPickUp[pickupid][accionar], po, ',');
  443.             GivePlayerWeapon(playerid, strval(po[0]), strval(po[1]));
  444.             SendClientMessage(playerid, COLOR_MSG, "* Has recibido un arma a través del pickup.");
  445.         }
  446.     }
  447.     return 1;
  448. }
  449.  
  450. stock strtok(const string[], &index)
  451. {
  452.     new length = strlen(string);
  453.     while ((index < length) && (string[index] <= ' '))
  454.     {
  455.         index++;
  456.     }
  457.  
  458.     new offset = index;
  459.     new result[20];
  460.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  461.     {
  462.         result[index - offset] = string[index];
  463.         index++;
  464.     }
  465.     result[index - offset] = EOS;
  466.     return result;
  467. }
  468.  
  469. stock split(const strsrc[], strdest[][], delimiter = '|')
  470. {
  471.     new i, li, aNum, len, srclen = strlen(strsrc);
  472.     while(i <= srclen)
  473.     {
  474.         if (strsrc[i] == delimiter || i == srclen)
  475.         {
  476.             len = strmid(strdest[aNum], strsrc, li, i, 128);
  477.             strdest[aNum][len] = 0;
  478.             li = i + 1;
  479.             aNum++;
  480.         }
  481.         i++;
  482.     }
  483. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement