AttachObjectToVehicle Not Work?.
#1

I Use command /xyzz to create vehicle.
and AttachObjectToVehicle not work?.


I use the command /xyz , then attachobject it work?



PHP код:
CMD:xyzz(playerid,params[])
{
    
CreateVehicle(4111869.9429, -1760.531313.243170.7358119, -1); //Infernus
    
new OBJ[1];
    new 
vehicleid GetPlayerVehicleID(playerid);
    if(
GetVehicleModel(vehicleid) == 411)
    {
        
OBJ[0] = CreateObject(12711519.2829, -1704.879013.49260.00000.00000.0000); //gunbox
        
AddVehicleComponent(vehicleid1010);
        
AddVehicleComponent(vehicleid1074);
        
AddVehicleComponent(vehicleid1087);
        
AttachObjectToVehicle(OBJ[0], vehicleid, -0.0099, -1.89090.52700.60000.00002.7000);
    }
    return 
1;

PHP код:
CMD:xyz(playerid,params[])
{
    for(new 
GetVehiclePoolSize(); 0i--)
    {
        
SetVehicleToRespawn(i);
    }
    return 
1;

. Sorry my bad english .
. Please help for me
Reply
#2

This:
PHP код:
new vehicleid GetPlayerVehicleID(playerid); 
Requires the player to be inside a vehicle, otherwise it will return 0. Looking at the screenshots and the code, it doesn't look like the player would be in a vehicle after using /xyzz.

If you want the object to get attached to the created vehicle, assign vehicleid to CreateVehicle:
PHP код:
new vehicleid CreateVehicle(4111869.9429, -1760.531313.243170.7358119, -1); //Infernus 
The reason that works is because CreateVehicle returns the ID of the vehicle created.
Reply
#3

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
This:
PHP код:
new vehicleid GetPlayerVehicleID(playerid); 
Requires the player to be inside a vehicle, otherwise it will return 0. Looking at the screenshots and the code, it doesn't look like the player would be in a vehicle after using /xyzz.

If you want the object to get attached to the created vehicle, assign vehicleid to CreateVehicle:
PHP код:
new vehicleid CreateVehicle(4111869.9429, -1760.531313.243170.7358119, -1); //Infernus 
The reason that works is because CreateVehicle returns the ID of the vehicle created.
I succeeded in experimentation mode . but putting it in my mode rpg , it does not work?



code:
PHP код:
forward OnPlayerVehicleSpawn(playerid);
public 
OnPlayerVehicleSpawn(playerid)
{
    new 
plate[10], query[128], string[128],
        
model cache_get_row_int(02),
        
color1 cache_get_row_int(03),
        
color2 cache_get_row_int(04),
        
Float:cache_get_row_float(05),
        
Float:cache_get_row_float(06),
        
Float:cache_get_row_float(07),
        
Float:cache_get_row_float(08),
        
fuel cache_get_row_int(09),
        
Float:health cache_get_row_float(010),
        
insured cache_get_row_int(036),
        
scrapped cache_get_row_int(037),
        
locktype cache_get_row_int(038);
    new 
OBJ[1];
    new 
vehicle CreateVehicle(modelXYZAcolor1color2, -1);
    if(
GetVehicleModel(vehicleid) == 411)
    {
        
OBJ[0] = CreateObject(12711519.2829, -1704.879013.49260.00000.00000.0000); //gunbox
        
AddVehicleComponent(vehicle1010);
        
AddVehicleComponent(vehicle1074);
        
AddVehicleComponent(vehicle1087);
        
AttachObjectToVehicle(OBJ[0], vehicle, -0.0099, -1.89090.52700.60000.00002.7000);
    }
    return 
1;

I changed " OnPlayerVehicleSpawn(playerid) " to " OnPlayerVehicleSpawn(playerid, vehicleid) "
- OnPlayerVehicleSpawn(playerid) - Not Work
- OnPlayerVehicleSpawn(playerid, vehicleid) - Not Work
Reply
#4

Help me
Reply
#5

- Help meeeeeeeeeeee
Reply
#6

use this this is better
Reply
#7

Quote:
Originally Posted by JuzDoiT
Посмотреть сообщение
use this this is better
link " *******" ?
Reply
#8

Quote:
Originally Posted by JuzDoiT
Посмотреть сообщение
use this this is better
It's against the rules to post links to that site, thus the asterisks.

Plus, the script you linked isn't really what this guy is asking for at all.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)