Attaching Object to specific Vehicle
#1

Hello
i'm wanting to be able to attach an object to my vehicle by Cmd "/lights".
but i want the /lights command to only work if i'm in a specific vehicle, say the Infernus id-411
i have got all my items / coords, i just need some help on how to make the cmd command to work only in the Infernus.
Reply
#2

My exampel
Код:
// Lights
new Light[MAX_VEHICLES];
new LightObject[MAX_VEHICLES];

CMD:light(playerid, params[])
{
	new veh, type[8], string[128];
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
   	if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle.");
	if(sscanf(params, "s[8]", type))
	{
		SendClientMessage(playerid, COLOR_WHITE, "USAGE: /light [position]");
		SendClientMessage(playerid, COLOR_WHITE, "POSITIONS: on|off");
		return 1;
	}
	if(Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "This vehicle already has a Light attached.");
	veh = GetPlayerVehicleID(playerid);
	if(!strcmp(type, "on"))
	{
		if(Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is already a light attached to this vehicle.");
        Light[veh] = 1;
        LightObject[veh] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
        AttachDynamicObjectToVehicle(LightObject[veh],veh, x, y, z, 0.0, 0.1, 0.0);
        format(string, sizeof(string), "* %s attaches a light to the car.", RPN(playerid));
        SendNearbyMessage(playerid, 15, string, Colors);
        return 1;
	else if(!strcmp(type, "off"))
	{
	    if(!Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is no Lights attached to this vehicle.");
		Light[veh] = 0;
		DestroyDynamicObject(LightObject[veh]);
		format(string, sizeof(string), "* %s takes the Light off the car.", RPN(playerid));
		SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
		return 1;
	}
	return 1;
}
Reply
#3

Quote:
Originally Posted by KeenanRitchie
Посмотреть сообщение
My exampel
Код:
// Lights
new Light[MAX_VEHICLES];
new LightObject[MAX_VEHICLES];

CMD:light(playerid, params[])
{
	new veh, type[8], string[128];
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
   	if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle.");
	if(sscanf(params, "s[8]", type))
	{
		SendClientMessage(playerid, COLOR_WHITE, "USAGE: /light [position]");
		SendClientMessage(playerid, COLOR_WHITE, "POSITIONS: on|off");
		return 1;
	}
	if(Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "This vehicle already has a Light attached.");
	veh = GetPlayerVehicleID(playerid);
	if(!strcmp(type, "on"))
	{
		if(Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is already a light attached to this vehicle.");
        Light[veh] = 1;
        LightObject[veh] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
        AttachDynamicObjectToVehicle(LightObject[veh],veh, x, y, z, 0.0, 0.1, 0.0);
        format(string, sizeof(string), "* %s attaches a light to the car.", RPN(playerid));
        SendNearbyMessage(playerid, 15, string, Colors);
        return 1;
	else if(!strcmp(type, "off"))
	{
	    if(!Light[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is no Lights attached to this vehicle.");
		Light[veh] = 0;
		DestroyDynamicObject(LightObject[veh]);
		format(string, sizeof(string), "* %s takes the Light off the car.", RPN(playerid));
		SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
		return 1;
	}
	return 1;
}
I don't think that is going to help me, i just need a simple line of code, i just dont know what it is
Reply
#4

This is my current code - http://pastebin.com/frX3SerK
i just need something that only lets my command work if i'm in a certain vehicle.
Reply
#5

Dont worry, i figured it out, i used "

Quote:

new vehid = GetPlayerVehicleID(playerid);
if(DFT(vehid))
{

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)