AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   invalid player (https://forums.alliedmods.net/showthread.php?t=187711)

KamiN 06-16-2012 20:59

invalid player
 
Code:

public beacon(id)
{
   
    if(cs_get_user_team(id) == CS_TEAM_CT)
    {
        if(is_user_alive(id))
        {
            static origin[3]
            get_user_origin(id, origin)
            message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
            write_byte(TE_BEAMCYLINDER)    // TE id
            write_coord(origin[0])        // x
            write_coord(origin[1])        // y
            write_coord(origin[2]-20)    // z
            write_coord(origin[0])        // x axis
            write_coord(origin[1])        // y axis
            write_coord(origin[2]+200)    // z axis
            write_short(beacon_sprite)    // sprite
            write_byte(0)            // startframe 
            write_byte(1)            // framerate 
            write_byte(6)            // life
            write_byte(2)              // width
            write_byte(1)              // noise   
            write_byte(0)              // red 
            write_byte(0)              // green
            write_byte(250)        // blue
            write_byte(200)            // brightness
            write_byte(0)            // speed
            message_end()
        }
    }
    else
    {
        if(is_user_alive(id))
        {
            static origin[3]
            get_user_origin(id, origin)
            message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
            write_byte(TE_BEAMCYLINDER)    // TE id
            write_coord(origin[0])        // x
            write_coord(origin[1])        // y
            write_coord(origin[2]-20)    // z
            write_coord(origin[0])        // x axis
            write_coord(origin[1])        // y axis
            write_coord(origin[2]+200)    // z axis
            write_short(beacon_sprite)    // sprite
            write_byte(0)            // startframe 
            write_byte(1)            // framerate 
            write_byte(6)            // life
            write_byte(2)              // width
            write_byte(1)              // noise   
            write_byte(250)            // red 
            write_byte(0)              // green
            write_byte(0)            // blue
            write_byte(200)            // brightness
            write_byte(0)            // speed
            message_end()
        }
    }

    set_task(1.0, "beacon", id)
       
}

Code:

L 06/17/2012 - 03:31:44: [CSTRIKE] Invalid player 1
L 06/17/2012 - 03:31:44: [AMXX] Displaying debug trace (plugin "jb_days_lr.amxx")
L 06/17/2012 - 03:31:44: [AMXX] Run time error 10: native error (native "cs_get_user_team")
L 06/17/2012 - 03:31:44: [AMXX]    [0] jb_days_lr.sma::beacon (line 706)

I saw this warning in logs, so i added to code that is_user_alive(id) thing, but even after that i have same problem. So how do i fix this?


this code is a part of this plugin http://forums.alliedmods.net/showthread.php?t=117992

hornet 06-16-2012 21:35

Re: invalid player
 
The attachment doesn't exactly help. Show where your actually calling the function beacon from.

Also you should optimize this to remove some checks and make it more efficient:
Code:
public beacon(id) {     if(is_user_alive(id))     {         static origin[3]         get_user_origin(id, origin)         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)         write_byte(TE_BEAMCYLINDER)    // TE id         write_coord(origin[0])         // x         write_coord(origin[1])        // y         write_coord(origin[2]-20)    // z         write_coord(origin[0])        // x axis         write_coord(origin[1])        // y axis         write_coord(origin[2]+200)    // z axis         write_short(beacon_sprite)    // sprite         write_byte(0)            // startframe           write_byte(1)            // framerate           write_byte(6)            // life         write_byte(2)              // width         write_byte(1)               // noise                 switch( cs_get_user_team( id ) )         {             case CS_TEAM_T:             {                 write_byte(250)            // red                   write_byte(0)               // green                 write_byte(0)             // blue             }                         case CS_TEAM_CT:             {                 write_byte(0)              // red                   write_byte(0)               // green                 write_byte(250)         // blue             }         }                 write_byte(200)            // brightness         write_byte(0)            // speed         message_end()     }     set_task(1.0, "beacon", id)     }

KamiN 06-17-2012 06:15

Re: invalid player
 
I dont know how to get correct line, but beacon is called in
Code:

public sub_choose_enemy
Code:

    switch (get_pcvar_num(cvar_effect))
    {
        case 0: // glow
        {
            set_user_rendering(id, kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 20)   
            set_user_rendering(tempid, kRenderFxGlowShell, 0, 0, 250, kRenderNormal, 20)
        }
        case 1: // beacon
        {
            set_task(1.0, "beacon", id)
            set_task(1.0, "beacon", tempid)
        }
        case 2: // glow n' beacon
        {
            set_user_rendering(id, kRenderFxGlowShell, 250, 0, 0, kRenderNormal, 20)   
            set_task(1.0, "beacon", id)
            set_user_rendering(tempid, kRenderFxGlowShell, 0, 0, 250, kRenderNormal, 20)
            set_task(1.0, "beacon", tempid)
        }
    }

Please use CSTRL + F and type beacon or sub_choose_enemy

Backstabnoob 06-17-2012 06:22

Re: invalid player
 
Do what hornet said.

KamiN 06-17-2012 06:44

Re: invalid player
 
is there someway how to copy code without lately correction? :O Becouse now when i copy and paste this code it writes in 2 lines? :O
http://youtu.be/-76l4v1txqw

Backstabnoob 06-17-2012 06:56

Re: invalid player
 
Use some real text editor ;)

Waleed 06-17-2012 06:58

Re: invalid player
 
Notepad suck!
Use your AMX Studio to open .sma or pasting code.....

Waleed 06-17-2012 07:00

Re: invalid player
 
It is pasting in notepad as it is,Might be some problem in your text editor or you can:

Select full code,
Right Click and select copy,
Then Past it!

hornet 06-17-2012 07:36

Re: invalid player
 
Quote:

Originally Posted by KamiN (Post 1730360)
is there someway how to copy code without lately correction? :O Becouse now when i copy and paste this code it writes in 2 lines? :O
http://youtu.be/-76l4v1txqw

Realistically you should be using AMXX Studio so you can test compile for warnings and errors - you'll also receive autocomplete help for constants aswell as functions and their arguments.

fysiks 06-17-2012 12:37

Re: invalid player
 
Quote:

Originally Posted by Waleed (Post 1730367)
It is pasting in notepad as it is,Might be some problem in your text editor or you can:

Select full code,
Right Click and select copy,
Then Past it!

No, the problem is that notepad is not smart enough to interpret various return characters. Use Notepad++.


All times are GMT -4. The time now is 06:11.

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