AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   NC-Laser code snippet (https://forums.alliedmods.net/showthread.php?t=190148)

striker07 07-15-2012 11:33

NC-Laser code snippet
 
1 Attachment(s)
Spoiler


I attached the working code (all ct's have lasersight, easy changable)

CS-A-Roland 07-15-2012 12:45

Re: NC-Laser code snippet
 
Never use buggy code!!! Use existing working code... :nono:
In this Nightcrawler script it is an item, this could be the reason why it dont work for you.. :wink:

try this here, it is exactly what you need ->>> Laser Sight

striker07 07-15-2012 13:34

Re: NC-Laser code snippet
 
I have that one, it fails to have my purposes.
The Nightcrawler laser fits my needs perfect with minor modifictations, I just removed the boolean that makes it an item to not make it an item

and I fail to see the buggy code, thats why i asked help ;)

CS-A-Roland 07-15-2012 13:42

Re: NC-Laser code snippet
 
the buggy code is there, that this laser just the "best" the "first" and the "last" player became... But it dont work as it should!
If the players connect and the item menu pops up, they got it all...
if they turn later to another item then its disabled for "this time", but if you take a weapon of a teammate wich have it you got both items...

dont understand me wrong, if you wan to use it, do it but you should know it dont works like it should so there can come complications later if the server iss full maybe!
I also looking for this problem, because it should work in the right way... without any bugs

By the way... i think you have not all what you need...
Code:

        enum _:ItemsInfo
        {
            ITEM_LASER, // Done
            ITEM_SUICIDE, // Done
            ITEM_POISON, // Done
            ITEM_ADRENALINE, // Done
            ITEM_MEDKIT // Done
        };

//and later.....

g_hItemsMenu = menu_create( "Choose an Item:", "ItemsMenu_Handler" );
       
        for( new i = 0; i < ItemsInfo; i++ )
        {
            num_to_str( i, szInfo, charsmax( szInfo ) );
           
            if( i == ITEM_LASER )
            {
                menu_additem( g_hItemsMenu, g_szItemNames[ i ], szInfo, _, menu_makecallback( "LaserItem_Callback" ) );
            }
           
            else menu_additem( g_hItemsMenu, g_szItemNames[ i ], szInfo );
        }
    }   
   
    public LaserItem_Callback( id, hMenu, iItem )
    {
        if( g_iCurrentRound == 0 )
            return ITEM_DISABLED;
           
        new iFrags = get_user_frags( id );
        new iDeaths = get_user_deaths( id );

        new iPlayerFrags;
       
        new iPlayers[ 32 ], iNum;
        get_players( iPlayers, iNum, "ae", "CT" );
       
        if( iNum == 1 )
            return ITEM_DISABLED;
           
        for( new i = 0, iPlayer; i < iNum; i++ )
        {
            iPlayer = iPlayers[ i ];
           
            if( !is_user_alive( iPlayer ) || iPlayer == id )
                continue;
               
            iPlayerFrags = get_user_frags( iPlayer );
           
            if( iPlayerFrags > iFrags )
                return ITEM_DISABLED;
               
            else if( iPlayerFrags == iFrags )
            {
                if( get_user_deaths( iPlayer ) < iDeaths )
                    return ITEM_DISABLED;
            }
        }
       
        return ITEM_ENABLED;
       
    }

Look at the "Laser" functions and lock them out of the item menu if you dont want use items... but dont ask me how, i'm new at this...

striker07 07-15-2012 16:13

Re: NC-Laser code snippet
 
that's what i did, in client prethink, what you see is the function what is giving you the lasers so in my case everybody of ct team should have the laser so i removed the boolean that became true once you choosed the item in nc. this way i removed it as an item and made it always active for the ct team

for the bug, thats a bug in the coding of the nc mod but not in the part that i took.
also this snippet comes out of the nc_new sma so i'm not sure if that version has that bug too

nikhilgupta345 07-15-2012 18:57

Re: NC-Laser code snippet
 
Put this line:
PHP Code:

g_iLaserSprite precache_modelg_szLaserSprite ); 

into a function called public plugin_precache()

so it'd be

PHP Code:


public plugin_precache()
{
     
g_iLaserSprite precache_modelg_szLaserSprite );


See if that works.

striker07 07-16-2012 07:49

Re: NC-Laser code snippet
 
omg unbelievable that that was the problem :s i use plugin init allot to precache and this is the first time this happend any way thx nikhil, it works now but i got one more question

is it possible to fix this problem? (lasers don't start out of the weapon but from you're body)=>
http://img12.**************/img12/897/2012071600001.jpg

this happens mostly with pistol I havent spotted this bug with primary weapons, any idea's what might cause this? i had the same problem with the lasersight plugin but thne for all weapons

CS-A-Roland 07-16-2012 09:05

Re: NC-Laser code snippet
 
Mhm, i have the problem too but not so often in the nc script...
If i take a look at both versions (yours and the lasersight orginal) there are 2 differences

First the orginal:
Code:

if(get_pcvar_num(ls_line) != 0)
    {
      write_byte (TE_BEAMENTPOINT)
      write_short(id | 0x1000)
      write_coord (e[0])
      write_coord (e[1])
      write_coord (e[2])
    }
    else
    {
      write_byte (0)
      write_coord (e[0] + 1)
      write_coord (e[1] + 1)
      write_coord (e[2] + 1)
      write_coord (e[0] - 1)
      write_coord (e[1] - 1)
      write_coord (e[2] - 1)

    }
   
    write_short(sprite)
    write_byte (0)                             
    write_byte (10)                           
    write_byte (1)
    write_byte (5)                         
    write_byte (0)

here yours
Code:

write_byte( TE_BEAMENTPOINT );
  write_short( id | 0x1000 );
  write_coord( iOrigin[ 0 ] );
  write_coord( iOrigin[ 1 ] );
  write_coord( iOrigin[ 2 ] );
  write_short( g_iLaserSprite );
  write_byte( 1 );
  write_byte( 10 );
  write_byte( 1 );
  write_byte( 5 );
  write_byte( 0 );

The difference maybe can the bug on the original plugin and also there you can find the reason i think how to fix. I hope it help to find it out! :)
for explanation, i think the bug is in the original harder because there will use an else every time there is something not "clear" or "wrong" ...

striker07 07-16-2012 10:08

Re: NC-Laser code snippet
 
have you seen the dot function in lasersight.amxx? it sucks bigtime its like lines but 500 m further, big fail if you ask me. so i wouldt even think about checking diffrences between the lasersight and nc laser.

and the lasersight plugin is even worse then the nc laser so i wouldnt recommend camparing those 2 with each other we should compare the nc with a perfectly working copy that does not have this bug

Quote:

Originally Posted by CS-A-Roland (Post 1751520)
for explanation, i think the bug is in the original harder because there will use an else every time there is something not "clear" or "wrong" ...

nono, the else function will happen everytime this check: if(get_pcvar_num(ls_line) != 0)
is false so when the cvar is 0 then the else function will come into play

nikhilgupta345 07-16-2012 19:29

Re: NC-Laser code snippet
 
Quote:

Originally Posted by striker07 (Post 1751491)
omg unbelievable that that was the problem :s i use plugin init allot to precache and this is the first time this happend any way thx nikhil, it works now but i got one more question

is it possible to fix this problem? (lasers don't start out of the weapon but from you're body)=>
http://img12.**************/img12/897/2012071600001.jpg

this happens mostly with pistol I havent spotted this bug with primary weapons, any idea's what might cause this? i had the same problem with the lasersight plugin but thne for all weapons

I'm almost positive there's no way to fix that, sorry.


All times are GMT -4. The time now is 15:16.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.