Attach Object
#1

Hello..
I have this command :

Код:
COMMAND:plantradio(playerid, params[])
{
    if (GetPVarInt(playerid, "PlayerLogged") == 0) return SendClientMessage(playerid, COLOR_WHITE, "SERVER: You must be logged in to use this.");
	if (GetPlayerInterior(playerid) != 0) return SendClientMessage(playerid, COLOR_GREY, "You must be outside to use this.");
    if(GetPVarInt(playerid, "RadioPlant") > 0)
    {
		new found = 0, string[128], Float:X, Float:Y, Float:Z, Float:A, id = 0;
        for(new i=0;i<sizeof(RadioInfo);i++)
		{
		    if(RadioInfo[i][rAreaID] == GetPlayerZone(playerid))
		    {
		        found++;
		    }
		}
		if(found != 0) return SendClientMessage(playerid, COLOR_GREY,"There is currently a radio in this area !");
		for(new i=0;i<sizeof(RadioInfo);i++)
		{
		    if(RadioInfo[i][rX] == 0.0 && RadioInfo[i][rY] == 0.0 && RadioInfo[i][rZ] == 0.0)
		    {
		        id = i;
		    }
		}
		if(id == 0) return SendClientMessage(playerid, COLOR_GREY,"All boom boxes have been used !");
		for(new i=0;i<sizeof(RadioInfo);i++)
		{
            if(strcmp(RadioInfo[i][rOwner], PlayerName(playerid), true) == 0)
		    {
		        SendClientMessage(playerid, COLOR_LIGHTRED, "You already have a boombox planted !");
		        return true;
		    }
		}
		GetPlayerPos(playerid,X,Y,Z);
		GetPlayerFacingAngle(playerid, A);
		RadioInfo[id][rObject] = CreateDynamicObject(2103, X,Y,Z-1, 0.0, 0.0, A, GetPlayerVirtualWorld(playerid));
		format(string, sizeof(string),"[BOOM BOX]\n%s", PlayerName(playerid));
		RadioInfo[id][rText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, X, Y, Z-0.25, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 50.0);
		RadioInfo[id][rX] = X;
		RadioInfo[id][rY] = Y;
		RadioInfo[id][rZ] = Z;
		RadioInfo[id][rStatus] = 0;
		RadioInfo[id][rAreaID] = GetPlayerZone(playerid);
		strmid(RadioInfo[id][rOwner], PlayerName(playerid), 0, strlen(PlayerName(playerid)), 255);
		strmid(RadioInfo[id][rURL], "NUll", 0, strlen("NULL"), 255);
		SetPVarInt(playerid, "RadioPlant", 0);
		SendClientMessage(playerid, COLOR_WHITE, "BoomBox planted, type (/editradio) to configure the radio options !");
    }
    else SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have a radio to plant !");
	return 1;
}
When i type /plantradio,i plant a boombox.
So,i wanna make when use /plantradio in a car to attach the boombox to car..Like a siren
If i enter in a vehicle and i use /plantradio,radio remain where I gave the command..

How can i attach the boombox to car..
Reply
#2

Hello Don, Heres a code to use..

Код:
AttachObjectToVehicle(objectid, vehicleid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:RotZ);
Reply
#3

So,i put this code on that script ?

AttachObjectToVehicle(objectid, vehicleid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:RotZ);


??
Only ?
Reply
#4

Quote:
Originally Posted by DonBonanno
Посмотреть сообщение
So,i put this code on that script ?

AttachObjectToVehicle(objectid, vehicleid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:RotZ);


??
Only ?
correct.

you'll have to fill in all the params like coordinates first ofc.

here's an example of a cop siren on a sultan:
PHP код:
YCMD:attach(playeridparams[], help)
{
    if(
GetVehicleModel(GetPlayerVehicleID(playerid)) != 560) return SendClientMessage(playerid,-1,"That's not a Sultan.");
    new 
Float:p[3];
    
GetPlayerPos(playerid,p[0],p[1],p[2]);
    new 
object CreateObject(19419,p[0],p[1]-0.25,p[2]+0.82999,0,0,0);
    
AttachObjectToVehicle(object,GetPlayerVehicleID(playerid),0,-0.25,0.82999,0,0,0);
    return 
1;

Reply
#5

Good ?

Код:
		}
		GetPlayerPos(playerid,X,Y,Z);
		GetPlayerFacingAngle(playerid, A);
		RadioInfo[id][rObject] = CreateDynamicObject(2103, X,Y,Z-1, 0.0, 0.0, A, GetPlayerVirtualWorld(playerid));
		format(string, sizeof(string),"[BOOM BOX]\n%s", PlayerName(playerid));
		RadioInfo[id][rText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, X, Y, Z-0.25, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 50.0);
		RadioInfo[id][rX] = X;
		RadioInfo[id][rY] = Y;
		RadioInfo[id][rZ] = Z;
		RadioInfo[id][rStatus] = 0;
		RadioInfo[id][rAreaID] = GetPlayerZone(playerid);
		strmid(RadioInfo[id][rOwner], PlayerName(playerid), 0, strlen(PlayerName(playerid)), 255);
		strmid(RadioInfo[id][rURL], "NUll", 0, strlen("NULL"), 255);
		SetPVarInt(playerid, "RadioPlant", 0);
		AttachObjectToVehicle(objectid, vehicleid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:RotZ);
		SendClientMessage(playerid, COLOR_WHITE, "BoomBox planted, type (/editradio) to configure the radio options !");
    }
    else SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have a radio to plant !");
	return 1;
}
I putted AttachObjectToVehicle(objectid, vehicleid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:RotZ); there..
Reply
#6

Quote:
Originally Posted by DonBonanno
Посмотреть сообщение
Good ?

Код:
		}
		GetPlayerPos(playerid,X,Y,Z);
		GetPlayerFacingAngle(playerid, A);
		RadioInfo[id][rObject] = CreateDynamicObject(2103, X,Y,Z-1, 0.0, 0.0, A, GetPlayerVirtualWorld(playerid));
		format(string, sizeof(string),"[BOOM BOX]\n%s", PlayerName(playerid));
		RadioInfo[id][rText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, X, Y, Z-0.25, 25.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, 0, 0, -1, 50.0);
		RadioInfo[id][rX] = X;
		RadioInfo[id][rY] = Y;
		RadioInfo[id][rZ] = Z;
		RadioInfo[id][rStatus] = 0;
		RadioInfo[id][rAreaID] = GetPlayerZone(playerid);
		strmid(RadioInfo[id][rOwner], PlayerName(playerid), 0, strlen(PlayerName(playerid)), 255);
		strmid(RadioInfo[id][rURL], "NUll", 0, strlen("NULL"), 255);
		SetPVarInt(playerid, "RadioPlant", 0);
		AttachObjectToVehicle(objectid, vehicleid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:RotZ);
		SendClientMessage(playerid, COLOR_WHITE, "BoomBox planted, type (/editradio) to configure the radio options !");
    }
    else SendClientMessage(playerid, COLOR_LIGHTRED, "You don't have a radio to plant !");
	return 1;
}
I putted AttachObjectToVehicle(objectid, vehicleid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:RotZ); there..
didn't you read my post? you have to fill the params....
this:
AttachObjectToVehicle(objectid, vehicleid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:RotZ);
in your code would just cause errors and does exactly nothing.

add your coords to it, and the vehicle id and all the other stuff.
example for my last post:
PHP код:
    new object CreateObject(19419,p[0],p[1]-0.25,p[2]+0.82999,0,0,0);
    
AttachObjectToVehicle(object,GetPlayerVehicleID(playerid),0,-0.25,0.82999,0,0,0); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)