Half-Life и Adrenaline Gamer форум
http://aghl.ru/forum/

help ! in this code: rpg laser dot
http://aghl.ru/forum/viewtopic.php?f=20&t=2205
Страница 2 из 4

Автор:  Lev [ 14 мар 2016, 00:24 ]
Заголовок сообщения:  Re: help ! in this cod

abdobiskra писал(а):
Код:
public FORWARD_SET_MODEL(entid, model[]) {
   
    if(!pev_valid(entid) || !equal(model, "sprites/laserdot.spr"))
    return FMRES_IGNORED
       
    new owner = pev(entid, pev_owner);
    if(!is_user_alive(owner) || !is_user_connected(owner))
    return FMRES_IGNORED
   
    switch(get_user_team(owner))
    {
    case 1:engfunc(EngFunc_SetModel,entid, "sprites/Dots/laserspot_blue.spr")   
    case 2:engfunc(EngFunc_SetModel,entid, "sprites/Dots/laserspot_red.spr")
    }
   
    return FMRES_SUPERCEDE
}
This one was better in its logic. Capture model set, check if laserdot.spr, get owner, get owner's team, set needed model.

Автор:  abdobiskra [ 14 мар 2016, 01:21 ]
Заголовок сообщения:  Re: help ! in this cod

but this not work for me ! i tryed that

Автор:  Lev [ 14 мар 2016, 02:20 ]
Заголовок сообщения:  Re: help ! in this cod

Test it step by step with server_print debug output.

Автор:  abdobiskra [ 14 мар 2016, 02:30 ]
Заголовок сообщения:  Re: help ! in this cod

I do not have an idea about that ?

Автор:  Lev [ 14 мар 2016, 07:19 ]
Заголовок сообщения:  Re: help ! in this cod

Lev писал(а):
Capture model set, check if laserdot.spr, get owner, get owner's team, set needed model
These are "steps".
Verify each that they are working as expected. Do server_print variables, etc...

Автор:  abdobiskra [ 14 мар 2016, 18:03 ]
Заголовок сообщения:  Re: help ! in this cod

I'm not sure how to did it?

for model ?

Код:
    if(!pev_valid(entid) || !equal(model, "sprites/laserdot.spr"))
    server_print("-----------------");
    server_print("%s", model)
    server_print("-----------------")
    return FMRES_IGNORED

Цитата:
-----------------
models/player.mdl
-----------------
-----------------
models/w_crowbar.mdl
-----------------
-----------------
models/w_9mmhandgun.mdl
-----------------
-----------------
models/w_hgun.mdl
-----------------
-----------------
models/w_rpg.mdl
-----------------
sprites/laserdot.spr
-----------------
-----------------
models/w_rpg.mdl
-----------------

for owner ?

Код:
    new owner = pev(entid, pev_owner);
    if(!is_user_alive(owner) || !is_user_connected(owner))
    server_print("-----------------");
    server_print("%s", owner)
    server_print("-----------------");
    return FMRES_IGNORED

==== | No result

for get owner's team ?

Код:
    switch(team)
    {
    case 1:engfunc(EngFunc_SetModel,entid, "sprites/Dots/laserspot_blue.spr")   
    case 2:engfunc(EngFunc_SetModel,entid, "sprites/Dots/laserspot_red.spr")
    }
   
    server_print("-----------------");
    server_print("%s", hl_get_user_team(owner))
    server_print("-----------------");
   
    return FMRES_SUPERCEDE


====| No result !

Автор:  GordonFreeman [ 14 мар 2016, 19:54 ]
Заголовок сообщения:  Re: help ! in this cod

Чет не нашел в SDK, что для laserdot выставляется owner.

Автор:  abdobiskra [ 14 мар 2016, 20:25 ]
Заголовок сообщения:  Re: help ! in this cod

GordonFreeman писал(а):
Чет не нашел в SDK, что для laserdot выставляется owner.

Цитата:
-----------------
models/w_rpg.mdl
-----------------
sprites/laserdot.spr <=== !
-----------------
-----------------
models/w_rpg.mdl

I've been introduced but randomly

Автор:  GordonFreeman [ 14 мар 2016, 21:58 ]
Заголовок сообщения:  Re: help ! in this cod

Try hook item postframe for weapon_rpg, then get laserdot entity by pdata.
Код:
// CRpg (weapon_rpg) - linux dif 4
CLaserSpot*         m_pSpot               45   // laserdot entity
int               m_fSpotActive         46   // is laserdot active
So you should have 3 ids - weapon_rpg, player and lasterdot entity.

Автор:  Lev [ 14 мар 2016, 22:35 ]
Заголовок сообщения:  Re: help ! in this cod

You did it almost right.
You should wrap instructions under if into surly brackets:
Код:
    if(!pev_valid(entid) || !equal(model, "sprites/laserdot.spr"))
    {
       server_print("-----------------");
       server_print("%s", model)
       server_print("-----------------")
       return FMRES_IGNORED
    }
But actually you should do so:
Код:
    if(!pev_valid(entid) || !equal(model, "sprites/laserdot.spr"))
    {
    return FMRES_IGNORED
    }
    server_print("-----------------");
    server_print("%s", model)
    server_print("-----------------")
So printing of the model will occur after you did check for a model name.

So, you intercepted needed model setup, but wasn't able to get owner. In case of owner you should print it before checks:
Код:
    new owner = pev(entid, pev_owner);
    server_print("-----------------");
    server_print("%s", owner)
    server_print("-----------------");
    if(!is_user_alive(owner) || !is_user_connected(owner))
    return FMRES_IGNORED
Thus you can check actual index. And, as GordonFreeman said, you will not be able to take RPG spot owner this way because game do not set it.
So, you need to get player id differently and you can't do it in FORWARD_SET_MODEL for two reasons: owner is not directly available (though you can iterate each play, get their active weapon, check if RPG and get m_pSpot to compare with current entity) and the second reason is that RPG could be dropped and picked up by another team play, so you will need to update spot with different model. Possibly it will be better to hook ItemPostFrame as GordonFreeman suggests and update spot model if needed.

Страница 2 из 4 Часовой пояс: UTC + 5 часов [ Летнее время ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/