[HELP] custom police car -
dk4ever - 10.03.2011
i want to make a undercover police car
for example : i want to create infernus and attach police light in it... an turn the light on when i press "H"
i have this car
PDinfernus = AddStaticVehicleEx(411,1526.4309,-1646.1412,6.0788,178.1691,0,1,6000);
Re: [HELP] custom police car -
xRyder - 10.03.2011
You'll need to use those functions:
CreateObject,
AttachObjectToVehicle,
OnPlayerKeyStateChange. Have fun!
Re: [HELP] custom police car -
dk4ever - 10.03.2011
can you give me the object id for police light?? pls
Re: [HELP] custom police car -
xRyder - 10.03.2011
I'm not sure, but you can try with
18646.
Find them all
here.
Re: [HELP] custom police car -
dk4ever - 10.03.2011
thx for help
Re: [HELP] custom police car -
dk4ever - 10.03.2011
i make like this
Код:
pdlight = CreateObject(18646,0,0,0,0,0,0);
buffpd1 = AddStaticVehicleEx(402,1545.5215,-1680.1603,5.7222,89.7425,0,0,30000); // buffalo pd
buffpd2 = AddStaticVehicleEx(402,1544.9746,-1676.1263,5.7223,91.2767,0,0,30000); // buffalo pd
buffpd3 = AddStaticVehicleEx(402,1600.9907,-1695.9442,5.7223,89.9302,0,0,30000); // buffalo pd
buffpd4 = AddStaticVehicleEx(402,1601.1803,-1700.0834,5.7223,90.7667,0,0,30000); // buffalo pd
AttachObjectToVehicle(pdlight, buffpd1, 0, -0.0, 0, 2.0, 2.0, 3.0);
AttachObjectToVehicle(pdlight, buffpd2, 0, -0.0, 0, 2.0, 2.0, 3.0);
AttachObjectToVehicle(pdlight, buffpd3, 0, -0.0, 0, 2.0, 2.0, 3.0);
AttachObjectToVehicle(pdlight, buffpd4, 0, -0.0, 0, 2.0, 2.0, 3.0);
but the object isn't there and no light
what i do wrong?
all is in "public OnGameModeInit()"
Re: [HELP] custom police car -
Loppa - 10.03.2011
You have to create one police light per vehicle:
Код:
pdlight1 = CreateObject(18646,0,0,0,0,0,0);
pdlight2 = CreateObject(18646,0,0,0,0,0,0);
pdlight3 = CreateObject(18646,0,0,0,0,0,0);
pdlight4 = CreateObject(18646,0,0,0,0,0,0);
buffpd1 = AddStaticVehicleEx(402,1545.5215,-1680.1603,5.7222,89.7425,0,0,30000); // buffalo pd
buffpd2 = AddStaticVehicleEx(402,1544.9746,-1676.1263,5.7223,91.2767,0,0,30000); // buffalo pd
buffpd3 = AddStaticVehicleEx(402,1600.9907,-1695.9442,5.7223,89.9302,0,0,30000); // buffalo pd
buffpd4 = AddStaticVehicleEx(402,1601.1803,-1700.0834,5.7223,90.7667,0,0,30000); // buffalo pd
AttachObjectToVehicle(pdlight1, buffpd1, 0, -0.0, 0, 2.0, 2.0, 3.0);
AttachObjectToVehicle(pdlight2, buffpd2, 0, -0.0, 0, 2.0, 2.0, 3.0);
AttachObjectToVehicle(pdlight3, buffpd3, 0, -0.0, 0, 2.0, 2.0, 3.0);
AttachObjectToVehicle(pdlight4, buffpd4, 0, -0.0, 0, 2.0, 2.0, 3.0);
And i would use arrays instead of all these variables.
Re: [HELP] custom police car -
dk4ever - 10.03.2011
thx for help
Re: [HELP] custom police car -
dk4ever - 11.03.2011
i make something like this
Код:
if (newkeys == KEY_CROUCH)
{
new pdlight1;
new pdlight2;
new pdlight3;
new pdlight4;
new pdlighton;
if(pdlighton == 0)
{
new checkcar = GetPlayerVehicleID(playerid);
if(checkcar == buffpd1)
{
pdlight1 = CreateObject(18646,0,0,0,0,0,0);
AttachObjectToVehicle(pdlight1, buffpd1, 0, -0.0, 0, 2.0, 2.0, 3.0);
pdlighton = 1;
}
else if(checkcar == buffpd2)
{
ipdlight2 = CreateObject(18646,0,0,0,0,0,0);
iAttachObjectToVehicle(pdlight2, buffpd2, 0, -0.0, 0, 2.0, 2.0, 3.0);
ipdlighton = 1;
}
else if(checkcar == buffpd3)
{
pdlight3 = CreateObject(18646,0,0,0,0,0,0);
AttachObjectToVehicle(pdlight3, buffpd3, 0, -0.0, 0, 2.0, 2.0, 3.0);
pdlighton = 1;
}
else if(checkcar == buffpd4)
{
pdlight4 = CreateObject(18646,0,0,0,0,0,0);
AttachObjectToVehicle(pdlight4, buffpd4, 0, -0.0, 0, 2.0, 2.0, 3.0);
pdlighton = 1;
}
return 1;
}
else
{
new checkcar = GetPlayerVehicleID(playerid);
if(checkcar == buffpd1)
{
DestroyObject(pdlight1);
}
else if(checkcar == buffpd2)
{
DestroyObject(pdlight2);
}
else if(checkcar == buffpd3)
{
DestroyObject(pdlight3);
}
else if(checkcar == buffpd4)
{
DestroyObject(pdlight4);
}
return 1;
}
}
but when i use again KEY_CROUCH that police light is still there..
how can i make a variable which depend by carid?
or how i can solve this problem?
Re: [HELP] custom police car -
dk4ever - 11.03.2011
i solved some problem
until now always attach new police light...now i solved
bot now i don't know why didn't destroy the police light
here is the code
pawn Код:
if (newkeys == KEY_CROUCH)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new pdlight1;
new pdlight2;
new pdlight3;
new pdlight4;
new checkcar = GetPlayerVehicleID(playerid);
if(pdlighton1 == 0 && checkcar == buffpd1 || pdlighton2 == 0 && checkcar == buffpd2 || pdlighton3 == 0 && checkcar == buffpd3 || pdlighton4 == 0 && checkcar == buffpd4)
{
if(checkcar == buffpd1)
{
pdlight1 = CreateObject(18646,0,0,0,0,0,0);
AttachObjectToVehicle(pdlight1, buffpd1, 0, -0.0, 0, 2.0, 2.0, 3.0);
pdlighton1 = 1;
}
if(checkcar == buffpd2)
{
pdlight2 = CreateObject(18646,0,0,0,0,0,0);
AttachObjectToVehicle(pdlight2, buffpd2, 0, -0.0, 0, 2.0, 2.0, 3.0);
pdlighton2 = 1;
}
if(checkcar == buffpd3)
{
pdlight3 = CreateObject(18646,0,0,0,0,0,0);
AttachObjectToVehicle(pdlight3, buffpd3, 0, -0.0, 0, 2.0, 2.0, 3.0);
pdlighton3 = 1;
}
if(checkcar == buffpd4)
{
pdlight4 = CreateObject(18646,0,0,0,0,0,0);
AttachObjectToVehicle(pdlight4, buffpd4, 0, -0.0, 0, 2.0, 2.0, 3.0);
pdlighton4 = 1;
}
}
else
{
if(checkcar == buffpd1)
{
DestroyObject(pdlight1);
}
if(checkcar == buffpd2)
{
DestroyObject(pdlight2);
}
if(checkcar == buffpd3)
{
DestroyObject(pdlight3);
}
if(checkcar == buffpd4)
{
DestroyObject(pdlight4);
}
}
}
}