Just some questions

Started by Mötley, Mar 21, 2016, 07:58 PM

Previous topic - Next topic

Mötley

(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

KAKAN

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
oh no

rww

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)
Join to Irrelevant Club Discord: https://discord.gg/MsPPZ5uV4X

MacTavish

#3
@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

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

KAKAN

Quotefunction onScriptLoad()
{
local WEP = [];
}
Seriously? Local?
oh no

MacTavish

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

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Mötley

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!!!


Thijn

What distance do you need then?

Mötley

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.

Thijn

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.

Mötley

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

aXXo

#11
Quote from: Mr_Motley on Mar 22, 2016, 08:29 PMAlso there is nothing really wrong with writing to files.
[Benchmark] SQLite vs INI

Mötley

#12
**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 ??

Thijn

@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...

.

@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.
.