AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Anyone have the answer to this (https://forums.alliedmods.net/showthread.php?t=5429)

Mugwump 08-31-2004 22:31

Anyone have the answer to this
 
I am trying to attach a model to a player, I have the model in both the valve/models directory and cstrike/models called roots2.mdl

Here is the source:

Code:
#include <amxmodx> #include <amxmisc> #define TE_PLAYERATTACHMENT 124 new roots public plugin_init() {    register_plugin("Roots Test", "1.0", "K2mia")    set_task(1.0, "test_sprite", 457) } public plugin_precache(){    roots = precache_model("models/roots2.mdl") } public test_sprite() {    new players[32], numofplayers, id, i    new origin[3]    get_players(players, numofplayers)    for (i = 0; i < numofplayers; i++){       id = players[i]       get_user_origin(id, origin)       client_print(id, print_chat, "Adding model ")       message_begin(MSG_BROADCAST, SVC_TEMPENTITY)       write_short(TE_PLAYERATTACHMENT)       write_entity(id)       write_coord( origin[2] + 50 )       write_short(roots)       write_short(100)       message_end()    }    set_task(10.0, "test_sprite", 457)    return PLUGIN_HANDLED }

When the test_sprite() routine is called I see this in console:

No model 1200!
No model 1424!

I know these models exist, I saw the download message when I first connected and the .dml file was precached...

Anyone have the answer?

Thanks
-Mug

PM 09-01-2004 07:07

Hi,

I have used the TE_PLAYERATTACHMENT tempentity in my superkeeper plugin.

The only differency i found is this:
Code:
        message_begin(MSG_BROADCAST, SVC_TEMPENTITY);         write_byte(TE_PLAYERATTACHMENT);         write_byte(g_SK[id]);         write_coord(FLYEFFECTMODEL_ZSHIFT);         write_short(g_FlyEffectModel);         write_short(600);         message_end();
(g_SK[id] is the player id)

As you can see, the player id is a byte and not short; making it a short would mess up offsets when reading and you would get bad values (that's probably why it can't find the model: the id is messed up)
Also note that the write_coord only specifies a relatie value I believe the origin of the model is the origin of the player with z value += the offset.
So you would set it to 50 rather than playerZ + 50.

Hope this help :)

Mugwump 09-01-2004 10:09

PM, thank you very much, that post cleared up everything for me... :)

-Mug

Mugwump 09-01-2004 10:13

Actually, I do have one more question (dont we always). ;)

Is there a way to display the playerattachment to a set of players, for example just the CT team, as opposed to the one player its attached to or everyone? I am unfamilar with the variations on MSG_BROADCAST, MSG_ALL and if they can be masked or set for just a single player of group of players.

Thanks!
-Mug

mahnsawce 09-01-2004 10:19

Loop through all the players, and send it as MSG_ONE

example of a message_begin using MSG_ONE:

message_begin(MSG_ONE,SVC_TEMPENTITY,{0,0,0}, idPlayer)

PM 09-01-2004 10:51

I'd say loop through the players and send it using MSG_ALL.
Sending with MSG_ONE will make sure only one player sees the attachement.

I posted info about MSG_** on the old amx forums some time ago (pretty long time ago) (cant find it anymore, argh)
Code:

#define        MSG_BROADCAST                0                // unreliable to all
#define        MSG_ONE                                1                // reliable to one (msg_entity)
#define        MSG_ALL                                2                // reliable to all
#define        MSG_INIT                        3                // write to the init string
#define MSG_PVS                                4                // Ents in PVS of org
#define MSG_PAS                                5                // Ents in PAS of org
#define MSG_PVS_R                        6                // Reliable to PVS
#define MSG_PAS_R                        7                // Reliable to PAS
#define MSG_ONE_UNRELIABLE        8                // Send to one client, but don't put in reliable stream, put in unreliable datagram ( could be dropped )
#define        MSG_SPEC                        9                // Sends to all spectator proxies

(HLSDK: common/const.h)

Most important ones:
MSG_BROADCAST - send to all players, unreliable stream
MSG_ALL - send to all players, reliable stream
MSG_ONE_UNRELIABLE - send to one player, unreliable stream
MSG_ONE - send to one player, reliable stream

the PAS and PVS stuff are about what the player hears / sees I think (something like that it was :D )
Now the TE_PLAYERATTACHMENT tempentity takes the player id, so sending it to all players will display an attachment on the id on all player's screens, but sending it to id only will display it only on his screen.

Hope this helps :D

Mugwump 09-01-2004 11:13

PM, my question is if I only wanted the CT team to see the message wouldnt I have to loop and only send it to one id at a time? If not I'm confused why MSG_ALL would accomplish that.

I'm also wondering if PLAYERATTACHMENT is the right message to be using. Basically I want to display a model surrounding the player's model based on their location at the specific time (the player will then be held in place for a set duration)... If I use PLAYERATTACH when the player ducks or jumps the attached model moves with them, is there a better way to create the model so it doesn't move with the player? I tried message # 17 (TE_SPRITE) but it displayed the model as a ghostform, was mostly transparent and whiteish, while the other message displays the correct model...

-Mug

PM 09-01-2004 11:24

When you send a message using MSG_ONE, only one client will receive it. So when you send a TE_PLAYERATTACHMENT using MSG_ONE, only one client will see the attachment.
You can specify which players will see the attachment.
OMG now i read your messages again and found that that you WANT that only some players will see it; sorry! :D

Mugwump 09-01-2004 12:54

Thanks PM, I was getting worried.

Is there a better way to position a model at a specific location so it doesn't move with the player, is creating an entity with that model the only way to do that?

-Mug


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

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