SA-MP Forums Archive
AttachObjectToVehicle Not Work?. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: AttachObjectToVehicle Not Work?. (/showthread.php?tid=614145)



AttachObjectToVehicle Not Work?. - quochuy - 05.08.2016

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


Re: AttachObjectToVehicle Not Work?. - AndySedeyn - 05.08.2016

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.


Re: AttachObjectToVehicle Not Work?. - quochuy - 05.08.2016

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



Re: AttachObjectToVehicle Not Work?. - quochuy - 05.08.2016

Help me


Re: AttachObjectToVehicle Not Work?. - quochuy - 05.08.2016

- Help meeeeeeeeeeee


Re: AttachObjectToVehicle Not Work?. - JuzDoiT - 05.08.2016

use this this is better
Quote:
http://www.******************/post/A...pt_other-5535/



Re: AttachObjectToVehicle Not Work?. - quochuy - 06.08.2016

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


Re: AttachObjectToVehicle Not Work?. - Crayder - 06.08.2016

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.