Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Mötley on Dec 21, 2016, 05:39 PM

Title: Remove players from a specific vehicle
Post by: Mötley on Dec 21, 2016, 05:39 PM
Well my server is setup to where if a player spawns a vehicle there last spawned vehicle is automatically removed.

I would to receive help on properly removing all players from that vehicle, Which means each seat, And hopefully no loop, And nothing that will alter data usage.



In the commands I added a simple array to store the vehicle.ID in, This array never gets cleared 'So far', Unless I plan to remove the vehicle on player part. So when the player spawns another vehicle that vehicle is automatically removed, Even if it belonged to another player 'Same array value, player.ID etc etc..

   
    if (Added_Vehicle[player.ID] > 0)
    {
        local vehicle = FindVehicle(Added_Vehicle[player.ID]);
        if (vehicle)
        {
            vehicle.Remove();
        }
    };

Now this is setup to prevent data usage, lag and so on.. Max limits on vehicles, command spaming vehicles into the server. Prevent server crashing.. blah blah blah....



If someone could help me with the concept of how I should go about scripting it, And maybe how I should add it to the server. I would be really happy.

Last I checked if a player/players happens to be in a vehicle and it is removed, This results in death and possible rage, Maybe even a /quit
Title: Re: Remove players from a specific vehicle
Post by: DizzasTeR on Dec 21, 2016, 05:46 PM
Why not a loop? Just why? Why do loops exist? To loop through players in VCMP only? Use the loops...
Title: Re: Remove players from a specific vehicle
Post by: Mötley on Dec 21, 2016, 05:58 PM
Quote from: Doom_Kill3R on Dec 21, 2016, 05:46 PMWhy not a loop? Just why? Why do loops exist? To loop through players in VCMP only? Use the loops...

Then how should I go about the loop? How should I go about detecting each seat a player is in? Maybe the player is a passenger and there is no driver, Maybe there is a driver and passenger... What is the max amount of players in one of the vehicle, Maybe the bus can hold a lot of players.. Not really sure about the max amount of players in certain vehicles..
Title: Re: Remove players from a specific vehicle
Post by: DizzasTeR on Dec 21, 2016, 06:03 PM
Why not just straight up delete the vehicle? The players will just end up on foot nothing else.
Title: Re: Remove players from a specific vehicle
Post by: Mötley on Dec 21, 2016, 06:06 PM
Quote from: Doom_Kill3R on Dec 21, 2016, 06:03 PMWhy not just straight up delete the vehicle? The players will just end up on foot nothing else.

Quote from: Mötley on Dec 21, 2016, 05:39 PMLast I checked if a player/players happens to be in a vehicle and it is removed, This results in death and possible rage, Maybe even a /quit

I will trust what you say, I have tested before in the past that players will die. I can no longer have two game windows open. So I can not re-check. Thanks for the advice
Title: Re: Remove players from a specific vehicle
Post by: DizzasTeR on Dec 21, 2016, 06:33 PM
Death? Why? I don't recall that happening though...
Title: Re: Remove players from a specific vehicle
Post by: Mötley on Dec 21, 2016, 06:54 PM
Could of been a script issue or a previous vcmp version not [0.4].

Can't recall I just remember it happening during testing..
Title: Re: Remove players from a specific vehicle
Post by: aXXo on Dec 21, 2016, 08:45 PM
vehicle.Driver (http://http://wiki.vc-mp.org/index.php?title=Scripting/Squirrel/Functions/Vehicle.Driver&action=edit&redlink=1) and vehicle.GetOccupant (http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/Vehicle.GetOccupant)