AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to rewrite "spectator mode" to not be able to change players? (https://forums.alliedmods.net/showthread.php?t=243988)

Drago36 07-12-2014 11:07

How to rewrite "spectator mode" to not be able to change players?
 
Hey.

I have this code:
Code:

public WejdzWCialo(id)
{
    fm_set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 100) // A - changing visibility Player
   
    new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")) // B - create a ent
    set_pev(iEnt, pev_classname, "player_hat") // B
    engfunc(EngFunc_SetModel, iEnt, "models/cod_jasnowidz.mdl") // B
   
    set_pev(iEnt, pev_movetype, MOVETYPE_FOLLOW) // C - created the ent follows the victim of wybrany[id]
    set_pev(iEnt, pev_aiment, wybrany[id]) // C
    set_pev(iEnt, pev_owner, wybrany[id]) // C
   
    new info[2] // D - data transfer set_task
    info[0] = id // D
    info[1] = wybrany[id] // D
   
    engfunc(EngFunc_SetView, id, iEnt) // C - code on the so-called "spectator mode"
    set_pev(id,pev_sequence,107)
    set_pev(id,pev_gaitsequence,6)
    set_pev(id,pev_iuser1,2)
    set_pev(id,pev_iuser2,wybrany[id])
    set_pev(id,pev_frame,255.0)
    set_pev(id,pev_framerate,1.0) // end C
   
    set_task(SLEDZ.0, "KoniecPodgladu",.parameter=info, .len=2) // D
}

public KoniecPodgladu(info[2])
{
    new id = info[0] // D
    new sledzony = info[1] // D
   
    engfunc(EngFunc_SetView, id, id) // E - ent transition from model
    set_pev(id,pev_sequence,75) // C - remove the "spectator mode"
    set_pev(id,pev_gaitsequence,1)
    set_pev(id,pev_iuser1,0)
    set_pev(id,pev_iuser2,0)
    set_pev(id,pev_frame,float(random(35)+110))
    set_pev(id,pev_framerate,1.0) // end C
   
    new iEnt = fm_find_ent_by_owner(-1, "player_hat", sledzony) // F - detection ent
    engfunc(EngFunc_RemoveEntity, iEnt) // F - delete ent
   
    fm_set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255) // getting rid of invisibility
}

This causes the player enters the ent created on another player.
All around him he sees as a spectator (See below).

After clicking the "DUCK" opens a window on the bottom and the player can afford to change the view of the other player. I would like to block, or otherwise adjust the camera.

Maybe somehow through "pev_body"? I would ask for the sample code.
Thank you for your answers.

Drago36 07-13-2014 13:37

Re: How to rewrite "spectator mode" to not be able to change players?
 
Maybe you know how to replace the code that the view was over the player, but without the "spectator mode"? P.S Sorry for understatement, I am using google translate
Code:

    set_pev(id,pev_sequence,107)
    set_pev(id,pev_gaitsequence,6)
    set_pev(id,pev_iuser1,2)
    set_pev(id,pev_iuser2,wybrany[id])
    set_pev(id,pev_frame,255.0)
    set_pev(id,pev_framerate,1.0


Drago36 07-21-2014 10:53

Re: How to rewrite "spectator mode" to not be able to change players?
 
@ref

Drago36 08-16-2014 08:51

Re: How to rewrite "spectator mode" to not be able to change players?
 
@ref

RateX 08-16-2014 15:09

Re: How to rewrite "spectator mode" to not be able to change players?
 
AFAIK, either pev_iuser1 or pev_iuser2 control the "spector mode". Try to play with other values like pev_iuser3, pev_iuser4, pev_euser, pev_fuser:)

Drago36 09-23-2014 11:57

Re: How to rewrite "spectator mode" to not be able to change players?
 
@ref

Drago36 10-09-2014 16:08

Re: How to rewrite "spectator mode" to not be able to change players?
 
I worked it out in such a way:
Code:

public WejdzWCialo(id)
{
        get_user_name(wybrany[id], name, 32)
        ColorChat(id, GREEN, "Obserwujesz: ^x01%s!", name)
        fm_set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 25)
       
        new iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
        set_pev(iEnt, pev_classname, "player_hat")
        engfunc(EngFunc_SetModel, iEnt, "models/w_c4.mdl")
        set_pev(iEnt, pev_solid, SOLID_TRIGGER)
        set_pev(iEnt, pev_movetype, MOVETYPE_FLYMISSILE)
        set_pev(iEnt, pev_owner, wybrany[id])
        set_pev(iEnt, pev_rendermode, kRenderTransTexture)
        set_pev(iEnt, pev_renderamt, 0.0)
        engfunc(EngFunc_SetView, id, iEnt)
        set_pev(iEnt, pev_nextthink, get_gametime())
       
        message_begin(MSG_ONE, msg_bartime, _, id)
        write_short(SLEDZ)
        message_end()
       
        new info[3]
        info[0] = id
        info[1] = wybrany[id]
        info[2] = iEnt
       
        if(get_cvar_num("cod_jasnowidz_odglos") == 1)
                //emit_sound(wybrany[id], CHAN_VOICE, "cod_jasnowidz/wchodzi.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) // odglos wokol ofiary (sledzonego)
        set_task(SLEDZ.0, "KoniecPodgladu",.parameter=info, .len=3)
}

public KoniecPodgladu(info[3])
{
        new id = info[0]
        new sledzony = info[1]
        new iEnt = info[2]
       
        engfunc(EngFunc_SetView, id, id)
        engfunc(EngFunc_RemoveEntity, iEnt)
        fm_set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255)
       
        if(get_cvar_num("cod_jasnowidz_radar") != 1) return
        if(!is_user_alive(sledzony)) return
        if(!is_user_alive(id))
        {
                ColorChat(id, RED, "Niestety nie dozyles. Nie udostepnisz namiarow na wroga swojej ^x03 druzynie.")
                return
        }
        oznaczony[sledzony] = true
       
        #if RADAR == 0
       
        ColorChat(id, RED, "Ofiara jest oznaczona na radarze!")
       
        #else
       
        ColorChat(id, RED, "Ofiara jest oznaczona przez %d sekund na radarze!", RADAR)
        set_task(RADAR.0-6.0, "SledzOfiare", sledzony+541230)
       
        #endif
}

public FM_KameraGracza(iEnt)
{
        static szClassname[32]
        pev(iEnt, pev_classname, szClassname, sizeof szClassname - 1)
       
        if(!equal(szClassname, "player_hat"))
                return FMRES_IGNORED
       
        static iOwner
        iOwner = pev(iEnt, pev_owner)
       
        if(!is_user_alive(iOwner))
                return FMRES_IGNORED
       
        static Float:fOrigin[3], Float:fAngle[3]
        pev(iOwner, pev_origin, fOrigin)
        pev(iOwner, pev_v_angle, fAngle)
        static Float:fVBack[3]
        angle_vector(fAngle, ANGLEVECTOR_FORWARD, fVBack)
        //odleglosc kamery od postaci
        fOrigin[2] += 20.0
        fOrigin[0] += (-fVBack[0] * 150.0)
        fOrigin[1] += (-fVBack[1] * 150.0)
        fOrigin[2] += (-fVBack[2] * 150.0)
       
        engfunc(EngFunc_SetOrigin, iEnt, fOrigin)
        set_pev(iEnt, pev_angles, fAngle)
        set_pev(iEnt, pev_nextthink, get_gametime())
       
        return FMRES_HANDLED;
}



All times are GMT -4. The time now is 21:10.

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