AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_origin and set_user_origin problem... (https://forums.alliedmods.net/showthread.php?t=45307)

Silencer123 09-28-2006 18:00

get_user_origin and set_user_origin problem...
 
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!

Zenith77 09-28-2006 18:16

Re: get_user_origin and set_user_origin problem...
 
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 ;).

XxAvalanchexX 09-28-2006 18:37

Re: get_user_origin and set_user_origin problem...
 
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.

Zenith77 09-28-2006 18:43

Re: get_user_origin and set_user_origin problem...
 
Avalanche, stop making me look bad :P.

Silencer123 09-29-2006 08:26

Re: get_user_origin and set_user_origin problem...
 
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

TheNewt 09-29-2006 10:04

Re: get_user_origin and set_user_origin problem...
 
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.

Silencer123 09-29-2006 13:29

Re: get_user_origin and set_user_origin problem...
 
thats correct.
a command to force player to duck would help.
or just restrict saving while ducking :o
how do i check if a player is ducking?
i forgot it its something with pev or get_button.
(The engine way if possible)

XxAvalanchexX 09-29-2006 14:16

Re: get_user_origin and set_user_origin problem...
 
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.

Silencer123 09-29-2006 15:53

Re: get_user_origin and set_user_origin problem...
 
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.


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

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