Vehicle alarm script help.. -
viddo - 16.04.2012
Okay so, i made a code that if a player bought an alarm and someone tried entering it it will send a message for nearby players... But it worked for anycar even if it doesn't have an alarm...
Код:
if(CarInfo[car][cAlarm] = 1)
{
format(string, sizeof(string), "*[Vehicle Alarm] BEEP! BEEP! BEEP!");
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
}
Note: I have created another command that sets the cAlarm to 1 if he bought it or something...
Re: Vehicle alarm script help.. -
aRoach - 16.04.2012
And where did you put this snippet of code ?
Re: Vehicle alarm script help.. -
viddo - 16.04.2012
OnPlayerStateChange
if(IsAnOwnableCar(newcar))
I made it to work only for the ownable cars IF they got the alarm but it work for any ownable car..
Re: Vehicle alarm script help.. -
aRoach - 16.04.2012
Can you give to us the whole snippet of code ?
Re: Vehicle alarm script help.. -
viddo - 16.04.2012
Код:
if(IsAnOwnableCar(newcar))
{
if(PlayerInfo[playerid][pPcarkey] == newcar) { CanTurnEngine[playerid] = newcar; }
else if(PlayerInfo[playerid][pPcarkey2] == newcar) { CanTurnEngine[playerid] = newcar; }
else
{
if(PlayerInfo[playerid][pAdmin] >= 5 && PlayerInfo[playerid][pAdminDuty] == 1)
{
SendClientMessage(playerid, COLOR_GREY, " You can drive this car because you are admin on duty !");
}
else
{
if(CarInfo[newcar][cLock] == 1)
{
CanTurnEngine[playerid] = 9999;
new vID = GetPlayerVehicleID(playerid);
SetVehicleParamsForPlayer(vID, playerid, 0, 1);
TogglePlayerControllable(playerid, 0);
if(PlayerInfo[playerid][pDecoder] == 1)
{
}
}
else
{
new vID = GetPlayerVehicleID(playerid);
SendClientMessage(playerid, COLOR_GREY,"* Car is not locked so you can start the engine!");
CanTurnEngine[playerid] = newcar;
SetVehicleParamsForPlayer(vID, playerid, 0, 0);
}
}
}
new car
if(CarInfo[car][cAlarm] = 1)
{
format(string, sizeof(string), "*[Vehicle Alarm] BEEP! BEEP! BEEP!");
ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
}
if(cDebug == 1) SendClientMessageToAll(COLOR_LIGHT_BLUE,"[DEBUG]: Ownable Car");
}
That's the alarm when it beeps.
Код:
else if(strcmp(x_nr,"buyalarm",true) == 0)
{
if(PlayerInfo[playerid][pPcarkey] == 9999 && PlayerInfo[playerid][pPcarkey2] == 9999)
{
SendClientMessage(playerid, COLOR_GREY,"* You don't have a vehicle.");
return 1;
}
if(!IsAtDealership(playerid))
{
SendClientMessage(playerid, COLOR_GREY,"* You must be at a Dealership to do this!");
return 1;
}
if(GetPlayerMoney(playerid) < 1000)
{
SendClientMessage(playerid, COLOR_GREY,"* You don't have enough money for vehicle alarm.");
return 1;
}
new car;
if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey]) { vehid = PlayerInfo[playerid][pPcarkey]; }
else if(GetPlayerVehicleID(playerid) == PlayerInfo[playerid][pPcarkey2]) { vehid = PlayerInfo[playerid][pPcarkey2]; }
else { return 1; }
if(IsPlayerInVehicle(playerid, vehid))
{
SafeGivePlayerMoney(playerid, -1000);
GameTextForPlayer(playerid, "~w~Alarm ~r~ installed", 5000, 1);
CarInfo[car][cAlarm] = 1;
OnPropUpdate(4,vehid);
OnPlayerUpdateEx(playerid);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GREY," You are not in your vehicle.");
return 1;
}
}
And that's when you buy the alarm..