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.
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.