Author Topic: Aiming with Sniper Rifle (Script)  (Read 1382 times)

theasl99

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-6
  • You fuck with me!, you fucking with the best!
    • View Profile
    • https://www.youtube.com/c/theasl99original
Aiming with Sniper Rifle (Script)
« on: June 25, 2020, 05:51:49 am »
Surprise! What is theasl99 doing here? This is my first post

I do not know if someone has already made a post of this, but I who have been reading the wiki and this page to make my roleplay server have not seen any script that allows the possibility of pointing while firing a sniper rifle

this is a small fix for users who shoot with sniper, since when you shoot with sniper, the player does not generate any animation and in my opinion it is quite annoying

I am just starting out in scripting and I saw this piece of useful script, if you have ideas to improve it with pleasure I accept them, I am an old user of the community as of 2011, some should already know me, greetings to all.  8)

:::THE SCRIPT:::



local sniper = 0;
local snipershoot = 0;

function onPlayerWeaponChange( player, oldwep, newwep, ammo )
{
if ( newwep == WEP_SNIPER ) {
sniper = 1;
//MessagePlayer ( "You have a SniperRifle! (sniper=1)", player );
} else {
sniper = 0;
}
}

function onPlayerKeyStateChange ( pPlayer, key, down ) {

if ( ( key == KEY_ONFOOT_AIM ) && ( down ) ) {



if (sniper == 1) {

snipershoot = 1;
//MessagePlayer ( "You has shooted the SniperRifle (snipershoot=1)", pPlayer );

if (snipershoot == 1){
//MessagePlayer ( "Generate the SniperRifle Animation", pPlayer );
pPlayer.SetAnim (50);

}
}
}
}


COPY AND PASTE, THIS IS A CLIENT SCRIPT!
« Last Edit: June 25, 2020, 12:46:14 pm by theasl99 »

Eclipse2G

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-3
    • View Profile
Re: Aiming with Sniper Rifle (Script)
« Reply #1 on: June 25, 2020, 10:22:54 am »
first of all

SetAnim doesnt exist on client side
second of all

It wont work at  all because the anim will play ONCE the shot has been fired, it makes this script useless

theasl99

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-6
  • You fuck with me!, you fucking with the best!
    • View Profile
    • https://www.youtube.com/c/theasl99original
Re: Aiming with Sniper Rifle (Script)
« Reply #2 on: June 25, 2020, 12:01:02 pm »
first of all

SetAnim doesnt exist on client side
second of all

It wont work at  all because the anim will play ONCE the shot has been fired, it makes this script useless

This script works, I test this script it before uploading it, although it has some deficiencies, it only generates the animation if I changed my weapon before for a Sniper.

Also when I play sniper with other players the animation appears but not every time.
« Last Edit: June 25, 2020, 12:04:38 pm by theasl99 »

Eclipse2G

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-3
    • View Profile
Re: Aiming with Sniper Rifle (Script)
« Reply #3 on: June 25, 2020, 12:04:27 pm »
SetAnim doesn't exist in CLIENT SCRIPTS.

theasl99

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-6
  • You fuck with me!, you fucking with the best!
    • View Profile
    • https://www.youtube.com/c/theasl99original
Re: Aiming with Sniper Rifle (Script)
« Reply #4 on: June 25, 2020, 12:06:34 pm »
SetAnim doesn't exist in CLIENT SCRIPTS.

SetAnim is a "function" of player, it should serve the same way

Eclipse2G

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-3
    • View Profile
Re: Aiming with Sniper Rifle (Script)
« Reply #5 on: June 25, 2020, 12:08:43 pm »

theasl99

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-6
  • You fuck with me!, you fucking with the best!
    • View Profile
    • https://www.youtube.com/c/theasl99original
Re: Aiming with Sniper Rifle (Script)
« Reply #6 on: June 25, 2020, 12:14:01 pm »
http://liberty-unleashed.co.uk/LUWiki/Squirrel/Client/Functions

Show me where you see SetAnim there.


I test the script on a client and it worked without problems, well, with the ones I specified before, I will try to test it without a client to see how it is.

Eclipse2G

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-3
    • View Profile
Re: Aiming with Sniper Rifle (Script)
« Reply #7 on: June 25, 2020, 12:26:17 pm »
The script is Server Side, not Client Side.

theasl99

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-6
  • You fuck with me!, you fucking with the best!
    • View Profile
    • https://www.youtube.com/c/theasl99original
Re: Aiming with Sniper Rifle (Script)
« Reply #8 on: June 25, 2020, 12:32:17 pm »
The script is Server Side, not Client Side.

Okay, although it is rare that it works without problems on the client side.

theasl99

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-6
  • You fuck with me!, you fucking with the best!
    • View Profile
    • https://www.youtube.com/c/theasl99original
Re: Aiming with Sniper Rifle (Script)
« Reply #9 on: June 25, 2020, 12:45:57 pm »
The script is Server Side, not Client Side.

Okay, I just test it on the server side and it doesn't work, it stays on the client.

Eclipse2G

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-3
    • View Profile
Re: Aiming with Sniper Rifle (Script)
« Reply #10 on: June 25, 2020, 01:58:23 pm »
client="0" in xml means its Server Side, client="1" means its client side. I dont get it how does this work for you while its on client side. It shouldnt.

Eclipse2G

  • Newbie
  • *
  • Posts: 13
  • Karma: +0/-3
    • View Profile
Re: Aiming with Sniper Rifle (Script)
« Reply #11 on: June 25, 2020, 02:02:28 pm »
Code: [Select]
sniper_shot <- array(128,false);
function ClearShot(plr) { if ( plr ) { sniper_shot[plr.ID] = false; } }
function onPlayerKeyStateChange( player, key, down )
{
    if (  key == KEY_ONFOOT_AIM && down  )
    {
        if (player.Weapon==7  && !sniper_shot[player.ID])
        {
            sniper_shot[player.ID] = true;
            player.SetAnim(50);
            NewTimer(ClearShot,800,1,player); // prevent anim spam
        }
    }
}

Saved it as script.nut, <script file="script.nut" client="0" /> in Script.xml
« Last Edit: June 25, 2020, 02:18:39 pm by Eclipse2G »

theasl99

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-6
  • You fuck with me!, you fucking with the best!
    • View Profile
    • https://www.youtube.com/c/theasl99original
Re: Aiming with Sniper Rifle (Script)
« Reply #12 on: June 27, 2020, 01:13:09 am »
Code: [Select]
sniper_shot <- array(128,false);
function ClearShot(plr) { if ( plr ) { sniper_shot[plr.ID] = false; } }
function onPlayerKeyStateChange( player, key, down )
{
    if (  key == KEY_ONFOOT_AIM && down  )
    {
        if (player.Weapon==7  && !sniper_shot[player.ID])
        {
            sniper_shot[player.ID] = true;
            player.SetAnim(50);
            NewTimer(ClearShot,800,1,player); // prevent anim spam
        }
    }
}

Saved it as script.nut, <script file="script.nut" client="0" /> in Script.xml

PERFECT, I like when they improve what is done, and not only do they criticize, now I try that piece of script, there is a bug in the piece that I put.
when you grab the sniper pickup, and you shoot the animation doesn't work, but when you change weapons if it works.

theasl99

  • Newbie
  • *
  • Posts: 11
  • Karma: +0/-6
  • You fuck with me!, you fucking with the best!
    • View Profile
    • https://www.youtube.com/c/theasl99original
Re: Aiming with Sniper Rifle (Script)
« Reply #13 on: June 27, 2020, 01:25:44 am »
Code: [Select]
sniper_shot <- array(128,false);
function ClearShot(plr) { if ( plr ) { sniper_shot[plr.ID] = false; } }
function onPlayerKeyStateChange( player, key, down )
{
    if (  key == KEY_ONFOOT_AIM && down  )
    {
        if (player.Weapon==7  && !sniper_shot[player.ID])
        {
            sniper_shot[player.ID] = true;
            player.SetAnim(50);
            NewTimer(ClearShot,800,1,player); // prevent anim spam
        }
    }
}

Saved it as script.nut, <script file="script.nut" client="0" /> in Script.xml

Nice, the script works better than my piece of script on server side, congratulations, Close topic
« Last Edit: June 27, 2020, 01:27:27 am by theasl99 »

 

© Liberty Unleashed Team.