AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   User aiming? (https://forums.alliedmods.net/showthread.php?t=76944)

[X]-RayCat 09-02-2008 13:10

User aiming?
 
Im trying to make plugin which creates ".mdl" (in example) in the location where you're aiming at. :)

Any explanation how to do this or maybe code?

anakin_cstrike 09-02-2008 13:15

Re: User aiming?
 
Use this stock:
PHP Code:

stock fm_get_aimorigin(indexFloat:origin[3])
{
    new 
Float:start[3], Float:view_ofs[3];
    
pev(indexpev_originstart);
    
pev(indexpev_view_ofsview_ofs);
    
xs_vec_add(startview_ofsstart);
    
    new 
Float:dest[3];
    
pev(indexpev_v_angledest);
    
engfunc(EngFunc_MakeVectorsdest);
    
global_get(glb_v_forwarddest);
    
xs_vec_mul_scalar(dest9999.0dest);
    
xs_vec_add(startdestdest);
    
    
engfunc(EngFunc_TraceLinestartdest0index0);
    
get_tr2(0TR_vecEndPosorigin);
    
    return 
1;


And do like this:
PHP Code:

if((engfunc(EngFunc_PointContentsfAimOrigin) != CONTENTS_SKY) && (engfunc(EngFunc_PointContentsfAimOrigin) != CONTENTS_SOLID))
    {
        static 
iEnt;
        
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
        
        if(!
iEnt)
            return 
0;
        
        
engfunc(EngFunc_SetOriginiEntfAimOrigin);
        
        static 
Float:fMaxs[3] = { 16.016.038.0 };
        static 
Float:fMins[3] = { -16.0, -16.0, -38.0 };
        
        
engfunc(EngFunc_SetModeliEnt"models/model.mdl");
        
set_pev(iEnt,pev_classname"classname");
        
        
dllfunc(DLLFunc_SpawniEnt);
        
set_pev(iEntpev_solidSOLID_BBOX);
        
engfunc(EngFunc_SetSizeiEntfMinsfMaxs);
        
    } 


atomen 09-02-2008 13:35

Re: User aiming?
 
Isn't this a lot better to use??
PHP Code:

get_user_origin(idorigin3); 

Quote:

Originally Posted By Funcwiki

If mode is passed, the origin changes:
0 - current position (Default)
1 - Position from eyes (weapon aiming)
2 - End position from player position
3 - End position from eyes (hit point for weapon)
4 - Position from last bullet hit (only CS)

[X]-RayCat 09-02-2008 13:50

Re: User aiming?
 
What if i want to add sprite to that location?

edit:
Lets say i wanna make implosion:
Code:
 message_begin(MSG_PVS, SVC_TEMPENTITY, origin);  write_byte(TE_IMPLOSION);  write_coord(origin[0]);  write_coord(origin[1]);  write_coord(origin[2]);  write_byte(64);  // radius  write_byte(100); // count  write_byte(6);  // life  message_end();

atomen 09-02-2008 13:57

Re: User aiming?
 
pev_model works with sprites too.

For your message:
PHP Code:

new origin[3];
get_user_origin(idorigin3);

message_begin(MSG_PVSSVC_TEMPENTITYorigin);
write_byte(TE_IMPLOSION);
write_coord(origin[0]);
write_coord(origin[1]);
write_coord(origin[2]);
write_byte(64);  // radius
write_byte(100); // count
write_byte(6);  // life
message_end(); 


[X]-RayCat 09-02-2008 14:19

Re: User aiming?
 
Quote:

Originally Posted by atomen (Post 680125)
pev_model works with sprites too.
PHP Code:

new origin[3];
get_user_origin(idorigin3);
 
message_begin(MSG_PVSSVC_TEMPENTITYorigin);
write_byte(TE_IMPLOSION);
write_coord(origin[0]);
write_coord(origin[1]);
write_coord(origin[2]);
write_byte(64);  // radius
write_byte(100); // count
write_byte(6);  // life
message_end(); 


I already know how to use that. >.<

I tried to set it before with fm aim origin, but it was never created. :o

atomen 09-02-2008 14:28

Re: User aiming?
 
Test this:
PHP Code:

new origin[3];
get_user_origin(idorigin3);

message_begin(MSG_PVSSVC_TEMPENTITYorigin);
write_byte(TE_IMPLOSION);
write_coord(origin[0] + random_num ( -7575 ));
write_coord(origin[1] + random_num ( -7575 ));
write_coord(origin[2] + random_num ( -2525 ));
write_byte(64);  // radius
write_byte(100); // count
write_byte(6);  // life
message_end(); 


[X]-RayCat 09-02-2008 17:04

Re: User aiming?
 
Haven't got it to work... >.<

danielkza 09-02-2008 18:13

Re: User aiming?
 
Try changing MSG_PVS to MSG_BROADCAST

Emp` 09-03-2008 03:31

Re: User aiming?
 
Quote:

Originally Posted by [X]-RayCat (Post 680138)
I tried to set it before with fm aim origin, but it was never created. :o

because "fm aim origin" returns a Float vector. if you were to use it, you would need to do:
Code:

message_begin(MSG_PVS, SVC_TEMPENTITY, origin);
write_byte(TE_IMPLOSION);
write_coord( floatround(origin[0]) );
write_coord( floatround(origin[1]) );
write_coord( floatround(origin[2]) );
write_byte(64);  // radius
write_byte(100); // count
write_byte(6);  // life
message_end();



All times are GMT -4. The time now is 03:04.

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