Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Mötley on Mar 21, 2016, 07:58 PM

Title: Just some questions
Post by: Mötley on Mar 21, 2016, 07:58 PM
(1) No longer needed What is a correct function to get the distance for a players movement?
(2) What is the best options for messages on entering vehicles
(any message that will allow a time change say"60 secs to return to vehicle with countdown ex 60 59 58 etc")
(3)No longer needed What is the correct uses of function onPlayerWeaponChange( player, ammo, nWep )??
(4)Maybe it is part of my scripting but i noticed if I run over a player the body part returns "0" rather than scripted Torso?
(5)Fixed Can I use onPlayerEnterVehicle(player, vehicle, seat) I am using [vehicle.ID] in this function and checking the players seat usage.
(6)FIXED onScriptUnload() is broken with Reloadscripts(); on [Hours] of "6" so I am building other alternatives

I just need some scripting help as I am the only scriptwriter of my server, so I would like to politely seek info.

I am not asking for fix this script etc just seeking info on certain stuff and small issues..

Any help is appericiated

It seems Announce is very nice

After playing with some of the values they work just as i was hoping they would any good pointers for this function would be appreciated

https://www.youtube.com/watch?v=PTPlzMgzhzs&feature=youtu.be

^ just a simple example/ wont actually use this message for your mute in game
Title: Re: Just some questions
Post by: KAKAN on Mar 22, 2016, 06:44 AM
function onScriptLoad(){
IsMuted <- array(100, false);
MuteTime <- array(100,0);
}

function onPlayerChat( player, text ){
if( IsMuted[ player.ID ] ) return PrivMessage( player, ( time() - MuteTime[ player.ID ] ) + "secs remaining");
MuteTime[ player.ID ] = time();
}
That's not the code actually. Just an example :P
You can use this method everywhere :D
I was on phone
Title: Re: Just some questions
Post by: rww on Mar 22, 2016, 07:57 AM
Some answers you can find here -> https://bitbucket.org/stormeus/0.4-squirrel/src

So:

1) http://forum.vc-mp.org/?topic=2240.msg16541#msg16541

3) function onPlayerWeaponChange(player,oldwep,newwep)
Title: Re: Just some questions
Post by: MacTavish on Mar 22, 2016, 08:07 AM
@Mr_Motley its function onPlayerWeaponChange( player, oWep, nWep ) not function onPlayerWeaponChange( player, ammo, nWep )
and actually i made something cool you may like


function onScriptLoad()
{
WEP <- [];
}

function onPlayerPart( player, reason )
{
for (local d = WEP.len()-1; d >= 0; d--)
 {
  if (WEP[d].Player.ID == player.ID)
  {
   if (WEP[d].Text != null) WEP[d].Text.Delete();
   WEP.remove(d);
   break;
  }
 }
}


function onPlayerWeaponChange( player, oldWep, newWep )
{
WEP.push({Player = player, Text = null});
DrawWEP();
}
function DrawWEP()
{
 foreach (val in WEP)
 {
  if (val.Text != null) val.Text.Delete();
  val.Text = CreateTextdraw("Current Weapon: " + GetWeaponName( val.Player.Weapon ), 20, -250, 0xFFFF69B4);
  if (val.Text != null) val.Text.ShowForPlayer(val.Player);
 }
}


Edited: onScriptLoad
Title: Re: Just some questions
Post by: KAKAN on Mar 22, 2016, 09:03 AM
Quotefunction onScriptLoad()
{
local WEP = [];
}
Seriously? Local?
Title: Re: Just some questions
Post by: MacTavish on Mar 22, 2016, 10:12 AM
Quote from: KAKAN on Mar 22, 2016, 09:03 AM
Quotefunction onScriptLoad()
{
local WEP = [];
}
Seriously? Local?
Sorry :P Actually in my script i've placed that outside of onScriptLoad BTW edited that line
Title: Re: Just some questions
Post by: Mötley on Mar 22, 2016, 03:24 PM
Quote from: KAKAN on Mar 22, 2016, 06:44 AMfunction onScriptLoad(){
IsMuted <- array(100, false);
MuteTime <- array(100,0);
}

function onPlayerChat( player, text ){
if( IsMuted[ player.ID ] ) return PrivMessage( player, ( time() - MuteTime[ player.ID ] ) + "secs remaining");
MuteTime[ player.ID ] = time();
}
That's not the code actually. Just an example :P
You can use this method everywhere :D
I was on phone

This was just a test to ensure that i can change the message periodically. I plan to use this in the method of police missions. exiting cars etc. in that case you will have 60 seconds to return to the vehicle, press B to bust players

Quote from: rwwpl on Mar 22, 2016, 07:57 AMSome answers you can find here -> https://bitbucket.org/stormeus/0.4-squirrel/src

So:

1) http://forum.vc-mp.org/?topic=2240.msg16541#msg16541

3) function onPlayerWeaponChange(player,oldwep,newwep)

I have stress tested that distance function for what I am trying to use it for and it does not work in the style I need it for. I also tried the code that you had that I messaged you about and not even that version helps But that code of yours works perfect on idle kicks. I need to get that code to work as there is islands without hospitals, Yet more than one hospital on one island. I need to use this code with the function of onislandchange, getplayersisland, My first test at this time is writing the distance you walked or drove in genera and write it on file, If i can get that working I know I can build the script of death positions with accurate hospital readings and busted locations(excluding certain locations.

Quote from: Kusanagi on Mar 22, 2016, 08:07 AM@Mr_Motley its function onPlayerWeaponChange( player, oWep, nWep ) not function onPlayerWeaponChange( player, ammo, nWep )
and actually i made something cool you may like


function onScriptLoad()
{
WEP <- [];
}

function onPlayerPart( player, reason )
{
for (local d = WEP.len()-1; d >= 0; d--)
 {
  if (WEP[d].Player.ID == player.ID)
  {
   if (WEP[d].Text != null) WEP[d].Text.Delete();
   WEP.remove(d);
   break;
  }
 }
}


function onPlayerWeaponChange( player, oldWep, newWep )
{
WEP.push({Player = player, Text = null});
DrawWEP();
}
function DrawWEP()
{
 foreach (val in WEP)
 {
  if (val.Text != null) val.Text.Delete();
  val.Text = CreateTextdraw("Current Weapon: " + GetWeaponName( val.Player.Weapon ), 20, -250, 0xFFFF69B4);
  if (val.Text != null) val.Text.ShowForPlayer(val.Player);
 }
}


Edited: onScriptLoad

Honestly After some thoughts i do not need the function onweaponchange as weapons and data gets saved every 5 minutes or when the player leaves the server all data is saved, I really do appreciate that CreateTextdraw example Kudos!!!

Title: Re: Just some questions
Post by: Thijn on Mar 22, 2016, 06:06 PM
What distance do you need then?
Title: Re: Just some questions
Post by: Mötley on Mar 22, 2016, 06:42 PM
Quote from: Thijn on Mar 22, 2016, 06:06 PMWhat distance do you need then?

How about distance traveled? I have played with Distance function and others but it seems impossible to get this correctly working. as I can't get the distance to write to file.
Title: Re: Just some questions
Post by: Thijn on Mar 22, 2016, 07:15 PM
Quote from: Mr_Motley on Mar 22, 2016, 06:42 PM
Quote from: Thijn on Mar 22, 2016, 06:06 PMWhat distance do you need then?

How about distance traveled? I have played with Distance function and others but it seems impossible to get this correctly working. as I can't get the distance to write to file.
Then don't blame the function, blame yourself for still wanting to write everything to files.
The function linked to works fine for calculating distance traveled. Show us some code and tell us what's not working.
Title: Re: Just some questions
Post by: Mötley on Mar 22, 2016, 08:29 PM
Quote from: Thijn on Mar 22, 2016, 07:15 PM
Quote from: Mr_Motley on Mar 22, 2016, 06:42 PM
Quote from: Thijn on Mar 22, 2016, 06:06 PMWhat distance do you need then?

How about distance traveled? I have played with Distance function and others but it seems impossible to get this correctly working. as I can't get the distance to write to file.
Then don't blame the function, blame yourself for still wanting to write everything to files.
The function linked to works fine for calculating distance traveled. Show us some code and tell us what's not working.

I will get that code in maybe 1-3 hours as I am in a meeting at the moment. Thanks for taking the time to help :)

Also there is nothing really wrong with writing to files. I actually did a lot of beefing up on ini's in my script. They are just as fast as any other method. But originally they were extremely slow and could not keep up. I am pleased the community was capable of helping me get the methods I prefer working with BIG THANKS!! :D
Title: Re: Just some questions
Post by: aXXo on Mar 22, 2016, 10:53 PM
Quote from: Mr_Motley on Mar 22, 2016, 08:29 PMAlso there is nothing really wrong with writing to files.
[Benchmark] SQLite vs INI (http://viceunderdogs.com/index.php?topic=2228.0)
Title: Re: Just some questions
Post by: Mötley on Mar 22, 2016, 10:59 PM
**Removed code as i found other methods around it.

@aXXo I Would really like someone like @S.L.C To view the script and run it and compare/view with his knowledge with SQlite with what I had to do to beef up the speed of ini as it took a long time and studying to make it happen. maybe SQLite is a little faster but I can guarantee you that I have peaked the performance of ini scripting.

I'd say S.L.C as he is very knowledgeable

My next question would have to be

Reloadscripts();
on [Hours] "6"  Should relate with the function onScriptUnload. But it appears that it happens to fast for it to message the server or save the data, Now I could be completely wrong with thinking that these two functions should relate ??
Title: Re: Just some questions
Post by: Thijn on Mar 23, 2016, 05:32 PM
@S.L.C. I'd very much like to see a MySQL comparison to INIs.

To be fair. The current INI implementation is horrible, and that's probably why it's so much slower then any other method. Let's not even begin about the limitations INIs give you. Grouping, ordering, joining. You'd all throw that away by using INIs...
Title: Re: Just some questions
Post by: . on Mar 23, 2016, 05:41 PM
@Thijn I just began work on the MySQL module. Might take a while until completed because I tend to experiment a lot with ideas to form something that is actually useful to the scripter. But I'll definitely do a comparison when I'll finish it because it's always good to know what are your best options.
Title: Re: Just some questions
Post by: Thijn on Mar 23, 2016, 05:45 PM
Quote from: S.L.C on Mar 23, 2016, 05:41 PM@Thijn I just began work on the MySQL module. Might take a while until completed because I tend to experiment a lot with ideas to form something that is actually useful to the scripter. But I'll definitely do a comparison when I'll finish it because it's always good to know what are your best options.
Awesome :)
Since MySQL has a big cache sitting in RAM I expect it to be much faster then both SQLite and INIs. But you never know :P
Title: Re: Just some questions
Post by: Mötley on Mar 23, 2016, 06:30 PM
I could still use an explanation to
Reloadscripts();on every [Hours] of "6" is how i have set this up  Shouldn't this relate with the function onScriptUnload?. But it appears that it happens to fast for it to message the server or save the data, Now I could be completely wrong with thinking that these two functions should relate ??
Title: Re: Just some questions
Post by: Thijn on Mar 23, 2016, 07:10 PM
Yes they should, and no they don't. It's a known issue.
Title: Re: Just some questions
Post by: Mötley on Mar 23, 2016, 07:15 PM
So maybe I should add save the player,message server restarted/ in the same function as reloadscripts in every 6 hours. kinda unprofessional as to it could make an incorrect call rather than to call when it actually happens, Thank you:another marked off my list. I will review the list and see what else I need to ask next

BUT does the method still work in the extent of preventing the server from bugging out, to much data uses etc? as I have attempted to add this in case something lags for odd reasons or anything in general, just server protection. [Basically I am asking is it still useful?]