Raised This Month: $ Target: $400
 0% 

get_user_origin and set_user_origin problem...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Silencer123
Veteran Member
Join Date: Jul 2006
Old 09-28-2006 , 18:00   get_user_origin and set_user_origin problem...
Reply With Quote #1

I am trying to build some kind of Teleport Plugin. (Just to learn)
get_user_origin and set_user_origin use integer values.
Now, for example if the player stands next to a wall and saves his position,
later then teleports there, he has a 50% chance of being stuck in the wall,
as his float values of his origin were rounded to integers.
Someone please get me a solution for this Problem!
Thanks in Advance!
__________________
EAT YOUR VEGGIES
Silencer123 is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 09-28-2006 , 18:16   Re: get_user_origin and set_user_origin problem...
Reply With Quote #2

Use engine/fakemeta to set origin.

Fakemeta:
Code:
set_pev(id, pev_origin, flMyVectors);

I forget the exact engine native, just go to the funcwiki ;).
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 09-28-2006 , 18:37   Re: get_user_origin and set_user_origin problem...
Reply With Quote #3

Code:
new Float:origin[3]; // engine entity_get_vector(ent,EV_VEC_origin,origin); // get entity_set_origin(ent,origin); // set // fakemeta pev(ent,pev_origin,origin); // get engfunc(EngFunc_SetOrigin,ent,origin); // set

Apparently there is a difference between setting pev_origin, and using SetOrigin, or so I've been told.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 09-28-2006 , 18:43   Re: get_user_origin and set_user_origin problem...
Reply With Quote #4

Avalanche, stop making me look bad .
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 09-29-2006 , 08:26   Re: get_user_origin and set_user_origin problem...
Reply With Quote #5

Thanks to both of you. Ill check that out!
EDIT: It works fine. Just one Problem remains:
if i am ducking while saving but am standing when teleporting there, I am stuck in the Ground for about 17 Units.
So i need to make the player duck right in the moment he teleports.
client_cmd(id,"+duck") is not really working
__________________
EAT YOUR VEGGIES

Last edited by Silencer123; 09-29-2006 at 09:25.
Silencer123 is offline
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 09-29-2006 , 10:04   Re: get_user_origin and set_user_origin problem...
Reply With Quote #6

How about this, detect whether or not he is ducking when saving, then have it save the coords like normal but have it save his spot 20 units above the ground.
The only problem I can see with this is if you're saving your location while in a vent or other places with a low ceiling.
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))

Last edited by TheNewt; 09-29-2006 at 10:07.
TheNewt is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 09-29-2006 , 13:29   Re: get_user_origin and set_user_origin problem...
Reply With Quote #7

thats correct.
a command to force player to duck would help.
or just restrict saving while ducking
how do i check if a player is ducking?
i forgot it its something with pev or get_button.
(The engine way if possible)
__________________
EAT YOUR VEGGIES
Silencer123 is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 09-29-2006 , 14:16   Re: get_user_origin and set_user_origin problem...
Reply With Quote #8

I had the same problem in my RedRover plugin. No matter what I tried (and it was pretty damn extensive), I could not get the player to duck in time for the teleport. So, I just save if he was ducking, and if so add 17 to his Z origin when teleporting him back (alternatively, just save his origin modified). This is what I use to see if he was ducking:

Code:
// if(entity_get_int(id,EV_INT_bInDuck) || (entity_get_int(id,EV_INT_flags) & FL_DUCKING)) //

But players still get stuck sometimes, so I had to add a semi-buggy anti-stuck feature.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 09-29-2006 , 15:53   Re: get_user_origin and set_user_origin problem...
Reply With Quote #9

I think it is easier to restrict saving Location while ducking.
It works now. I am not going to release it, as it already exists a thousand Times.
Anyways:
Code:
#include <amxmodx> #include <engine> #include <fun> #define VERSION "1.0" new Float:origin[99][3] new bool:been_before_a[33] new bool:been_before_b[33] new bool:been_before_c[33] public plugin_init() {     register_plugin("Teleportation Device",VERSION,"Silencer")     register_menucmd(register_menuid("Tele"),1023,"TeleChoice")     register_concmd("telemenu","Tele",0,"- Open the Teleportation Device Menu")     register_cvar("amx_teleportation_device","1",FCVAR_SERVER) } public plugin_precache() {     precache_sound("ambience/loader_hydra1.wav")     precache_sound("ambience/particle_suck1.wav") } public set_all_back(id) {     been_before_a[id]=false     been_before_b[id]=false     been_before_c[id]=false     origin[id][0]=0.0     origin[id][1]=0.0     origin[id][2]=0.0     origin[id+33][0]=0.0     origin[id+33][1]=0.0     origin[id+33][2]=0.0     origin[id+66][0]=0.0     origin[id+66][1]=0.0     origin[id+66][2]=0.0 } public inform(id) {     if(get_cvar_num("amx_teleportation_device")>=1)     {         new name[32]         get_user_name(id,name,31)         client_print(id,print_chat,"[TD] Hello, %s. Teleportation Device is enabled - Bind a Key to ^"telemenu^".",name)     } } public client_connect(id) {     set_all_back(id)     set_task(30.0,"inform",id) } public client_disconnect(id) {     set_all_back(id) } public Tele(id) {     if(get_cvar_num("amx_teleportation_device")>=1)     {         new menuBody[1024]         new key         format(menuBody,1023,"Teleporation Device^n^n^n^n^n1.  Teleport to Destination A^n^n2.  Teleport to Destination B^n^n3.  Teleport to Destination C^n^n^n4. Save to Destination A^n^n5. Save to Destination B^n^n6. Save to Destination C^n^n^n^n0.  Cancel")         key=(1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<9)         show_menu(id,key,menuBody)     }     else     {         client_print(id,print_chat,"[TD] Teleportation Device is currently disabled.")         emit_sound(id,4,"ambience/warn3.wav",0.9,0.8,0,100)         set_task(0.3,"stop_warn3",id)     } } public TeleChoice(id,key) {     switch(key)     {         case 0:         {             if(get_cvar_num("amx_teleportation_device")>=1)             {                 if(been_before_a[id])                 {                     if(is_user_alive(id))                     {                         entity_set_origin(id,origin[id])                         client_print(id,print_chat,"[TD] You were Teleported to Destination saved to Slot A.")                         emit_sound(id,4,"ambience/particle_suck1.wav",0.9,0.8,0,109)                     }                     else                     {                         client_print(id,print_chat,"[TD] Dead People lie on the Ground. They do not use a Teleportation Device, for example...")                     }                 }                 else                 {                     client_print(id,print_chat,"[TD] You do not have saved a Destination to Slot A on this Connection, yet.")                 }             }             else             {                 client_print(id,print_chat,"[TD] Teleportation Device is currently disabled.")             }         }         case 1:         {             if(get_cvar_num("amx_teleportation_device")>=1)             {                 if(been_before_b[id])                 {                     if(is_user_alive(id))                     {                         entity_set_origin(id,origin[id+33])                         client_print(id,print_chat,"[TD] You were Teleported to Destination saved to Slot B.")                         emit_sound(id,4,"ambience/particle_suck1.wav",0.9,0.8,0,109)                     }                     else                     {                         client_print(id,print_chat,"[TD] Dead People lie on the Ground. They do not use a Teleportation Device, for example...")                     }                 }                 else                 {                     client_print(id,print_chat,"[TD] You do not have saved a Destination to Slot B on this Connection, yet.")                 }             }             else             {                 client_print(id,print_chat,"[TD] Teleportation Device is currently disabled.")             }         }         case 2:         {             if(get_cvar_num("amx_teleportation_device")>=1)             {                 if(been_before_c[id])                 {                     if(is_user_alive(id))                     {                         entity_set_origin(id,origin[id+66])                         client_print(id,print_chat,"[TD] You were Teleported to Destination saved to Slot C.")                         emit_sound(id,4,"ambience/particle_suck1.wav",0.9,0.8,0,109)                     }                     else                     {                         client_print(id,print_chat,"[TD] Dead People lie on the Ground. They do not use a Teleportation Device, for example...")                     }                 }                 else                 {                     client_print(id,print_chat,"[TD] You do not have saved a Destination to Slot C on this Connection, yet.")                 }             }             else             {                 client_print(id,print_chat,"[TD] Teleportation Device is currently disabled.")             }         }         case 3:         {             if(get_cvar_num("amx_teleportation_device")>=1)             {                 if(is_user_alive(id))                 {                     if(get_user_button(id)&IN_DUCK)                     {                         client_print(id,print_chat,"[TD] Saving Location while ducking is permitted.")                     }                     else                     {                         if(!been_before_a[id])                         {                             been_before_a[id]=true                         }                         entity_get_vector(id,EV_VEC_origin,origin[id])                         client_print(id,print_chat,"[TD] Your current Location was saved to Slot A.")                         emit_sound(id,4,"ambience/loader_hydra1.wav",0.7,0.8,0,100)                     }                 }                 else                 {                     client_print(id,print_chat,"[TD] Dead People lie on the Ground. They do not use a Teleportation Device, for example...")                 }             }             else             {                 client_print(id,print_chat,"[TD] Teleportation Device is currently disabled.")             }         }         case 4:         {             if(get_cvar_num("amx_teleportation_device")>=1)             {                 if(is_user_alive(id))                 {                     if(get_user_button(id)&IN_DUCK)                     {                         client_print(id,print_chat,"[TD] Saving Location while ducking is permitted.")                     }                     else                     {                         if(!been_before_b[id])                         {                             been_before_b[id]=true                         }                         entity_get_vector(id,EV_VEC_origin,origin[id+33])                         client_print(id,print_chat,"[TD] Your current Location was saved to Slot B.")                         emit_sound(id,4,"ambience/loader_hydra1.wav",0.7,0.8,0,100)                     }                 }                 else                 {                     client_print(id,print_chat,"[TD] Dead People lie on the Ground. They do not use a Teleportation Device, for example...")                 }             }             else             {                 client_print(id,print_chat,"[TD] Teleportation Device is currently disabled.")             }         }         case 5:         {             if(get_cvar_num("amx_teleportation_device")>=1)             {                 if(is_user_alive(id))                 {                     if(get_user_button(id)&IN_DUCK)                     {                         client_print(id,print_chat,"[TD] Saving Location while ducking is permitted.")                     }                     else                     {                         if(!been_before_c[id])                         {                             been_before_c[id]=true                         }                         entity_get_vector(id,EV_VEC_origin,origin[id+66])                         client_print(id,print_chat,"[TD] Your current Location was saved to Slot C.")                         emit_sound(id,4,"ambience/loader_hydra1.wav",0.7,0.8,0,100)                     }                 }                 else                 {                     client_print(id,print_chat,"[TD] Dead People lie on the Ground. They do not use a Teleportation Device, for example...")                 }             }             else             {                 client_print(id,print_chat,"[TD] Teleportation Device is currently disabled.")             }         }         case 9:         {             // Do nothing = Close Menu         }     }     return PLUGIN_HANDLED }
Allows every Player to save up to 3 different Destinations.
__________________
EAT YOUR VEGGIES
Silencer123 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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