PDA

View Full Version : [REQ] Can someone help me?


Wiggen94
06-21-2010, 21:34
hi!
can someone help me with this code?
i'd like it to be just like on kz maps, when you type .cp a checkpoint is made and if you type .tp i will teleport.
i don't want it to be /cp like it is now, and no menu is needed just .cp and .tp :)
/*
Syn-Scripts Checkpoint
Copyright © Zenith77 & www.thesyndicated.com 2006

Description:
This was (we don't use it as of now), the offical checkpoint system of Team Syndicated.
It is a simple plugin, but unlike other less user-friendly checkpoint plugins, it uses a menu that allows ease of use
and quick access to multiple checkpoints. I decided to release this since it was just sitting
there in my folder collecting dust.

Commands:
say /checkpoint - displays checkpoint menu
say /cp - displays checkpoint menu
say /cphelp - opens the checkpoint help window (MOTD style).

Using the menu:
Once you've opened your checkpoint menu you will see six options:
* Go to checkpoint - Goes to your last saved checkpoint
* Save checkpoint - Saves a checkpoint to your current poisition
* Create checkpoint - Creates a new checkpoint (Max Checkpoints: 5 [default])
* Erase checkpoint - Erases your current selected checkpoint
* Checkpoint # - Press this to go through your checkpoints in order to modify/teleport to them
* Exit - Exits the menu

NOTE: Some options may be blocked on certain conditions. These options will be "darkened/grayed" out.

CVars:
sv_checkpoint - [default: 1] Is checkpoint enabled on this server?
checkpoint_announce - [default: 240] Display checkpoint every # of seconds, shows short help (set this to zero to disable).
checkpoint_wait - [default: 5] How long does a player have to wait until he/she can teleport again?

Notes:
Very old and messy code :/.

All comments and suggestions welcomed.
*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "Syn-Scripts Checkpoint"
#define VERSION "1.0"
#define AUTHOR "Zenith77"

#define MAX_CHECKPOINTS 5

new gCVAREnabled;
new gCVARAnnounce;
new gCVARWait;

new gCheckpoints[33];
new Float:gNextCheckpointTime[33];
new Float:gCheckpointVec[33][MAX_CHECKPOINTS][3];

new gMenuCheckpoint[33];

public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)

gCVAREnabled = register_cvar("sv_checkpoint", "1", FCVAR_SERVER);
gCVARAnnounce = register_cvar("checkpoint_announce", "0");
gCVARWait = register_cvar("checkpoint_wait", "0");

register_clcmd("say /checkpoint", "CMD_CheckPoint", ADMIN_ALL, "- displays checkpoint menu");
register_clcmd("say /cp", "CMD_CheckPoint", ADMIN_ALL, "- displays checkpoint menu");
register_clcmd("say /cphelp", "CMD_Help", ADMIN_ALL, "- shows checkpoint help window");

register_menucmd(register_menuid("Syn-Scripts Checkpoint Menu"), 1023, "PressedCheckpointMenu")

set_task(float(get_pcvar_num(gCVARAnnounce)), "Task_Announce");
}

public client_connect(id)
{
gCheckpoints[id] = -1;
gNextCheckpointTime[id] = 0.0;
gMenuCheckpoint[id] = 0;

static i;
static j;
for (i = 0; i < MAX_CHECKPOINTS; i++)
for (j = 0; j < 3; j++)
gCheckpointVec[id][i][j] = 0.0;
}

/*
public client_putinserver(id)
set_task(2.0, "PrintInfoToConsole", id + 555);

public PrintInfoToConsole(id)
{
id -= 555;

client_print(id, print_console, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
client_print(id, print_console, ">>> Checkpoint is enabled on this server: >>>");
client_print(id, print_console, ">>> say /cphelp for more information! >>>");
client_print(id, print_console, ">>> Sponsored by: www.efrigid.org >>>");
client_print(id, print_console, ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
}
*/

public CMD_CheckPoint(id)
{
if (!get_pcvar_num(gCVAREnabled))
{
client_print(id, print_chat, "[AMXX] Checkpoint is currently disabled.");
return PLUGIN_HANDLED;
}

if (!is_user_alive(id))
{
client_print(id, print_chat, "[AMXX] Sorry, dead people can't use checkpoint!");
return PLUGIN_HANDLED;
}
if (gCheckpoints[id] <= -1)
gMenuCheckpoint[id] = -1;
else
gMenuCheckpoint[id] = 0;

ShowCheckpointMenu(id);

return PLUGIN_HANDLED;
}

public CMD_Help(id)
{
new len = 1600
new buffer[1601]
new n = 0

n += format(buffer[n],len-n,"<html><head><style type=^"text/css^">pre{color:#FFB000;}body{background:#000000;ma rgin-left:8px;margin-top:0px;}</style></head><body><pre>^n");

n += format(buffer[n],len-n,"<b>Commands</b>^n");
n += format(buffer[n],len-n,"<li>say /checkpoint - displays checkpoint menu</li>^n");
n += format(buffer[n],len-n,"<li>say /cp - displays checkpoint menu</li>^n");
n += format(buffer[n],len-n,"<li>say /cphelp - displays this window</li>^n^n");

n += format(buffer[n],len-n,"<b>How to use checkpoint</b>^n")
n += format(buffer[n],len-n,"Once you've opened your checkpoint menu you will see six options:^n");
n += format(buffer[n],len-n,"<li>Go to checkpoint - Goes to your last saved checkpoint</li>^n");
n += format(buffer[n],len-n,"<li>Save checkpoint - Saves a checkpoint to your current poisition</li>^n");
n += format(buffer[n],len-n,"<li>Create checkpoint - Creates a new checkpoint (Max Checkpoints: <b>%d</b>)</li>^n", MAX_CHECKPOINTS);
n += format(buffer[n],len-n,"<li>Erase checkpoint - Erases your current selected checkpoint^n");
n += format(buffer[n],len-n,"<li>Checkpoint #</li> - Press this to go through your checkpoints in order to modify/teleport to them^n");
n += format(buffer[n],len-n,"<li>Exit - Exits the menu</li>^n^n");

n += format(buffer[n],len-n,"<i>NOTE: Some options may be blocked on certain conditions. These options will be ^"darkened/grayed^" out.</i>^n^n");

n += format(buffer[n],len-n,"<b>Status</b>^n");
n += format(buffer[n],len-n,"Checkpoint is currently: <b>%s</b>^n^n", get_pcvar_num(gCVAREnabled) ? "ON" : "OFF");

n += format(buffer[n],len-n,"<b>Other</b>^n");
n += format(buffer[n],len-n,"Visit our offical website at: www.efrigid.org (www.thesyndicated.com)^n");
n += format(buffer[n],len-n,"This plugin made by: syn.zenith");
n += format(buffer[n],len-n,"</html>");

show_motd(id, buffer, "Syn-Scripts Checkpoint Help");

return PLUGIN_HANDLED;
}

public Task_Announce()
{
// We set this any way since the cvar can be toggled on/off
set_task(float(get_pcvar_num(gCVARAnnounce)), "Task_Announce");

if (!get_pcvar_num(gCVAREnabled) || !get_pcvar_num(gCVARAnnounce))
return;

client_print(0, print_chat, "[AMXX] Checkpoint is currently enabled, say /cphelp for more information.");
}

#define MENU_SIZE 300

// I honestly hate my code from this point forward.
// I'm going to change it when I don't feel so lazy :/.
ShowCheckpointMenu(id)
{
new menu[MENU_SIZE];
new keys = MENU_KEY_0;
new szColor[4];

if (gCheckpoints[id] > -1)
{
keys |= MENU_KEY_1|MENU_KEY_2|MENU_KEY_4;

if (gCheckpoints[id] >= 1)
keys |= MENU_KEY_8;

szColor[0] = 0;
}
else
copy(szColor, 3, "\d");

if (gCheckpoints[id] < MAX_CHECKPOINTS-1)
keys |= MENU_KEY_3;

new checkpoint = /*gCheckpoints[id] <= 0 ?*/ gMenuCheckpoint[id]+1 //: gCheckpoints[id];

format(menu, MENU_SIZE-1, "\rSyn-Scripts Checkpoint Menu^n\yYou have %d checkpoints^n^n\w%s1. Go to checkpoint^n\w%s2. Save checkpoint^n%s3. Create new checkpoint^n\
\w%s4. Erase checkpoint^n^n%s8. Checkpoint #%d^n^n\w0. Exit", gCheckpoints[id]+1, szColor, szColor, keys &MENU_KEY_3 ? "\w" : "\d", szColor,
keys &MENU_KEY_4 ? "\y" : "\d", checkpoint);

show_menu(id, keys, menu);
}

public PressedCheckpointMenu(id, key)
{
// new Float:velocity[3]
new flags;

// pev(id, pev_velocity, velocity);
flags = pev(id, pev_flags);

switch(key)
{
case 0:
{
if (get_gametime() < gNextCheckpointTime[id])
{
ShowCheckpointMenu(id);
client_print(id, print_chat, "[AMXX] You cannot teleport that often!");

return;
}

if (!(pev(id, pev_flags) &FL_ONGROUND) && !(flags &FL_INWATER))
{
ShowCheckpointMenu(id);
client_print(id, print_chat, "[AMXX] You cannot teleport while you're off the ground!");

return;
}

new Float:origin[3];
pev(id, pev_origin, origin);

message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_TELEPORT);
engfunc(EngFunc_WriteCoord, origin[0]);
engfunc(EngFunc_WriteCoord, origin[1]);
engfunc(EngFunc_WriteCoord, origin[2]);
message_end();

set_pev(id, pev_origin, gCheckpointVec[id][gMenuCheckpoint[id]]);

message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(TE_TELEPORT);
engfunc(EngFunc_WriteCoord, gCheckpointVec[id][gMenuCheckpoint[id]][0]);
engfunc(EngFunc_WriteCoord, gCheckpointVec[id][gMenuCheckpoint[id]][1]);
engfunc(EngFunc_WriteCoord, gCheckpointVec[id][gMenuCheckpoint[id]][2]);
message_end();

gNextCheckpointTime[id] = get_gametime() + float(get_pcvar_num(gCVARWait));

ShowCheckpointMenu(id);
//client_print(id, print_chat, "[Syn-Scripts] You have been teleported to checkpoint #%d", gMenuCheckpoint[id]);
}

case 1:
{
if (!(flags &FL_ONGROUND) && !(flags &FL_INWATER))
{
ShowCheckpointMenu(id);
client_print(id, print_chat, "[AMXX] You cannot save a checkpoint while you're off the ground and/or in the water!");

return;
}

pev(id, pev_origin, gCheckpointVec[id][gMenuCheckpoint[id]]);

if (flags &FL_DUCKING)
gCheckpointVec[id][gMenuCheckpoint[id]][2] += 30.0;

client_print(id, print_chat, "[AMXX] Checkpoint #%d saved", gMenuCheckpoint[id] + 1);
ShowCheckpointMenu(id);
}

case 2:
{
pev(id, pev_origin, gCheckpointVec[id][++gCheckpoints[id]]);

gMenuCheckpoint[id] = gCheckpoints[id];
client_print(id, print_chat, "[AMXX] Created checkpoint #%d", gCheckpoints[id]+1);

ShowCheckpointMenu(id);
}


case 3:
{
new i;
for (i = 0; i < 3; i++)
gCheckpointVec[id][gMenuCheckpoint[id]][i] = 0.0;

gMenuCheckpoint[id] = --gCheckpoints[id];

client_print(id, print_chat, "[AMXX] Checkpoint erased");
ShowCheckpointMenu(id);
}

case 7:
{
if (gMenuCheckpoint[id] == gCheckpoints[id])
gMenuCheckpoint[id] = 0;
else
++gMenuCheckpoint[id];

ShowCheckpointMenu(id);
}

}

}