I can't figure this out -
Stefand - 18.06.2012
Hello,
I played another RP server and there I saw that they used /flash to put flash on and /flash to put them off.
I made a script for /flash and /flashoff but maybe someone on the forum can make /flash to /flash for on and if the lights are on then /flash for off.
pawn Код:
command(flash, playerid, params[])
{
new vehicleid,panels,doors,lights,tires;
if(Groups[Player[playerid][Group]][CommandTypes] == 1)
if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
{
return SendClientMessage(playerid, -1, "* You are not the driver!");
}
new pveh = GetPlayerVehicleID(playerid);
if (!GetVehicleModel(pveh)) return SendClientMessage(playerid, -1, "* You are not in a vehicle!");
switch (GetVehicleModel(pveh))
{
case 596:
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
AttachObjectToVehicle(obj2[pveh], pveh, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
Flasher[vehicleid] = 1;
}
case 597:
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
AttachObjectToVehicle(obj2[pveh], pveh, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
Flasher[vehicleid] = 1;
}
case 598:
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.524999, -0.300000, 0.899999, 0.000000, 0.000000, 0.000000);
AttachObjectToVehicle(obj2[pveh], pveh, -0.524999, -0.300000, 0.899999, 0.000000, 0.000000, 0.000000);
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
Flasher[vehicleid] = 1;
}
case 599:
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.524999,0.000000,1.125000,0.000000,0.000000,0.000000);
AttachObjectToVehicle(obj2[pveh], pveh, -0.524999,0.000000,1.125000,0.000000,0.000000,0.000000);
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
Flasher[vehicleid] = 1;
}
case 541://bullet
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.375000,0.524999,0.375000,0.000000,0.000000,0.000000);
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
Flasher[vehicleid] = 1;
}
case 426://premier
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.524999,0.749999,0.375000,0.000000,0.000000,0.000000);
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
Flasher[vehicleid] = 1;
}
case 427://enforcer
{
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
Flasher[vehicleid] = 1;
}
case 560://sultan
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.225000,0.750000,0.449999,0.000000,0.000000,0.000000);
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
Flasher[vehicleid] = 1;
}
case 490://FBI
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.000000,1.125000,0.599999,0.000000,0.000000,0.000000);
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
Flasher[vehicleid] = 1;
}
default:
{
return SendClientMessage(playerid, -1, "You are not in a CODE 2 compatible police vehicle!");
}
}
return SendClientMessage(playerid, -1, "Lights on, you are now in a CODE 2 run!");
}
command(flashoff, playerid, params[])
{
new vehicleid,panels,doors,lights,tires;
new pveh = GetPlayerVehicleID(playerid);
if(Groups[Player[playerid][Group]][CommandTypes] == 1)
{
if (IsValidObject(obj[pveh]) || IsValidObject(obj2[pveh]))
SendClientMessage(playerid, -1, "You switched off the lights."), DestroyObject(obj[pveh]), DestroyObject(obj2[pveh]);
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
if(LightPwr[vehicleid] == 1)
UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
else
UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
Flasher[vehicleid] = 0;
}
return 1;
}
Re: I can't figure this out -
FUNExtreme - 18.06.2012
Create a variable like: new bool:flash[max_players] ;
Then in the command you do
pawn Код:
flash command
{
If(flash[playerid] == false)
{
//everything to turn flash on
flash[playerid] = true;
}
else
{
//everything for flash off
flash[playerid] = false;
}
return 1;
}
Sorry for indentation! I'm on the phone
Re: I can't figure this out -
Stefand - 19.06.2012
Will try when home (phone too:P)
Re: I can't figure this out -
Audi_Quattrix - 19.06.2012
On top new Flash[MAX_PLAYERS];
OnPlayer connect Flash[playerid] = 0;
OnPlayerDisconnect Flash[playerid] = 0;
and on command if (Flash[playerid] ==0)
Command here
Flash[playerid] = 1;
then if (Flash[playerid] == 1)
Turn command off
Flash[playerid] = 0;
Re: I can't figure this out -
BrandyPenguin - 19.06.2012
I think that line
pawn Код:
GetVehicleDamageStatus(pveh,panels,doors,lights,tires);
is unneeded there because you not use SetVehicleDamageStatus...?
Anyway the code i think should work:
pawn Код:
new Flashing[MAX_VEHICLES]; // Top of script.
//Untested but may work.
command(flash, playerid, params[])
{
new vehicleid,panels,doors,lights,tires;
if(Groups[Player[playerid][Group]][CommandTypes] == 1)
if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "* You are not the driver!");
new pveh = GetPlayerVehicleID(playerid);
if(!Flashing[pveh]) {
// Lights not flashing
if (!GetVehicleModel(pveh)) return SendClientMessage(playerid, -1, "* You are not in a vehicle!");
switch (GetVehicleModel(pveh))
{
case 596:
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
AttachObjectToVehicle(obj2[pveh], pveh, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
GetVehicleDamageStatus(pveh,panels,doors,lights,tires);
Flasher[pveh] = 1;
}
case 597:
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
AttachObjectToVehicle(obj2[pveh], pveh, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
GetVehicleDamageStatus(pveh,panels,doors,lights,tires);
Flasher[pveh] = 1;
}
case 598:
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.524999, -0.300000, 0.899999, 0.000000, 0.000000, 0.000000);
AttachObjectToVehicle(obj2[pveh], pveh, -0.524999, -0.300000, 0.899999, 0.000000, 0.000000, 0.000000);
GetVehicleDamageStatus(pveh,panels,doors,lights,tires);
Flasher[pveh] = 1;
}
case 599:
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.524999,0.000000,1.125000,0.000000,0.000000,0.000000);
AttachObjectToVehicle(obj2[pveh], pveh, -0.524999,0.000000,1.125000,0.000000,0.000000,0.000000);
GetVehicleDamageStatus(pveh,panels,doors,lights,tires);
Flasher[pveh] = 1;
}
case 541://bullet
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.375000,0.524999,0.375000,0.000000,0.000000,0.000000);
GetVehicleDamageStatus(pveh,panels,doors,lights,tires);
Flasher[pveh] = 1;
}
case 426://premier
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.524999,0.749999,0.375000,0.000000,0.000000,0.000000);
GetVehicleDamageStatus(pveh,panels,doors,lights,tires);
Flasher[pveh] = 1;
}
case 427://enforcer
{
GetVehicleDamageStatus(pveh,panels,doors,lights,tires);
Flasher[pveh] = 1;
}
case 560://sultan
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.225000,0.750000,0.449999,0.000000,0.000000,0.000000);
GetVehicleDamageStatus(pveh,panels,doors,lights,tires);
Flasher[pveh] = 1;
}
case 490://FBI
{
obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
AttachObjectToVehicle(obj[pveh], pveh, 0.000000,1.125000,0.599999,0.000000,0.000000,0.000000);
GetVehicleDamageStatus(pveh,panels,doors,lights,tires);
Flasher[pveh] = 1;
}
default:
{
return SendClientMessage(playerid, -1, "You are not in a CODE 2 compatible police vehicle!");
}
}Flashing[pveh] =1;
return SendClientMessage(playerid, -1, "Lights on, you are now in a CODE 2 run!");
} else {
if(Groups[Player[playerid][Group]][CommandTypes] == 1)
{
if (IsValidObject(obj[pveh]) || IsValidObject(obj2[pveh]))
SendClientMessage(playerid, -1, "You switched off the lights."), DestroyObject(obj[pveh]), DestroyObject(obj2[pveh]);
GetVehicleDamageStatus(pveh,panels,doors,lights,tires);
if(LightPwr[pveh] == 1)
UpdateVehicleDamageStatus(pveh, panels, doors, 0, tires);
else
UpdateVehicleDamageStatus(pveh, panels, doors, 5, tires);
Flasher[pveh] = 0;
Flashing[pveh] =0;
}
}
}