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(411, 1869.9429, -1760.5313, 13.2431, 70.7358, 1, 19, -1); //Infernus
    
new OBJ[1];
    new 
vehicleid = GetPlayerVehicleID(playerid);
    if(
GetVehicleModel(vehicleid) == 411)
    {
        
OBJ[0] = CreateObject(1271, 1519.2829, -1704.8790, 13.4926, 0.0000, 0.0000, 0.0000); //gunbox
        
AddVehicleComponent(vehicleid, 1010);
        
AddVehicleComponent(vehicleid, 1074);
        
AddVehicleComponent(vehicleid, 1087);
        
AttachObjectToVehicle(OBJ[0], vehicleid, -0.0099, -1.8909, 0.5270, 0.6000, 0.0000, 2.7000);
    }
    return 
1;
} 
PHP код:
CMD:xyz(playerid,params[])
{
    for(new 
i = GetVehiclePoolSize(); i > 0; i--)
    {
        
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(411, 1869.9429, -1760.5313, 13.2431, 70.7358, 1, 19, -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(411, 1869.9429, -1760.5313, 13.2431, 70.7358, 1, 19, -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(0, 2),
        
color1 = cache_get_row_int(0, 3),
        
color2 = cache_get_row_int(0, 4),
        
Float:X = cache_get_row_float(0, 5),
        
Float:Y = cache_get_row_float(0, 6),
        
Float:Z = cache_get_row_float(0, 7),
        
Float:A = cache_get_row_float(0, 8),
        
fuel = cache_get_row_int(0, 9),
        
Float:health = cache_get_row_float(0, 10),
        
insured = cache_get_row_int(0, 36),
        
scrapped = cache_get_row_int(0, 37),
        
locktype = cache_get_row_int(0, 38);
    new 
OBJ[1];
    new 
vehicle = CreateVehicle(model, X, Y, Z, A, color1, color2, -1);
    if(
GetVehicleModel(vehicleid) == 411)
    {
        
OBJ[0] = CreateObject(1271, 1519.2829, -1704.8790, 13.4926, 0.0000, 0.0000, 0.0000); //gunbox
        
AddVehicleComponent(vehicle, 1010);
        
AddVehicleComponent(vehicle, 1074);
        
AddVehicleComponent(vehicle, 1087);
        
AttachObjectToVehicle(OBJ[0], vehicle, -0.0099, -1.8909, 0.5270, 0.6000, 0.0000, 2.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)