/siren by vehicle type
#1

I don't know what's the problem with the system, everything works fine, I mean the whole permissions but when I enter the vehicle the siren object dosen't created.

Код:
CMD:siren(playerid, vehicleid, params[])
{
	new veh = GetVehicleModel(vehicleid);
	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
   	if(!IsAEmergency(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You don't have a siren.");
   	if(!PlayerInfo[playerid][pFacDuty]) return SendClientMessage(playerid, COLOR_GREY, "You are not on duty.");
   	if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You are not driving a vehicle.");
	if(Siren[veh]) return SendClientMessage(playerid, COLOR_GREY, "This vehicle already has a siren attached.");
	if(!Siren[veh])
	{
		if(GetPlayerVehicleID(playerid))
		{
			if(veh == 415)
			{
				if(Siren[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is already a siren attached to this vehicle.");
		        Siren[veh] = 1;
		        SirenObject[veh] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
		        AttachDynamicObjectToVehicle(SirenObject[veh],veh, -0.3, -0.2, 0.65, 0.0, 0.1, 0.0);
		        return 1;
			}
			else if(veh == 402)
			{
			    if(Siren[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is already a siren attached to this vehicle.");
				Siren[veh] = 1;
		        SirenObject[veh] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
		        AttachDynamicObjectToVehicle(SirenObject[veh], veh, -0.5, -0.3, 0.8, 0.0, 0.1, 0.0);
		        return 1;
			}
			else if(veh == 426)
			{
			    if(Siren[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is already a siren attached to this vehicle.");
				Siren[veh] = 1;
		        SirenObject[veh] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
		        AttachDynamicObjectToVehicle(SirenObject[veh], veh, -0.5, -0.2, 0.9, 0.0, 0.1, 0.0);
		        return 1;
			}
			else if(veh == 541)
			{
			    if(Siren[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is already a siren attached to this vehicle.");
				Siren[veh] = 1;
		        SirenObject[veh] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
		        AttachDynamicObjectToVehicle(SirenObject[veh], veh, -0.4, 0.1, 0.68, 0.0, 0.1, 0.0);
		        return 1;
			}
			else if(veh == 560)
			{
			    if(Siren[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is already a siren attached to this vehicle.");
				Siren[veh] = 1;
		        SirenObject[veh] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
		        AttachDynamicObjectToVehicle(SirenObject[veh], veh, -0.4, 0.2, 0.9, 0.0, 0.1, 0.0);
		        return 1;
			}
			else if(veh == 579)
			{
			    if(Siren[veh]) return SendClientMessage(playerid, COLOR_GREY, "There is already a siren attached to this vehicle.");
				Siren[veh] = 1;
		        SirenObject[veh] = CreateDynamicObject(18646, 10.0, 10.0, 10.0, 0, 0, 0);
		        AttachDynamicObjectToVehicle(SirenObject[veh], veh, -0.4, -0.2, 1.3, 0.0, 0.1, 0.0);
		        return 1;
			}
			else SendClientMessage(playerid, COLOR_LIGHTRED, "Siren cannot be attached to this vehicle.");
		}
		return 1;
	}
	else
	{
		Siren[veh] = 0;
		DestroyDynamicObject(SirenObject[veh]);
		return 1;
	}
}
Help please, thanks.
Reply
#2

veh seems to contain the model ID, not the vehicle ID.
Reply
#3

That's what I need. For exmple model 415 Cheetah Siren will be attached to the Cheetah.
Reply
#4

Quote:
Originally Posted by maiky1499
Посмотреть сообщение
That's what I need. For exmple model 415 Cheetah Siren will be attached to the Cheetah.
Yes, but the vehicle ID 415 might not be a Cheetah. Vehicle ID 415 might not even exist.
Reply
#5

So how did I do it with model ID, veh = ? if I want that veh == 415 its in Cheetah
Reply
#6

Bump
Reply
#7

Instead of
AttachDynamicObjectToVehicle(SirenObject[veh], veh, ...);

You must do something like:
new vehicleid = GetPlayerVehicleID(playerid);
AttachDynamicObjectToVehicle(SirenObject[veh], vehicleid, ...);
Reply
#8

Thank you very much, works %100.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)