Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot Other languages Spanish/Español Programación [AYUDA] Necesito adaptar esto

 
  • 0 Vote(s) - 0 Average
[AYUDA] Necesito adaptar esto
BIOS
Offline

Burgershot Member
Posts: 5
Threads: 2
Joined: May 2020
Reputation: 0
Location: Argentina
#1
2020-05-24, 03:18 AM
Buenas, Resulta que quiero poner este objeto en mi vehículo de trabajo pero no se como hacerlo, si me mostrarían un ejemplo se los agradecería.

El objeto:
[código] nuevo myobject = CreateObject (19433,0,0, -1000,0,0,0,100);


AttachObjectToVehicle (myobject, GetPlayerVehicleID (playerid), -0.000000, -1.875000,0.375000,0.000000,121.499954, -91.799980); [/ code]

El vehículo en el cual quiero montar el objeto:

[código] nuevo San_Andreas_Vehicles [] [San_Andreas_Vehicles_Info] =
{
// taxi ls

{VEHICLE_TYPE_WORK, WORK_TAXI, 0, 420, 1792.5676, -1868.2953, 13.2887, 0.0000, 6, 1, 0},


}[/código]
SKainer
Offline

Burgershot Member
Posts: 15
Threads: 3
Joined: Jan 2020
Reputation: 0
#2
2020-05-24, 04:50 AM
No necesitas poner CreateObject en myobject, con sólo poner la id del objeto ya basta
AttachObjectToVehicle(objectid, ...)

Puedes mostrar el enum "San_Andreas_Vehicles_Info"?
Languajes de Programación que domino:
Pawn, Lua.
Lenguajes de Programación que estoy aprendiendo:
C++, JavaScript & C#.

¡Listo para ayudarte!
BIOS
Offline

Burgershot Member
Posts: 5
Threads: 2
Joined: May 2020
Reputation: 0
Location: Argentina
#3
2020-05-24, 03:26 PM
[quote = "SKainer" pid = '7593' dateline = '1590295858']
No necesitas poner CreateObject en myobject, con solo poner la id del objeto ya basta
AttachObjectToVehicle ( objectid , ...)

Puedes mostrar el enum " San_Andreas_Vehicles_Info"?
[/citar]

Claro, es este ....
enumeración San_Andreas_Vehicles_Info
{
san_andreas_vehicle_TYPE,
san_andreas_vehicle_TYPE_IN,
san_andreas_vehicle_TYPE_IN_EXP,
san_andreas_vehicle_MODELID,
Flotador: san_andreas_vehicle_SPAWN_X,
Flotador: san_andreas_vehicle_SPAWN_Y,
Flotador: san_andreas_vehicle_SPAWN_Z,
Flotador: san_andreas_vehicle_SPAWN_ANGLE,
san_andreas_vehicle_COLOR_1,
san_andreas_vehicle_COLOR_2,
san_andreas_vehicle_vip
};

Si me pasas el codigo completo me ayudas por que asi aprendo mas rapido amigo, Gracias !!!
SKainer
Offline

Burgershot Member
Posts: 15
Threads: 3
Joined: Jan 2020
Reputation: 0
#4
2020-05-26, 01:47 AM (This post was last modified: 2020-05-26, 01:48 AM by SKainer.)
Te hice este pequeño y sencillo script que tal vez no sea lo que quieras exactamente pero úsalo como ejemplo o plantilla

PHP Code:
new vehicle_taxi1; // Variable global del vehículo
public OnVehicleSpawn(vehicleid) // Usamos este callback para cuando el vehículo se spawnee
{
   if(San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_TYPE] == VEHICLE_TYPE_WORK)
   
// Condicional de si el vehiculo es tipo de trabajo
   {
       if(San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_TYPE_IN] == WORK_TAXI)
       
// Condicional de si el vehiculos es tipo trabajo taxi
       {
           // Esto lo hice para que la linea no sea tan larga
           new modelid = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_MODELID];
           new floatx = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_X];
           new floaty = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_Y];
           new floatz = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_Z];
           new floata = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_ANGLE];
           new color1 = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_COLOR_1];
           new color2 = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_COLOR_2];

           vehicle_taxi1 = AddStaticVehicle(modelid, floatx, floaty, floatz, floata, color1, color2);
           AttachObjectToVehicle(objectid, vehicle_taxi1, ...);
       }
       // Tus otros vehiculos de trabajo
   }
   return 1;
} 
Languajes de Programación que domino:
Pawn, Lua.
Lenguajes de Programación que estoy aprendiendo:
C++, JavaScript & C#.

¡Listo para ayudarte!
BIOS
Offline

Burgershot Member
Posts: 5
Threads: 2
Joined: May 2020
Reputation: 0
Location: Argentina
#5
2020-05-26, 01:59 AM
(2020-05-26, 01:47 AM)SKainer Wrote: Te hice este pequeño y sencillo script que tal vez no sea lo que quieras exactamente pero úsalo como ejemplo o plantilla

PHP Code:
new vehicle_taxi1; // Variable global del vehículo
public OnVehicleSpawn(vehicleid) // Usamos este callback para cuando el vehículo se spawnee
{
   if(San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_TYPE] == VEHICLE_TYPE_WORK)
  // Condicional de si el vehiculo es tipo de trabajo
   {
       if(San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_TYPE_IN] == WORK_TAXI)
      // Condicional de si el vehiculos es tipo trabajo taxi
       {
           // Esto lo hice para que la linea no sea tan larga
           new modelid = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_MODELID];
           new floatx = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_X];
           new floaty = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_Y];
           new floatz = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_Z];
           new floata = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_ANGLE];
           new color1 = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_COLOR_1];
           new color2 = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_COLOR_2];

           vehicle_taxi1 = AddStaticVehicle(modelid, floatx, floaty, floatz, floata, color1, color2);
           AttachObjectToVehicle(objectid, vehicle_taxi1, ...);
       }
       // Tus otros vehiculos de trabajo
   }
   return 1;
} 


Entonces esto:

PHP Code:
{VEHICLE_TYPE_WORK, WORK_TAXI, 0, 420, 1792.5676, -1868.2953, 13.2887, 0.0000, 6, 1, 0}, 


Debe desaparecer?? Se agregaría en el ejemplo que me pusiste que vendria ir aca

           
PHP Code:
vehicle_taxi1 = AddStaticVehicle(modelid, floatx, floaty, floatz, floata, color1, color2);

           AttachObjectToVehicle(objectid, vehicle_taxi1, ...); 
SKainer
Offline

Burgershot Member
Posts: 15
Threads: 3
Joined: Jan 2020
Reputation: 0
#6
2020-05-26, 04:31 AM (This post was last modified: 2020-05-26, 05:28 PM by SKainer.)
(2020-05-26, 01:59 AM)BIOS Wrote: Entonces esto:

PHP Code:
{VEHICLE_TYPE_WORK, WORK_TAXI, 0, 420, 1792.5676, -1868.2953, 13.2887, 0.0000, 6, 1, 0}, 

Debe desaparecer?? Se agregaría en el ejemplo que me pusiste que vendria ir aca

No es necesario, ya que vehicle_taxi1 es solo un identificador, puedes agregar esto al enum

PHP Code:
enum San_Andreas_Vehicles_Info
{
   san_andreas_vehicle_VARIABLE,
}; 

y aquí agregar el ID:

PHP Code:
{1, VEHICLE_TYPE_WORK, WORK_TAXI, 0, 420, 1792.5676, -1868.2953, 13.2887, 0.0000, 6, 1, 0}, 

esto para agregarle un identificador a tu variable y así poder crear más vehículos del mismo tipo (WORK_TAXI).
Ahora te mostraré como sería TODO el código con ese identificador y sin errores (mi código anterior daba errores):

PHP Code:
enum San_Andreas_Vehicles_Info
{
    san_andreas_vehicle_VARIABLE, //id
    san_andreas_vehicle_TYPE,
    san_andreas_vehicle_TYPE_IN,
    san_andreas_vehicle_TYPE_IN_EXP,
    san_andreas_vehicle_MODELID,
    Float:san_andreas_vehicle_SPAWN_X,
    Float:san_andreas_vehicle_SPAWN_Y,
    Float:san_andreas_vehicle_SPAWN_Z,
    Float:san_andreas_vehicle_SPAWN_ANGLE,
    san_andreas_vehicle_COLOR_1,
    san_andreas_vehicle_COLOR_2,
    san_andreas_vehicle_vip
};

new 
San_Andreas_Vehicles[][San_Andreas_Vehicles_Info] =
{
    { 1, VEHICLE_TYPE_WORK, WORK_TAXI, 0, 420, 1792.5676, -1868.2953, 13.2887, 0.0000, 6, 1, 0 } // El identificador agregado
};

public 
OnVehicleSpawn(vehicleid) // Usamos este callback para cuando el vehículo se spawnee
{
   if(San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_TYPE] == VEHICLE_TYPE_WORK)
   // Condicional de si el vehiculo es tipo de trabajo
   {
       if(San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_TYPE_IN] == WORK_TAXI)
       // Condicional de si el vehiculos es tipo trabajo taxi
       {
           if(San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_VARIABLE] == 1) // Nueva línea
           {
              // Esto lo hice para que la linea no sea tan larga
               new modelid = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_MODELID];
               new Float:floatx = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_X];
               new Float:floaty = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_Y];
               new Float:floatz = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_Z];
               new Float:floata = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_SPAWN_ANGLE];
               new color1 = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_COLOR_1];
               new color2 = San_Andreas_Vehicles[vehicleid][san_andreas_vehicle_COLOR_2];

               AddStaticVehicle(modelid, floatx, floaty, floatz, floata, color1, color2);
               AttachObjectToVehicle(1223, vehicleid, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
           }
           // Tus otros tipos de vehiculos de trabajo taxi
       }
       // Tus otros tipos de vehiculos de trabajo
   }
   return 1;
}
  

Tal vez con el AttachObject te dé un bug... pero si eres inteligente sabrás cómo resolverlo, también ten en cuenta que puedes hacerlo cómo quieras pero no es necesario usar lo que te puse
Languajes de Programación que domino:
Pawn, Lua.
Lenguajes de Programación que estoy aprendiendo:
C++, JavaScript & C#.

¡Listo para ayudarte!
BIOS
Offline

Burgershot Member
Posts: 5
Threads: 2
Joined: May 2020
Reputation: 0
Location: Argentina
#7
2020-05-26, 09:56 PM
El 1 Significa Activo y el 0 significa Inactivo? Perdona por ser reiterativo jajajaja
SKainer
Offline

Burgershot Member
Posts: 15
Threads: 3
Joined: Jan 2020
Reputation: 0
#8
2020-05-26, 11:06 PM
(2020-05-26, 09:56 PM)BIOS Wrote: El 1 Significa Activo y el 0 significa Inactivo? Perdona por ser reiterativo jajajaja

El 1 es un IDentificador, puedes ponerle cualquier otro número para identificar
Languajes de Programación que domino:
Pawn, Lua.
Lenguajes de Programación que estoy aprendiendo:
C++, JavaScript & C#.

¡Listo para ayudarte!
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode