Morning Guys!
So... I did it!
As I said before, I was trying to call a specific function, which would allow me to buy the vehicle only once.
After that, the vehicle will be free to use by any player.
And it would only be bought again if it was destroyed or sunk.
And as I expected, the script is quite simple!
Well, at least I found a simple solution.
Here is the code:
Note that I used "vehicle.IsGhost" instead of "vehicle.Locked".
The second function just didn't work in this case. I don't know wy.
But the first function works fine. With a small caveat:
All vehicles spawned are now "Ghost Vehicles".
This means that they lost the effect of collision with other vehicles.
However, once purchased, it returns to the collision effect, and everything goes back to normal.
At least with the vehicle you just bought.
Those that have not yet been purchased remains "Ghost Vehicles".
So, this is it!
That's my solution!
If anyone has a better idea, don't hesitate to let me know.
See u guys!
So... I did it!
As I said before, I was trying to call a specific function, which would allow me to buy the vehicle only once.
After that, the vehicle will be free to use by any player.
And it would only be bought again if it was destroyed or sunk.
And as I expected, the script is quite simple!
Well, at least I found a simple solution.
Here is the code:
Code Select
function onPlayerEnteringVehicle( player, vehicle, door )
{
if (vehicle.Model == 132)
{
if (vehicle.IsGhost == false) return true;
else if (player.Cash < 2500) MessagePlayer("[#00cc00] Need enough money!",player);
else{
player.Cash -= 2500;
MessagePlayer("[#00cc00] You buy a Car! Congratz!",player);
return true;
}
}
if (vehicle.Model == 141)
{
if (vehicle.IsGhost == false) return true;
else if (player.Cash < 5000) MessagePlayer("[#00cc00] Need enough money!",player);
else{
player.Cash -= 5000;
MessagePlayer("[#00cc00] You buy a Car! Congratz!",player);
return true;
}
}
}
function onPlayerEnterVehicle( player, vehicle, door )
{
vehicle.IsGhost = false;
}
function onVehicleRespawn( vehicle )
{
vehicle.IsGhost = true;
}
Note that I used "vehicle.IsGhost" instead of "vehicle.Locked".
The second function just didn't work in this case. I don't know wy.
But the first function works fine. With a small caveat:
All vehicles spawned are now "Ghost Vehicles".
This means that they lost the effect of collision with other vehicles.
However, once purchased, it returns to the collision effect, and everything goes back to normal.
At least with the vehicle you just bought.
Those that have not yet been purchased remains "Ghost Vehicles".
So, this is it!
That's my solution!
If anyone has a better idea, don't hesitate to let me know.
See u guys!