04.09.2011, 00:01
Hi, I made a little system for my server so bandits must shoot a cars door to be able to enter it...
for that I used the OnEmptyVehicleDamage callback, wich could be downloaded in an include
here you can see alot of code, but it's pretty much al the same, ok so, there are 6 different types of cars u can steal and each one has a different difficult level...
When I made this system I only made it that you can only steal carID 516, to test if my script works, so now, what I did was I added more vehicles... but for some reason it does not work anymore :/
when I used only one vehicle to steal u would get the message saying "U have unlocked the vehicle", and u were be able to enter the car... the system worked perfect
but since I added more cars I don't get the message no more, and the vehicle does not get unlocked :/
here's the unlock code to check if a vehicle is locked:
any help
for that I used the OnEmptyVehicleDamage callback, wich could be downloaded in an include
pawn Код:
public OnEmptyVehicleDamage(vehicleid,playerid,exems)
{
new panels,doors,lights,tires;
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
//==============================================================================
//Vehicle Unlock system
//==============================================================================
if(IsPlayerLookingAtVehicle(playerid,vehicleid))
{
if(gTeam[playerid] == TEAM_BANDIT)
{
if(unlocked[vehicleid] != 0)
{
GameTextForPlayer(playerid,"~y~This vehicle is already unlocked!",4000,3);
return 1;
}
new vehicle;
vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
//////////
//Nebula//
//////////
if(unlocked[vehicleid] == 0)
{
if(vehicle == 516)
{
if(doors <100)
{
new crand = random(100);
if(crand <= 10)
{
GameTextForPlayer(playerid,"~r~U have failed shooting the lock of this door, try another car...",4000,3);
funlocked[vehicleid] = 1;
SetTimer("lockshotrectim", 30000, false);
unlocked[vehicleid] = 0;
}
else if(crand > 10)
{
unlocked[vehicleid] = 1;
GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
}
}
}
//////////////
//Washington//
//////////////
else if(vehicle == 421)
{
if(doors <100)
{
new crand = random(100);
if(crand <= 30)
{
GameTextForPlayer(playerid,"~r~U have failed shooting the lock of this door, try another car...",4000,3);
funlocked[vehicleid] = 1;
SetTimer("lockshotrectim", 30000, false);
unlocked[vehicleid] = 0;
}
else if(crand > 30)
{
unlocked[vehicleid] = 1;
GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
}
}
}
///////////
//stretch//
///////////
else if(vehicle == 409)
{
if(doors <100)
{
new crand = random(100);
if(crand <= 60)
{
GameTextForPlayer(playerid,"~r~U have failed shooting the lock of this door, try another car...",4000,3);
funlocked[vehicleid] = 1;
SetTimer("lockshotrectim", 30000, false);
unlocked[vehicleid] = 0;
}
else if(crand > 60)
{
unlocked[vehicleid] = 1;
GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
}
}
}
//======================================================
//Cops
//======================================================
////////
//Lspd//
////////
else if(vehicle == 596 || vehicle == 599)
{
if(doors <100)
{
new crand = random(100);
if(crand <= 75)
{
GameTextForPlayer(playerid,"~r~U have failed shooting the lock of good this secured door, try another car...",4000,3);
funlocked[vehicleid] = 1;
SetTimer("lockshotrectim", 30000, false);
unlocked[vehicleid] = 0;
}
else if(crand > 75)
{
unlocked[vehicleid] = 1;
GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
}
}
}
///////////
//S.W.A.T//
///////////
else if(vehicle == 601)
{
if(doors <100)
{
new crand = random(100);
if(crand <= 90)
{
GameTextForPlayer(playerid,"~r~U have failed shooting the lock of this heavy secured door, try another car...",4000,3);
funlocked[vehicleid] = 1;
SetTimer("lockshotrectim", 30000, false);
unlocked[vehicleid] = 0;
}
else if(crand > 90)
{
unlocked[vehicleid] = 1;
GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
}
}
}
///////
//FBI//
///////
else if(vehicle == 490)
{
if(doors <100)
{
new crand = random(100);
if(crand <= 95)
{
GameTextForPlayer(playerid,"~r~U have failed shooting the lock of this heavy secured door, try another car...",4000,3);
funlocked[vehicleid] = 1;
SetTimer("lockshotrectim", 30000, false);
unlocked[vehicleid] = 0;
}
else if(crand > 95)
{
unlocked[vehicleid] = 1;
GameTextForPlayer(playerid,"~y~U have unlocked this Vehicle by shooting its door!",4000,3);
}
}
}
}
}
}
return 1;
}
When I made this system I only made it that you can only steal carID 516, to test if my script works, so now, what I did was I added more vehicles... but for some reason it does not work anymore :/
when I used only one vehicle to steal u would get the message saying "U have unlocked the vehicle", and u were be able to enter the car... the system worked perfect
but since I added more cars I don't get the message no more, and the vehicle does not get unlocked :/
here's the unlock code to check if a vehicle is locked:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(unlocked[vehicleid] == 0)
{
if(gTeam[playerid] == TEAM_BANDIT)
{
SendClientMessage(playerid, COLOR_RED, "This vehicle is locked for you! Shoot its door to open the vehicle");
TogglePlayerControllable(playerid,0);
TogglePlayerControllable(playerid,1);
return 1;
}
}
if(funlocked[vehicleid] == 1)
{
SendClientMessage(playerid, COLOR_RED, "You have failed braking the lock of this vehicle, try another car!");
TogglePlayerControllable(playerid,0);
TogglePlayerControllable(playerid,1);
return 1;
}
return 1;
}
![Huh?](images/smilies/confused.gif)