Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Kewun on May 05, 2016, 03:32 PM

Title: vehicle time
Post by: Kewun on May 05, 2016, 03:32 PM
anyone knows how to change vehicle respawn time? i hate it instant respawning :/
Title: Re: vehicle time
Post by: jayant on May 05, 2016, 04:07 PM
Vehicle.Respawn
Vehicle.RespawnTimer

I found these ^ in wiki..
Title: Re: vehicle time
Post by: KAKAN on May 05, 2016, 04:09 PM
vehicle.RespawnTimer = TimeInMS.
It's there in the wiki.

Quote from: jayant on May 05, 2016, 04:07 PMVehicle.Respawn
Vehicle.RespawnTimer

I found these ^ in wiki..
vehicle.Respawn is a function which will respawn the vehicle.
Title: Re: vehicle time
Post by: Kewun on May 05, 2016, 04:09 PM
how to set them for all vehicles?
Title: Re: vehicle time
Post by: Thijn on May 05, 2016, 05:36 PM
Loop through them all.
Title: Re: vehicle time
Post by: Kewun on May 05, 2016, 06:10 PM
how to loop? im noob in scripting
Title: Re: vehicle time
Post by: Mötley on May 05, 2016, 06:39 PM
I am busy(at work)
but when thijn said loop he is correct.

I haven't checked if there's any loop tutorials on vcmp but this should help in some type of way someone can correct me if wrong. I refer to this method once a while.

It's a while loop :P
http://forum.liberty-unleashed.co.uk/index.php/topic,629.0.html
Title: Re: vehicle time
Post by: jayant on May 05, 2016, 07:06 PM
/*With for loop*/
Syntax:

for(declare & intialise variable;condition;increment/decrement)
{
 //Statements to execute
}

for( local i=130; i <= GetVehicleCount(); i++ )
        {
        local veh = FindVehicle( i );
        if(veh)
       {
       veh.RespawnTimer = 10000;
        }
       }

/*While loop*/

Syntax:

Declare and initialise variable;
while(condition)/*Entry controlled loop*/
{
 //Statements to execute
}

So,

local i = 130;
while(i<=GetVehicleCount)
{
 local veh = FindVehicle(i);
 if(veh)
 {
 veh.RespawnTimer = 1000;
}
i++;
}

/*Do while loop*/
Syntax:

do
{
 //Statements to execute
i++;
}while(condtion);
So, you can do the same in do-while loop.
Examples are untested.
Title: Re: vehicle time
Post by: Mötley on May 05, 2016, 07:09 PM
Nice! @jayant
Title: Re: vehicle time
Post by: Kewun on May 05, 2016, 07:25 PM
thx man
Title: Re: vehicle time
Post by: Murdock on May 05, 2016, 07:26 PM
Quote from: Kewun on May 05, 2016, 06:10 PMhow to loop? im noob in scripting

Why dont you take some basic programming courses first before you get into scripting..
Title: Re: vehicle time
Post by: Kewun on May 05, 2016, 07:27 PM
then where can i learn squirrel language? ???

im not that very noob in scripting, i know basic functions,  i only dont know advanced things like loops, datas etc
Title: Re: vehicle time
Post by: Murdock on May 05, 2016, 07:31 PM
Quote from: Kewun on May 05, 2016, 07:27 PMthen where can i learn squirrel language? ???

im not that very noob in scripting, i know basic functions,  i only dont know advanced things like loops, datas etc

I suggest you start with learning a type-safe language so you avoid learning any bad habits. Once you've done that Squirrel should be fairly similar to other programming languages
Title: Re: vehicle time
Post by: KAKAN on May 06, 2016, 04:43 AM
Quote from: Kewun on May 05, 2016, 07:27 PMthen where can i learn squirrel language? ???

im not that very noob in scripting, i know basic functions,  i only dont know advanced things like loops, datas etc

w3schools.com
go there and learn PHP, then come to Squirrel, you'll find it easy to program then :D
Here's a sample script for your vehicle loop thingy :D :
http://pastebin.com/rmnjbJsD
Title: Re: vehicle time
Post by: Kewun on May 06, 2016, 05:24 AM
nope, the example script does not work. somehow they are still respawning instantly after explosion..
Title: Re: vehicle time
Post by: Thijn on May 06, 2016, 06:25 AM
Do you actually call that function anywhere?
Title: Re: vehicle time
Post by: jayant on May 06, 2016, 06:27 AM
Quote from: jayant on May 05, 2016, 07:06 PMExamples are untested.
@Kewun  I was just trying to explain usage of loops.
Title: Re: vehicle time
Post by: KAKAN on May 06, 2016, 08:18 AM
Quote from: Thijn on May 06, 2016, 06:25 AMDo you actually call that function anywhere?
Thijn, you didn't get him, from his last post, I get to know that, he wants to slow down the respawn time when a vehicle gets destroyed.
Aka: When the vehicles gets destroyed, it respawns automagically, he wants to control it via his script. The only method I can think of is to remove the vehicle and add it again later using timers
Title: Re: vehicle time
Post by: Milos on May 06, 2016, 01:57 PM
Quote from: jayant on May 05, 2016, 07:06 PM/*With for loop*/
Syntax:

for(declare & intialise variable;condition;increment/decrement)
{
 //Statements to execute
}

for( local i=130; i <= GetVehicleCount(); i++ )
        {
        local veh = FindVehicle( i );
        if(veh)
       {
       veh.RespawnTimer = 10000;
        }
       }

/*While loop*/

Syntax:

Declare and initialise variable;
while(condition)/*Entry controlled loop*/
{
 //Statements to execute
}

So,

local i = 130;
while(i<=GetVehicleCount)
{
 local veh = FindVehicle(i);
 if(veh)
 {
 veh.RespawnTimer = 1000;
}
i++;
}

/*Do while loop*/
Syntax:

do
{
 //Statements to execute
i++;
}while(condtion);
So, you can do the same in do-while loop.
Examples are untested.
These loops does not configure all vehicles
I think you are confusing ID and Model
Title: Re: vehicle time
Post by: jayant on May 06, 2016, 02:38 PM
Quote from: jayant on May 06, 2016, 06:27 AM
Quote from: jayant on May 05, 2016, 07:06 PMExamples are untested.
@Kewun  I was just trying to explain usage of loops.
Title: Re: vehicle time
Post by: Thijn on May 06, 2016, 03:16 PM
Quote from: KAKAN on May 06, 2016, 08:18 AM
Quote from: Thijn on May 06, 2016, 06:25 AMDo you actually call that function anywhere?
Thijn, you didn't get him, from his last post, I get to know that, he wants to slow down the respawn time when a vehicle gets destroyed.
Aka: When the vehicles gets destroyed, it respawns automagically, he wants to control it via his script. The only method I can think of is to remove the vehicle and add it again later using timers
That's exactly what Vehicle.RespawnTime is for. And that code snippet should work by the looks of it.
Title: Re: vehicle time
Post by: Mötley on May 06, 2016, 03:38 PM
So there is no need to remove cars xml side and script them in server side to take full control? just curious @Thijn ,. This is one nice thing to do at least in [LU]. I have not tried in [VC:MP] yet

 :P(allows entire full control over vehicles regardless of anything what so ever. I find that the cars in xml have there own setting that scripting nature could not fully control at times, it just helps..)
Title: Re: vehicle time
Post by: Thijn on May 06, 2016, 06:14 PM
Quote from: Mötley on May 06, 2016, 03:38 PMSo there is no need to remove cars xml side and script them in server side to take full control? just curious @Thijn ,. This is one nice thing to do at least in [LU]. I have not tried in [VC:MP] yet

 :P(allows entire full control over vehicles regardless of anything what so ever. I find that the cars in xml have there own setting that scripting nature could not fully control at times, it just helps..)
Your post made no sense to me. Care to elaborate?
Title: Re: vehicle time
Post by: Mötley on May 06, 2016, 08:01 PM
I will try (on my phone/away from pc)

I will explain LU wise as I can explain more accurate.

So basically a lot of times when cars are spawned into the world from the server xml, the xml will overwrite respawn time as well as keeping the exact amount of damage as I have seen these cars overwrite scripting features.

When using ::CreateVehicle (I believe that is what it is) I can fully do anything I want to cars keeping the exact amount of damage to a vehicle for say 10 days of the server running, as well as keeping cars where they were last used, but sometimes cars would become bugged and it's impossible to enter a car by the 4th day.

I found that the xml overwrites features a lot of times.

So I am curious if his script is not incorrect..
 :P unless someone can verify

@Thijn 

Okay so I ran some test finnaly and removed the vehicles from the xml to server side and added the cars with CreateVehicle
What happens with
Vehicle.RespawnTimeris that it will respawn the vehicle over and over again. Basically if not used and you change the time of the created vehicle to say 100 it will keep creating the vehicle causing 99.9 percent bad data usage,
What is needed is a delay not a respawn.timer.

Maybe with the code
FindVehiclefollowing [player.ID]
And add Vehicle.Remove somewhere where that would be valid without the players vehicle disapering pis*ing off the player base.

This should cause the vehicle to not get recreated if I am correct. then the vehicle should create on that next long re-spawn timer of
Vehicle.RespawnTimer
as the vehicle does need to be removed from the server and with server side scripting the vehicle can be re created at another time.

If you could shoot me a way that's valid
on Vehicle.Remove without the players vehicle disappearing pis*ing off the player base.
I will most definitely do that. and respond with my answer.