Raised This Month: $ Target: $400
 0% 

Set checkpoints


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-16-2009 , 15:41   Set checkpoints
Reply With Quote #1

Hi,

i´m workin on a mod like Rally or whatever its named. so i wont ask if is there anyway to set on maps any checkpoints that checks the player positions & saves the time.i think u all know what i mean.

he a simple video that ma member maked.

http://www.youtube.com/watch?v=yv-Zimm7y2o

EDIT : u have to wait 4 HQ mod on youtube.
EDIT : video link updated.
__________________

Last edited by One; 03-17-2009 at 11:02.
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-16-2009 , 16:14   Re: Set checkpoints
Reply With Quote #2

Create box entities that are invisible and are the checkpoints.
When the player touches it, then the player made a checkpoint.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-16-2009 , 17:40   Re: Set checkpoints
Reply With Quote #3

yea, iknow that, but how to creat boxs?
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
padilha007
Senior Member
Join Date: Jul 2008
Old 03-16-2009 , 19:26   Re: Set checkpoints
Reply With Quote #4

http://forums.alliedmods.net/showthread.php?t=43321

or

http://forums.alliedmods.net/showthread.php?t=11756
__________________

padilha007 is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-17-2009 , 10:50   Re: Set checkpoints
Reply With Quote #5

hihihihi ))))

whats here wrong?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
const gHudRed 255;
const 
gHudGreen 255;
const 
gHudBlue 255;
new 
g_Classname[] = "func_timer"
const Float:gfTextX = -1.0;
const 
Float:gfTextY 0.84;
const 
gHudEffects 0;
const 
Float:gfHudFxTime 0.0;
const 
Float:gfHudHoldTime 0.25;
const 
Float:gfHudFadeInTime 0.0;
const 
Float:gfHudFadeOutTime 0.0;
const 
gHudChannel 2;

public 
plugin_init()
{
    
register_plugin("test","one","1?")
   
    
register_clcmd("say /addpoint","Cmdcheckpoint")
   
    
register_forward(FM_Touch,"ForwardTouch")
}

public 
Cmdcheckpoint(id)
{
    new 
Ent engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    
set_pev(Ent,pev_classname,g_Classname)
    
set_pev(Ent,pev_solid,SOLID_TRIGGER)
    
engfunc(EngFunc_SetSize,Ent,Float:{-50.0,-50.0,-50.0},Float:{50.0,50.0,50.0})
    
set_pev(Ent,pev_owner,id)
}

public 
ForwardTouch(Ptd,Ptr)
{
    new 
Classname[33],Ent Ptd,id Ptr
    pev
(Ptd,pev_classname,Classname,32)
   
    if(!
equal(Classname,g_Classname))
    {
        
Ent Ptr
        id 
Ptd
       
        pev
(Ptr,pev_classname,Classname,32)
       
        if(!
equal(Classname,g_Classname))
            return
    }
   
    new 
Owner pev(Ent,pev_owner)
    if(
Owner != id)
        return
   
        
set_hudmessage(gHudRedgHudGreengHudBluegfTextXgfTextYgHudEffectsgfHudFxTimegfHudHoldTimegfHudFadeInTimegfHudFadeOutTimegHudChannel);
        
show_hudmessage(id"Checkpoint 1...");

__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
padilha007
Senior Member
Join Date: Jul 2008
Old 03-17-2009 , 11:48   Re: Set checkpoints
Reply With Quote #6

any error?
__________________

padilha007 is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-17-2009 , 11:54   Re: Set checkpoints
Reply With Quote #7

First. its not working.
second : only one error, but we can ignore this.

PHP Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c1997-2006 ITB CompuPhaseAMX Mod X Team

Warning
Loose indentation on line 55
Header size
:            356 bytes
Code size
:             1304 bytes
Data size
:              396 bytes
Stack
/heap size:      16384 bytesestimated maxusage=780 cells (3120 bytes)
Total requirements:   18440 bytes

1 Warning
.
Done
ill write a new hudmessage. its not to hard.

line 55
PHP Code:
set_hudmessage(gHudRedgHudGreengHudBluegfTextXgfTextYgHudEffectsgfHudFxTimegfHudHoldTimegfHudFadeInTimegfHudFadeOutTimegHudChannel); 
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-17-2009 , 12:25   Re: Set checkpoints
Reply With Quote #8

Ok. i´m finish with the first step. but ma menu dont shows up :

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>

#define PLUGIN "Checkpoint maker"
#define VERSION "1.0"
#define AUTHOR "One"

#define POST_FORWARD 1
#define PRE_FORWARD 0

#define FM_TEAM_OFFSET 114
#define fm_get_user_team(%1) get_pdata_int(%1, FM_TEAM_OFFSET)

#define MENU_ACCESS ADMIN_BAN

#define TASK_SHOWpoint_ID 144690
#define TASK_SHOWAV_ID 290661

#define MAX_CP_POINTS 25


enum {
    
IZ_FIRST_POINT 0,
    
IZ_SECOND_POINT
};

new 
g_iMainMenu;

new 
g_iMaxPlayers;
new 
g_iBeamSprite;
new 
g_ipoints;

new 
g_iCurrentEnt[33];
new 
g_szTouchedpoint[33][32];
new 
g_iBuildStage[33];
new 
Float:g_fLastTouch[33];
new 
Float:g_fOriginBox[33][2][3];
new 
bool:g_bInBuild[33];

new 
g_iColor[3] = { 0255255 };

new const 
g_szIzClassName[] = "Checkpoint_mk";

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd("say /cp""clcmdMainMenu"MENU_ACCESS"");
    
register_clcmd("say /cpmenu""clcmdMainMenu"MENU_ACCESS"");
    
register_clcmd("set_cp_mk""clcmdcp_mk"MENU_ACCESS"");
    
register_clcmd("say_team""clcmdSayTeam", -1"");
    
    
    
register_forward(FM_Touch"Fwd_Touch"PRE_FORWARD);
    
register_forward(FM_PlayerPreThink"Fwd_PlayerPreThink"POST_FORWARD);
    
    
g_iMainMenu menu_create("\yCheckpoint Maker \rBy One""menuMainHandle"0);
    
menu_additem(g_iMainMenu"New CP_Point""1"0, -1);
    
menu_additem(g_iMainMenu"Delete CP_Point""2"0, -1);
    
menu_additem(g_iMainMenu"Select CP_Point""3"0, -1);
    
menu_additem(g_iMainMenu"Rename CP_Point""4"0, -1);
    
menu_addblank(g_iMainMenu0);
    
menu_additem(g_iMainMenu"Show/Hide CP_Point""5"0, -1);
    
menu_addblank(g_iMainMenu0);
    
menu_additem(g_iMainMenu"Delete all CP_Points""6"0, -1);
    
menu_additem(g_iMainMenu"Save CP_Points""7"0, -1);
    
menu_addblank(g_iMainMenu0);
    
    
g_iMaxPlayers global_get(glb_maxClients);
}

public 
plugin_precache()
    
g_iBeamSprite precache_model("sprites/dot.spr");

public 
plugin_cfg()
{
    new 
szFile[64], szMapName[32];
    
get_datadir(szFilesizeof szFile 1);
    
get_mapname(szMapNamesizeof szMapName 1);
    
    
add(szFilesizeof szFile 1"/CP_Point");
    
    if(!
dir_exists(szFile))
        
mkdir(szFile);
    
    
format(szFilesizeof szFile 1"%s/Checkpoints_%s.ini"szFileszMapName);
    
    new 
iFile fopen(szFile"at+");
    
    new 
szBuffer[256];
    new 
szTargetName[32], szOrigin[64], szMins[64], szMaxs[64];
    new 
szTemp1[3][32], szTemp2[3][32], szTemp3[3][32];
    
    while(!
feof(iFile))
    {
        
fgets(iFileszBuffersizeof szBuffer 1);
        
        if(!
szBuffer[0])
            continue;
        
        
parse(szBufferszTargetNamesizeof szTargetName 1szOriginsizeof szOrigin 1szMinssizeof szMins 1szMaxssizeof szMaxs 1);
        
        
str_piece(szOriginszTemp1sizeof szTemp1sizeof szTemp1[] - 1';');
        
str_piece(szMinsszTemp2sizeof szTemp2sizeof szTemp2[] - 1';');
        
str_piece(szMaxsszTemp3sizeof szTemp3sizeof szTemp3[] - 1';');
        
        static 
Float:fOrigin[3], Float:fMins[3], Float:fMaxs[3];
        
fOrigin[0] = str_to_float(szTemp1[0]);
        
fOrigin[1] = str_to_float(szTemp1[1]);
        
fOrigin[2] = str_to_float(szTemp1[2]);
        
        
fMins[0] = str_to_float(szTemp2[0]);
        
fMins[1] = str_to_float(szTemp2[1]);
        
fMins[2] = str_to_float(szTemp2[2]);
        
        
fMaxs[0] = str_to_float(szTemp3[0]);
        
fMaxs[1] = str_to_float(szTemp3[1]);
        
fMaxs[2] = str_to_float(szTemp3[2]);
        
        
fm_create_cp_point(fOriginfMinsfMaxsszTargetName);
        
        
g_ipoints++;
        
        if(
g_ipoints >= MAX_CP_POINTS)
        {
            
fclose(iFile);
            return;
        }
    }
    
fclose(iFile);
}

public 
clcmdcp_mk(id)
{
    if(!(
get_user_flags(id) & MENU_ACCESS))
        return 
1;
    
    new 
szArgs[32];
    
read_argv(1szArgssizeof szArgs 1);
    
    if(
szArgs[0] && pev_valid(g_iCurrentEnt[id]))
    {
        
set_pev(g_iCurrentEnt[id], pev_targetnameszArgs);
        
        
client_printg(id"> Successfully seted the CP-Point description ^"%s^"."szArgs);
    }
    return 
1;
}

public 
clcmdMainMenu(id)
{
    if(!(
get_user_flags(id) & MENU_ACCESS))
        return 
1;
    
    
menu_display(idg_iMainMenu0);
    
    
set_hudmessage(4285255, -1.00.706.05.00.50.5, -1);
    
show_hudmessage(id"Current CP-Points num: '%d'^nMax CP-Points num: '%d'"g_ipointsMAX_CP_POINTS);
    
    return 
0;
}

public 
menuMainHandle(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        if(
task_exists(id TASK_SHOWAV_ID))
            
remove_task(id TASK_SHOWAV_ID);
        
        
g_bInBuild[id] = false;
        
        return 
1;
    }
    
    new 
szData[6], iAccessiCallBack;
    
menu_item_getinfo(menuitemiAccessszDatasizeof szData 1__iCallBack);
    
    new 
iKey str_to_num(szData);
    
    switch(
iKey)
    {
        case 
:
        {
            if(
g_bInBuild[id])
            {
                
menu_display(idmenu0);
                return 
1;
            }
            
            if(
g_ipoints >= MAX_CP_POINTS)
            {
                
client_printg(id"> Sorry, limit of CP-Points reached (%d)."MAX_CP_POINTS);
                
menu_display(idmenu0);
                
                return 
1;
            }
            
g_bInBuild[id] = true;
            
            if(!
task_exists(id TASK_SHOWAV_ID))
                
set_task(0.5"taskShowAimVector"id TASK_SHOWAV_ID""0"b"0);
            
            
client_printg(id"> Set the origin for the top right corner of the box.");
            
            
menu_display(idmenu0);
        }
        case 

        {
            if(
pev_valid(g_iCurrentEnt[id]))
            {    
                new 
szTargetName[32];
                
pev(g_iCurrentEnt[id], pev_targetnameszTargetNamesizeof szTargetName 1);
                
                
engfunc(EngFunc_RemoveEntityg_iCurrentEnt[id]);
                
                
client_printg(id"> Successfully removed CP-Points ^"%s^"."szTargetName);
                
                
g_ipoints--;
                
                
menu_display(idmenu0);
            }
            else
            {
                
client_printg(id"> Invalid CP-Points ent index.");
                
                
menu_display(idmenu0);
            }
        }
        case 
:
        {
            new 
iMenu menu_create("\yCP Point : Select""menuSelectHandle"0);
            
            new 
iEnt = -1;
            while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"g_szIzClassName)) != 0)
            {
                static 
szTargetName[32];
                
pev(iEntpev_targetnameszTargetNamesizeof szTargetName 1);
                
                
menu_additem(iMenuszTargetName""0, -1);
            }
            if(
menu_items(iMenu) > 0)
                
menu_addblank(iMenu0);
            
            
menu_display(idiMenu0);
        }
        case 
:
        {
            if(
pev_valid(g_iCurrentEnt[id]))
            {
                
client_cmd(id"messagemode set_cp_mk");
                
                
menu_display(idmenu0);
            }
            else
            {
                
client_printg(id"> Invalid CP-Point ent index.");
                
                
menu_display(idmenu0);
            }
        }
        case 
:
        {
            if(!
task_exists(TASK_SHOWpoint_ID id) && g_ipoints)
                
set_task(1.0"taskSHOWpoints"TASK_SHOWpoint_ID id""0"b"0);
            else
                
remove_task(TASK_SHOWpoint_ID id);
            
            
menu_display(idmenu0);
        }
        case 
:
        {
            new 
iEnt = -1;
            while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"g_szIzClassName)) != 0)
                
engfunc(EngFunc_RemoveEntityiEnt);
            
            
client_printg(id"> Successfully deleted all CP-Points.");
            
            
g_ipoints 0;
            
            
menu_display(idmenu0);
            
        }
        case 
:
        {
            new 
szFile[64], szMapName[32];
            
get_datadir(szFilesizeof szFile 1);
            
get_mapname(szMapNamesizeof szMapName 1);
            
            
format(szFilesizeof szFile 1"%s/Checkpoints/Checkpoints_%s.ini"szFileszMapName);
            
            new 
iFile fopen(szFile"wt+");
            
            new 
iEnt = -1;
            while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"g_szIzClassName)) != 0)
            {
                static 
szTargetName[32], Float:fOrigin[3], Float:fMins[3], Float:fMaxs[3];
                
                
pev(iEntpev_targetnameszTargetNamesizeof szTargetName 1);
                
pev(iEntpev_minsfMins);
                
pev(iEntpev_maxsfMaxs);
                
pev(iEntpev_originfOrigin);
                
                
fprintf(iFile"^"%s^" ^"%.1f;%.1f;%.1f^" ^"%.1f;%.1f;%.1f^" ^"%.1f;%.1f;%.1f^"^n"szTargetNamefOrigin[0], fOrigin[1], fOrigin[2], fMins[0], fMins[1], fMins[2], fMaxs[0], fMaxs[1], fMaxs[2]);
            }
            
fclose(iFile);
            
            
client_printg(0"> Successfully saved all CP_Points (%d)."g_ipoints);
        }
    }
    return 
1;
}

public 
taskShowPoint(id)
{
    
id -= TASK_SHOWpoint_ID;
    
    if(!
is_user_connected(id))
    {
        
remove_task(TASK_SHOWpoint_ID id);
        return;
    }
    
    new 
iEnt fm_get_nearest_iz(id);
    
    new 
Float:fOrigin[3], Float:fMins[3], Float:fMaxs[3];
    
    
pev(iEntpev_minsfMins);
    
pev(iEntpev_maxsfMaxs);
    
pev(iEntpev_originfOrigin);
    
    
fMins[0] += fOrigin[0];
    
fMins[1] += fOrigin[1];
    
fMins[2] += fOrigin[2];
    
fMaxs[0] += fOrigin[0];
    
fMaxs[1] += fOrigin[1];
    
fMaxs[2] += fOrigin[2];
    
    
fm_draw_line(idfMaxs[0], fMaxs[1], fMaxs[2], fMins[0], fMaxs[1], fMaxs[2], g_iColor);
    
fm_draw_line(idfMaxs[0], fMaxs[1], fMaxs[2], fMaxs[0], fMins[1], fMaxs[2], g_iColor);
    
fm_draw_line(idfMaxs[0], fMaxs[1], fMaxs[2], fMaxs[0], fMaxs[1], fMins[2], g_iColor);
    
fm_draw_line(idfMins[0], fMins[1], fMins[2], fMaxs[0], fMins[1], fMins[2], g_iColor);
    
fm_draw_line(idfMins[0], fMins[1], fMins[2], fMins[0], fMaxs[1], fMins[2], g_iColor);
    
fm_draw_line(idfMins[0], fMins[1], fMins[2], fMins[0], fMins[1], fMaxs[2], g_iColor);
    
fm_draw_line(idfMins[0], fMaxs[1], fMaxs[2], fMins[0], fMaxs[1], fMins[2], g_iColor);
    
fm_draw_line(idfMins[0], fMaxs[1], fMins[2], fMaxs[0], fMaxs[1], fMins[2], g_iColor);
    
fm_draw_line(idfMaxs[0], fMaxs[1], fMins[2], fMaxs[0], fMins[1], fMins[2], g_iColor);
    
fm_draw_line(idfMaxs[0], fMins[1], fMins[2], fMaxs[0], fMins[1], fMaxs[2], g_iColor);
    
fm_draw_line(idfMaxs[0], fMins[1], fMaxs[2], fMins[0], fMins[1], fMaxs[2], g_iColor);
    
fm_draw_line(idfMins[0], fMins[1], fMaxs[2], fMins[0], fMaxs[1], fMaxs[2], g_iColor);
}

public 
taskShowAimVector(id)
{
    
id -= TASK_SHOWAV_ID;
    
    if(!
is_user_connected(id))
    {
        
remove_task(TASK_SHOWAV_ID id);
        return;
    }
    
    static 
Float:vAim[3];
    
velocity_by_aim(id64vAim);
    
    static 
Float:vOrigin[3];
    
pev(idpev_originvOrigin);
    
    
vOrigin[0] += vAim[0];
    
vOrigin[1] += vAim[1];
    
    if(!(
pev(idpev_flags) & FL_DUCKING))
        
vOrigin[2] += (vAim[2] + 16.0);
    else
        
vOrigin[2] += (vAim[2] + 12.0);
    
    static 
Float:vOrigin2[3];
    
    
vOrigin2[0] = vOrigin[0];
    
vOrigin2[1] = vOrigin[1];
    
vOrigin2[2] = vOrigin[2];
    
    
vOrigin[0] += 16.0;
    
fm_draw_line(idvOrigin[0], vOrigin[1], vOrigin[2], vOrigin2[0], vOrigin2[1], vOrigin2[2], {25500});
    
    
vOrigin[0] -= 16.0;
    
vOrigin[1] += 16.0;
    
fm_draw_line(idvOrigin[0], vOrigin[1], vOrigin[2], vOrigin2[0], vOrigin2[1], vOrigin2[2], {00255});
    
    
vOrigin[1] -= 16.0;
    
vOrigin[2] += 16.0;
    
fm_draw_line(idvOrigin[0], vOrigin[1], vOrigin[2], vOrigin2[0], vOrigin2[1], vOrigin2[2], {02550});
}

public 
menuSelectHandle(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_display(idg_iMainMenu0);
        return 
1;
    }
    
    new 
iAccessszName[32], iCallback;
    
menu_item_getinfo(menuitemiAccess""0szNamesizeof szName 1iCallback);
    
    new 
iEnt = -1;
    while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"targetname"szName)) != 0)
    {
        if(
pev_valid(iEnt))
            
g_iCurrentEnt[id] = iEnt;
    }
    
    
client_printg(id"> Successfully selected CP_Point ^"%s^"."szName);
    
    
menu_display(idg_iMainMenu0);
    return 
1;
}

public 
Fwd_Touch(Entid)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED;
    
    static 
szClassName[32];
    
pev(Entpev_classnameszClassNamesizeof szClassName 1);
    
    static 
Float:fGameTime;
    
fGameTime get_gametime();
    
    if(
equal(szClassNameg_szIzClassName) && (fGameTime g_fLastTouch[id]) > 0.1)
    {
        static 
szTargetName[32];
        
pev(Entpev_targetnameszTargetNamesizeof szTargetName 1);
        
        if(!
equal(g_szTouchedpoint[id], szTargetName))
            
formatex(g_szTouchedpoint[id], sizeof g_szTouchedpoint[] - 1szTargetName);
        
        
g_fLastTouch[id] = fGameTime;
    }
    return 
FMRES_IGNORED;
}

public 
Fwd_PlayerPreThink(id)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED;
    
    static 
Float:fGameTime;
    
fGameTime get_gametime();
    
    if((
fGameTime g_fLastTouch[id]) > 0.5 && strlen(g_szTouchedpoint[id]))
        
g_szTouchedpoint[id][0] = '^0';
    
    if(((
pev(idpev_button) & IN_ATTACK) && !(pev(idpev_oldbuttons) & IN_ATTACK) || (pev(idpev_button) & IN_USE && !(pev(idpev_oldbuttons) & IN_USE))) && g_bInBuild[id])
    {
        new 
Float:fOrigin[3];
        
        if(
pev(idpev_button) & IN_ATTACK)
            
fm_get_aim_origin(idfOrigin);
        else
        {
            new 
Float:fAim[3];
            
velocity_by_aim(id64fAim);
            
            
pev(idpev_originfOrigin);
            
            
fOrigin[0] += fAim[0];
            
fOrigin[1] += fAim[1];
            
            if(!(
pev(idpev_flags) & FL_DUCKING))
                
fOrigin[2] += (fAim[2] + 16.0);
            else
                
fOrigin[2] += (fAim[2] + 12.0);
        }
        
        if(
g_iBuildStage[id] == IZ_FIRST_POINT)
        {
            
g_iBuildStage[id] = IZ_SECOND_POINT;
            
            
g_fOriginBox[id][IZ_FIRST_POINT] = fOrigin;
            
            
client_printg(id"> Now set the origin for the bottom left corner of the box.");
        }
        else
        {
            
g_iBuildStage[id] = IZ_FIRST_POINT;
            
g_bInBuild[id] = false;
            
            
g_fOriginBox[id][IZ_SECOND_POINT] = fOrigin;
            
            if(
task_exists(id TASK_SHOWAV_ID))
                
remove_task(id TASK_SHOWAV_ID);
            
            new 
Float:fCenter[3], Float:fSize[3];
            new 
Float:fMins[3], Float:fMaxs[3];
            
            for ( new 
03i++ )
            {
                
fCenter[i] = (g_fOriginBox[id][IZ_FIRST_POINT][i] + g_fOriginBox[id][IZ_SECOND_POINT][i]) / 2.0;
                
                
fSize[i] = get_float_difference(g_fOriginBox[id][IZ_FIRST_POINT][i], g_fOriginBox[id][IZ_SECOND_POINT][i]);
                
                
fMins[i] = fSize[i] / -2.0;    
                
fMaxs[i] = fSize[i] / 2.0;
            }
            new 
iEnt fm_create_cp_point(fCenterfMinsfMaxs"");
            
            
g_ipoints++;
            
            
g_iCurrentEnt[id] = iEnt;
            
            
client_cmd(id"messagemode set_cp_mk");
            
            
client_printg(id"> Enter the CP_Point description.");
        }
    }
    return 
FMRES_IGNORED;
}



stock fm_get_aim_origin(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;
}

stock fm_create_cp_point(Float:fOrigin[3], Float:fMins[3], Float:fMaxs[3], const szTargetName[])
{
    new 
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
    
    if(!
iEnt)
        return 
0;
    
    
engfunc(EngFunc_SetOriginiEntfOrigin);
    
    
set_pev(iEntpev_classnameg_szIzClassName);
    
set_pev(iEntpev_targetnameszTargetName);
    
    
dllfunc(DLLFunc_SpawniEnt);
    
    
set_pev(iEntpev_movetypeMOVETYPE_FLY);
    
set_pev(iEntpev_solidSOLID_TRIGGER);
    
    
engfunc(EngFunc_SetSizeiEntfMinsfMaxs);
    
    return 
iEnt;
}

stock fm_draw_line(idFloat:x1Float:y1Float:z1Float:x2Float:y2Float:z2g_iColor[3])
{
    
message_begin(id MSG_ONE_UNRELIABLE MSG_BROADCASTSVC_TEMPENTITY_id id 0);
    
    
write_byte(TE_BEAMPOINTS);
    
    
write_coord(floatround(x1));
    
write_coord(floatround(y1));
    
write_coord(floatround(z1));
    
    
write_coord(floatround(x2));
    
write_coord(floatround(y2));
    
write_coord(floatround(z2));
    
    
write_short(g_iBeamSprite);
    
write_byte(1);
    
write_byte(1);
    
write_byte(10);
    
write_byte(5);
    
write_byte(0); 
    
    
write_byte(g_iColor[0]);
    
write_byte(g_iColor[1]); 
    
write_byte(g_iColor[2]);
    
    
write_byte(200); 
    
write_byte(0);
    
    
message_end();
}

stock client_printg(id, const message[], {FloatSqlResul,_}:...) {
    
    static 
msg[192];
    
msg[0] = 0x04;
    
    
vformat(msg[1], 190message3);
    
    if( 
id && id <= g_iMaxPlayers)
    {
        
message_begin(MSG_ONEget_user_msgid("SayText"),_id);
        
write_byte(id);
        
write_string(msg);
        
message_end();
    }
    else if(
id == 0)
    {
        for( new 
1<= g_iMaxPlayersi++ )
        {
            if(!
is_user_connected(i))
                continue;
            
            
message_begin(MSG_ONEget_user_msgid("SayText"),_i);
            
write_byte(i);
            
write_string(msg);
            
message_end();
        }
    }
}

stock print_SayText(senderreceiver, const szMessage[])
{
    static 
MSG_typeid;
    
    if(
receiver 0)
    {
        
MSG_type MSG_ONE_UNRELIABLE;
        
id receiver;
    }
    else
    {
        
MSG_type MSG_BROADCAST;
        
id sender;
    }
    
    
message_begin(MSG_typeget_user_msgid("SayText"), _id);
    
write_byte(sender);
    
write_string(szMessage);
    
message_end();
    
    return 
1;
}

stock get_radio_num(const szRadioCode[])
{
    for(new 
0sizeof g_szRadioCodei++)
    {
        if(
equali(g_szRadioCode[i], szRadioCode))
            return 
i;
    }
    return -
1;
}

stock str_piece(const input[], output[][], outputsizepiecelentoken '|')
{
    new 
= -1pieceslen = -;
    
    while ( 
input[++i] != )
    {
        if ( 
input[i] != token )
        {
            if ( ++
len piecelen )
                
output[pieces][len] = input[i] ;
        }
        else
        {
            
output[pieces++][++len] = ;
            
len = -;
            
            if ( 
pieces == outputsize )
                return 
pieces ;
        }
    }
    return 
pieces 1;
}

stock Float:get_float_difference(Float:num1Float:num2)
{
    if( 
num1 num2 )
        return (
num1-num2);
    else if( 
num2 num1 )
        return (
num2-num1);
    
    return 
0.0;
}

stock fm_get_nearest_iz(id)
{
    new 
Float:fPlrOrigin[3], Float:fNearestDist 9999.0iNearestEnt;
    new 
Float:fOrigin[3], Float:fCurDist;
    
    
pev(idpev_originfPlrOrigin);
    
    new 
iEnt = -1;
    while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"g_szIzClassName)) != 0)
    {
        
pev(iEntpev_originfOrigin);
        
        
fCurDist vector_distance(fPlrOriginfOrigin);
        
        if(
fCurDist fNearestDist)
        {
            
fNearestDist fCurDist;
            
iNearestEnt iEnt;
        }
    }
    return 
iNearestEnt;

__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
padilha007
Senior Member
Join Date: Jul 2008
Old 03-17-2009 , 12:43   Re: Set checkpoints
Reply With Quote #9

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>

#define PLUGIN "Checkpoint maker"
#define VERSION "1.0"
#define AUTHOR "One"

#define POST_FORWARD 1
#define PRE_FORWARD 0

#define FM_TEAM_OFFSET 114
#define fm_get_user_team(%1) get_pdata_int(%1, FM_TEAM_OFFSET)

#define MENU_ACCESS ADMIN_BAN

#define TASK_SHOWpoint_ID 144690
#define TASK_SHOWAV_ID 290661

#define MAX_CP_POINTS 25


enum {
    
IZ_FIRST_POINT 0,
    
IZ_SECOND_POINT
};

new 
g_iMainMenu;

new 
g_iBeamSprite;
new 
g_ipoints;

new 
g_iCurrentEnt[33];
new 
g_szTouchedpoint[33][32];
new 
g_iBuildStage[33];
new 
Float:g_fLastTouch[33];
new 
Float:g_fOriginBox[33][2][3];
new 
bool:g_bInBuild[33];

new 
g_iColor[3] = { 0255255 };

new const 
g_szIzClassName[] = "Checkpoint_mk";

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd("say /cp""clcmdMainMenu"MENU_ACCESS"");
    
register_clcmd("say /cpmenu""clcmdMainMenu"MENU_ACCESS"");
    
register_clcmd("set_cp_mk""clcmdcp_mk"MENU_ACCESS"");
    
register_clcmd("say_team""clcmdSayTeam", -1"");
    
    
register_forward(FM_Touch"Fwd_Touch"PRE_FORWARD);
    
register_forward(FM_PlayerPreThink"Fwd_PlayerPreThink"POST_FORWARD);
}

public 
plugin_precache()
    
g_iBeamSprite precache_model("sprites/dot.spr");

public 
plugin_cfg()
{
    new 
szFile[64], szMapName[32];
    
get_datadir(szFilesizeof szFile 1);
    
get_mapname(szMapNamesizeof szMapName 1);
    
    
add(szFilesizeof szFile 1"/CP_Point");
    
    if(!
dir_exists(szFile))
        
mkdir(szFile);
    
    
format(szFilesizeof szFile 1"%s/Checkpoints_%s.ini"szFileszMapName);
    
    new 
iFile fopen(szFile"at+");
    
    new 
szBuffer[256];
    new 
szTargetName[32], szOrigin[64], szMins[64], szMaxs[64];
    new 
szTemp1[3][32], szTemp2[3][32], szTemp3[3][32];
    
    while(!
feof(iFile))
    {
        
fgets(iFileszBuffersizeof szBuffer 1);
        
        if(!
szBuffer[0])
            continue;
        
        
parse(szBufferszTargetNamesizeof szTargetName 1szOriginsizeof szOrigin 1szMinssizeof szMins 1szMaxssizeof szMaxs 1);
        
        
str_piece(szOriginszTemp1sizeof szTemp1sizeof szTemp1[] - 1';');
        
str_piece(szMinsszTemp2sizeof szTemp2sizeof szTemp2[] - 1';');
        
str_piece(szMaxsszTemp3sizeof szTemp3sizeof szTemp3[] - 1';');
        
        static 
Float:fOrigin[3], Float:fMins[3], Float:fMaxs[3];
        
fOrigin[0] = str_to_float(szTemp1[0]);
        
fOrigin[1] = str_to_float(szTemp1[1]);
        
fOrigin[2] = str_to_float(szTemp1[2]);
        
        
fMins[0] = str_to_float(szTemp2[0]);
        
fMins[1] = str_to_float(szTemp2[1]);
        
fMins[2] = str_to_float(szTemp2[2]);
        
        
fMaxs[0] = str_to_float(szTemp3[0]);
        
fMaxs[1] = str_to_float(szTemp3[1]);
        
fMaxs[2] = str_to_float(szTemp3[2]);
        
        
fm_create_cp_point(fOriginfMinsfMaxsszTargetName);
        
        
g_ipoints++;
        
        if(
g_ipoints >= MAX_CP_POINTS)
        {
            
fclose(iFile);
            return;
        }
    }
    
fclose(iFile);
}

public 
clcmdcp_mk(id)
{
    if(!(
get_user_flags(id) & MENU_ACCESS))
        return 
1;
    
    new 
szArgs[32];
    
read_argv(1szArgssizeof szArgs 1);
    
    if(
szArgs[0] && pev_valid(g_iCurrentEnt[id]))
    {
        
set_pev(g_iCurrentEnt[id], pev_targetnameszArgs);
        
        
client_printg(id"> Successfully seted the CP-Point description ^"%s^"."szArgs);
    }
    return 
1;
}

public 
clcmdMainMenu(id)
{
    if(!(
get_user_flags(id) & MENU_ACCESS))
        return 
1;
    
    new 
g_iMainMenu menu_create("\yCheckpoint Maker \rBy One""menuMainHandle"0);
    
    
menu_additem(g_iMainMenu"New CP_Point""1"0, -1);
    
menu_additem(g_iMainMenu"Delete CP_Point""2"0, -1);
    
menu_additem(g_iMainMenu"Select CP_Point""3"0, -1);
    
menu_additem(g_iMainMenu"Rename CP_Point""4"0, -1);
    
menu_addblank(g_iMainMenu0);
    
menu_additem(g_iMainMenu"Show/Hide CP_Point""5"0, -1);
    
menu_addblank(g_iMainMenu0);
    
menu_additem(g_iMainMenu"Delete all CP_Points""6"0, -1);
    
menu_additem(g_iMainMenu"Save CP_Points""7"0, -1);
    
menu_addblank(g_iMainMenu0);
    
    
menu_setprop(g_iMainMenuMPROP_EXITMEXIT_ALL)
    
menu_display(idg_iMainMenu0);
    
    
set_hudmessage(4285255, -1.00.706.05.00.50.5, -1);
    
show_hudmessage(id"Current CP-Points num: '%d'^nMax CP-Points num: '%d'"g_ipointsMAX_CP_POINTS);
    
    return 
0;
}

public 
menuMainHandle(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        if(
task_exists(id TASK_SHOWAV_ID))
            
remove_task(id TASK_SHOWAV_ID);
        
        
g_bInBuild[id] = false;
        
        return 
1;
    }
    
    new 
szData[6], iAccessiCallBack;
    
menu_item_getinfo(menuitemiAccessszDatasizeof szData 1__iCallBack);
    
    new 
iKey str_to_num(szData);
    
    switch(
iKey)
    {
        case 
:
        {
            if(
g_bInBuild[id])
            {
                
menu_display(idmenu0);
                return 
1;
            }
            
            if(
g_ipoints >= MAX_CP_POINTS)
            {
                
client_printg(id"> Sorry, limit of CP-Points reached (%d)."MAX_CP_POINTS);
                
menu_display(idmenu0);
                
                return 
1;
            }
            
g_bInBuild[id] = true;
            
            if(!
task_exists(id TASK_SHOWAV_ID))
                
set_task(0.5"taskShowAimVector"id TASK_SHOWAV_ID""0"b"0);
            
            
client_printg(id"> Set the origin for the top right corner of the box.");
            
            
menu_display(idmenu0);
        }
        case 

        {
            if(
pev_valid(g_iCurrentEnt[id]))
            {    
                new 
szTargetName[32];
                
pev(g_iCurrentEnt[id], pev_targetnameszTargetNamesizeof szTargetName 1);
                
                
engfunc(EngFunc_RemoveEntityg_iCurrentEnt[id]);
                
                
client_printg(id"> Successfully removed CP-Points ^"%s^"."szTargetName);
                
                
g_ipoints--;
                
                
menu_display(idmenu0);
            }
            else
            {
                
client_printg(id"> Invalid CP-Points ent index.");
                
                
menu_display(idmenu0);
            }
        }
        case 
:
        {
            new 
iMenu menu_create("\yCP Point : Select""menuSelectHandle"0);
            
            new 
iEnt = -1;
            while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"g_szIzClassName)) != 0)
            {
                static 
szTargetName[32];
                
pev(iEntpev_targetnameszTargetNamesizeof szTargetName 1);
                
                
menu_additem(iMenuszTargetName""0, -1);
            }
            if(
menu_items(iMenu) > 0)
                
menu_addblank(iMenu0);
            
            
menu_display(idiMenu0);
        }
        case 
:
        {
            if(
pev_valid(g_iCurrentEnt[id]))
            {
                
client_cmd(id"messagemode set_cp_mk");
                
                
menu_display(idmenu0);
            }
            else
            {
                
client_printg(id"> Invalid CP-Point ent index.");
                
                
menu_display(idmenu0);
            }
        }
        case 
:
        {
            if(!
task_exists(TASK_SHOWpoint_ID id) && g_ipoints)
                
set_task(1.0"taskSHOWpoints"TASK_SHOWpoint_ID id""0"b"0);
            else
                
remove_task(TASK_SHOWpoint_ID id);
            
            
menu_display(idmenu0);
        }
        case 
:
        {
            new 
iEnt = -1;
            while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"g_szIzClassName)) != 0)
                
engfunc(EngFunc_RemoveEntityiEnt);
            
            
client_printg(id"> Successfully deleted all CP-Points.");
            
            
g_ipoints 0;
            
            
menu_display(idmenu0);
            
        }
        case 
:
        {
            new 
szFile[64], szMapName[32];
            
get_datadir(szFilesizeof szFile 1);
            
get_mapname(szMapNamesizeof szMapName 1);
            
            
format(szFilesizeof szFile 1"%s/Checkpoints/Checkpoints_%s.ini"szFileszMapName);
            
            new 
iFile fopen(szFile"wt+");
            
            new 
iEnt = -1;
            while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"g_szIzClassName)) != 0)
            {
                static 
szTargetName[32], Float:fOrigin[3], Float:fMins[3], Float:fMaxs[3];
                
                
pev(iEntpev_targetnameszTargetNamesizeof szTargetName 1);
                
pev(iEntpev_minsfMins);
                
pev(iEntpev_maxsfMaxs);
                
pev(iEntpev_originfOrigin);
                
                
fprintf(iFile"^"%s^" ^"%.1f;%.1f;%.1f^" ^"%.1f;%.1f;%.1f^" ^"%.1f;%.1f;%.1f^"^n"szTargetNamefOrigin[0], fOrigin[1], fOrigin[2], fMins[0], fMins[1], fMins[2], fMaxs[0], fMaxs[1], fMaxs[2]);
            }
            
fclose(iFile);
            
            
client_printg(0"> Successfully saved all CP_Points (%d)."g_ipoints);
        }
    }
    return 
1;
}

public 
taskShowPoint(id)
{
    
id -= TASK_SHOWpoint_ID;
    
    if(!
is_user_connected(id))
    {
        
remove_task(TASK_SHOWpoint_ID id);
        return;
    }
    
    new 
iEnt fm_get_nearest_iz(id);
    
    new 
Float:fOrigin[3], Float:fMins[3], Float:fMaxs[3];
    
    
pev(iEntpev_minsfMins);
    
pev(iEntpev_maxsfMaxs);
    
pev(iEntpev_originfOrigin);
    
    
fMins[0] += fOrigin[0];
    
fMins[1] += fOrigin[1];
    
fMins[2] += fOrigin[2];
    
fMaxs[0] += fOrigin[0];
    
fMaxs[1] += fOrigin[1];
    
fMaxs[2] += fOrigin[2];
    
    
fm_draw_line(idfMaxs[0], fMaxs[1], fMaxs[2], fMins[0], fMaxs[1], fMaxs[2], g_iColor);
    
fm_draw_line(idfMaxs[0], fMaxs[1], fMaxs[2], fMaxs[0], fMins[1], fMaxs[2], g_iColor);
    
fm_draw_line(idfMaxs[0], fMaxs[1], fMaxs[2], fMaxs[0], fMaxs[1], fMins[2], g_iColor);
    
fm_draw_line(idfMins[0], fMins[1], fMins[2], fMaxs[0], fMins[1], fMins[2], g_iColor);
    
fm_draw_line(idfMins[0], fMins[1], fMins[2], fMins[0], fMaxs[1], fMins[2], g_iColor);
    
fm_draw_line(idfMins[0], fMins[1], fMins[2], fMins[0], fMins[1], fMaxs[2], g_iColor);
    
fm_draw_line(idfMins[0], fMaxs[1], fMaxs[2], fMins[0], fMaxs[1], fMins[2], g_iColor);
    
fm_draw_line(idfMins[0], fMaxs[1], fMins[2], fMaxs[0], fMaxs[1], fMins[2], g_iColor);
    
fm_draw_line(idfMaxs[0], fMaxs[1], fMins[2], fMaxs[0], fMins[1], fMins[2], g_iColor);
    
fm_draw_line(idfMaxs[0], fMins[1], fMins[2], fMaxs[0], fMins[1], fMaxs[2], g_iColor);
    
fm_draw_line(idfMaxs[0], fMins[1], fMaxs[2], fMins[0], fMins[1], fMaxs[2], g_iColor);
    
fm_draw_line(idfMins[0], fMins[1], fMaxs[2], fMins[0], fMaxs[1], fMaxs[2], g_iColor);
}

public 
taskShowAimVector(id)
{
    
id -= TASK_SHOWAV_ID;
    
    if(!
is_user_connected(id))
    {
        
remove_task(TASK_SHOWAV_ID id);
        return;
    }
    
    static 
Float:vAim[3];
    
velocity_by_aim(id64vAim);
    
    static 
Float:vOrigin[3];
    
pev(idpev_originvOrigin);
    
    
vOrigin[0] += vAim[0];
    
vOrigin[1] += vAim[1];
    
    if(!(
pev(idpev_flags) & FL_DUCKING))
        
vOrigin[2] += (vAim[2] + 16.0);
    else
        
vOrigin[2] += (vAim[2] + 12.0);
    
    static 
Float:vOrigin2[3];
    
    
vOrigin2[0] = vOrigin[0];
    
vOrigin2[1] = vOrigin[1];
    
vOrigin2[2] = vOrigin[2];
    
    
vOrigin[0] += 16.0;
    
fm_draw_line(idvOrigin[0], vOrigin[1], vOrigin[2], vOrigin2[0], vOrigin2[1], vOrigin2[2], {25500});
    
    
vOrigin[0] -= 16.0;
    
vOrigin[1] += 16.0;
    
fm_draw_line(idvOrigin[0], vOrigin[1], vOrigin[2], vOrigin2[0], vOrigin2[1], vOrigin2[2], {00255});
    
    
vOrigin[1] -= 16.0;
    
vOrigin[2] += 16.0;
    
fm_draw_line(idvOrigin[0], vOrigin[1], vOrigin[2], vOrigin2[0], vOrigin2[1], vOrigin2[2], {02550});
}

public 
menuSelectHandle(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_display(idg_iMainMenu0);
        return 
1;
    }
    
    new 
iAccessszName[32], iCallback;
    
menu_item_getinfo(menuitemiAccess""0szNamesizeof szName 1iCallback);
    
    new 
iEnt = -1;
    while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"targetname"szName)) != 0)
    {
        if(
pev_valid(iEnt))
            
g_iCurrentEnt[id] = iEnt;
    }
    
    
client_printg(id"> Successfully selected CP_Point ^"%s^"."szName);
    
    
menu_display(idg_iMainMenu0);
    return 
1;
}

public 
Fwd_Touch(Entid)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED;
    
    static 
szClassName[32];
    
pev(Entpev_classnameszClassNamesizeof szClassName 1);
    
    static 
Float:fGameTime;
    
fGameTime get_gametime();
    
    if(
equal(szClassNameg_szIzClassName) && (fGameTime g_fLastTouch[id]) > 0.1)
    {
        static 
szTargetName[32];
        
pev(Entpev_targetnameszTargetNamesizeof szTargetName 1);
        
        if(!
equal(g_szTouchedpoint[id], szTargetName))
            
formatex(g_szTouchedpoint[id], sizeof g_szTouchedpoint[] - 1szTargetName);
        
        
g_fLastTouch[id] = fGameTime;
    }
    return 
FMRES_IGNORED;
}

public 
Fwd_PlayerPreThink(id)
{
    if(!
is_user_alive(id))
        return 
FMRES_IGNORED;
    
    static 
Float:fGameTime;
    
fGameTime get_gametime();
    
    if((
fGameTime g_fLastTouch[id]) > 0.5 && strlen(g_szTouchedpoint[id]))
        
g_szTouchedpoint[id][0] = '^0';
    
    if(((
pev(idpev_button) & IN_ATTACK) && !(pev(idpev_oldbuttons) & IN_ATTACK) || (pev(idpev_button) & IN_USE && !(pev(idpev_oldbuttons) & IN_USE))) && g_bInBuild[id])
    {
        new 
Float:fOrigin[3];
        
        if(
pev(idpev_button) & IN_ATTACK)
            
fm_get_aim_origin(idfOrigin);
        else
        {
            new 
Float:fAim[3];
            
velocity_by_aim(id64fAim);
            
            
pev(idpev_originfOrigin);
            
            
fOrigin[0] += fAim[0];
            
fOrigin[1] += fAim[1];
            
            if(!(
pev(idpev_flags) & FL_DUCKING))
                
fOrigin[2] += (fAim[2] + 16.0);
            else
                
fOrigin[2] += (fAim[2] + 12.0);
        }
        
        if(
g_iBuildStage[id] == IZ_FIRST_POINT)
        {
            
g_iBuildStage[id] = IZ_SECOND_POINT;
            
            
g_fOriginBox[id][IZ_FIRST_POINT] = fOrigin;
            
            
client_printg(id"> Now set the origin for the bottom left corner of the box.");
        }
        else
        {
            
g_iBuildStage[id] = IZ_FIRST_POINT;
            
g_bInBuild[id] = false;
            
            
g_fOriginBox[id][IZ_SECOND_POINT] = fOrigin;
            
            if(
task_exists(id TASK_SHOWAV_ID))
                
remove_task(id TASK_SHOWAV_ID);
            
            new 
Float:fCenter[3], Float:fSize[3];
            new 
Float:fMins[3], Float:fMaxs[3];
            
            for ( new 
03i++ )
            {
                
fCenter[i] = (g_fOriginBox[id][IZ_FIRST_POINT][i] + g_fOriginBox[id][IZ_SECOND_POINT][i]) / 2.0;
                
                
fSize[i] = get_float_difference(g_fOriginBox[id][IZ_FIRST_POINT][i], g_fOriginBox[id][IZ_SECOND_POINT][i]);
                
                
fMins[i] = fSize[i] / -2.0;    
                
fMaxs[i] = fSize[i] / 2.0;
            }
            new 
iEnt fm_create_cp_point(fCenterfMinsfMaxs"");
            
            
g_ipoints++;
            
            
g_iCurrentEnt[id] = iEnt;
            
            
client_cmd(id"messagemode set_cp_mk");
            
            
client_printg(id"> Enter the CP_Point description.");
        }
    }
    return 
FMRES_IGNORED;
}



stock fm_get_aim_origin(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;
}

stock fm_create_cp_point(Float:fOrigin[3], Float:fMins[3], Float:fMaxs[3], const szTargetName[])
{
    new 
iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
    
    if(!
iEnt)
        return 
0;
    
    
engfunc(EngFunc_SetOriginiEntfOrigin);
    
    
set_pev(iEntpev_classnameg_szIzClassName);
    
set_pev(iEntpev_targetnameszTargetName);
    
    
dllfunc(DLLFunc_SpawniEnt);
    
    
set_pev(iEntpev_movetypeMOVETYPE_FLY);
    
set_pev(iEntpev_solidSOLID_TRIGGER);
    
    
engfunc(EngFunc_SetSizeiEntfMinsfMaxs);
    
    return 
iEnt;
}

stock fm_draw_line(idFloat:x1Float:y1Float:z1Float:x2Float:y2Float:z2g_iColor[3])
{
    
message_begin(id MSG_ONE_UNRELIABLE MSG_BROADCASTSVC_TEMPENTITY_id id 0);
    
    
write_byte(TE_BEAMPOINTS);
    
    
write_coord(floatround(x1));
    
write_coord(floatround(y1));
    
write_coord(floatround(z1));
    
    
write_coord(floatround(x2));
    
write_coord(floatround(y2));
    
write_coord(floatround(z2));
    
    
write_short(g_iBeamSprite);
    
write_byte(1);
    
write_byte(1);
    
write_byte(10);
    
write_byte(5);
    
write_byte(0); 
    
    
write_byte(g_iColor[0]);
    
write_byte(g_iColor[1]); 
    
write_byte(g_iColor[2]);
    
    
write_byte(200); 
    
write_byte(0);
    
    
message_end();
}

stock client_printg(id, const message[], {FloatSqlResul,_}:...) {
    
    static 
msg[192];
    
msg[0] = 0x04;
    
    
vformat(msg[1], 190message3);
    
    if( 
id && id <= get_maxplayers())
    {
        
message_begin(MSG_ONEget_user_msgid("SayText"),_id);
        
write_byte(id);
        
write_string(msg);
        
message_end();
    }
    else if(
id == 0)
    {
        for( new 
1<= get_maxplayers(); i++ )
        {
            if(!
is_user_connected(i))
                continue;
            
            
message_begin(MSG_ONEget_user_msgid("SayText"),_i);
            
write_byte(i);
            
write_string(msg);
            
message_end();
        }
    }
}

stock print_SayText(senderreceiver, const szMessage[])
{
    static 
MSG_typeid;
    
    if(
receiver 0)
    {
        
MSG_type MSG_ONE_UNRELIABLE;
        
id receiver;
    }
    else
    {
        
MSG_type MSG_BROADCAST;
        
id sender;
    }
    
    
message_begin(MSG_typeget_user_msgid("SayText"), _id);
    
write_byte(sender);
    
write_string(szMessage);
    
message_end();
    
    return 
1;
}

stock get_radio_num(const szRadioCode[])
{
    for(new 
0sizeof g_szRadioCodei++)
    {
        if(
equali(g_szRadioCode[i], szRadioCode))
            return 
i;
    }
    return -
1;
}

stock str_piece(const input[], output[][], outputsizepiecelentoken '|')
{
    new 
= -1pieceslen = -;
    
    while ( 
input[++i] != )
    {
        if ( 
input[i] != token )
        {
            if ( ++
len piecelen )
                
output[pieces][len] = input[i] ;
        }
        else
        {
            
output[pieces++][++len] = ;
            
len = -;
            
            if ( 
pieces == outputsize )
                return 
pieces ;
        }
    }
    return 
pieces 1;
}

stock Float:get_float_difference(Float:num1Float:num2)
{
    if( 
num1 num2 )
        return (
num1-num2);
    else if( 
num2 num1 )
        return (
num2-num1);
    
    return 
0.0;
}

stock fm_get_nearest_iz(id)
{
    new 
Float:fPlrOrigin[3], Float:fNearestDist 9999.0iNearestEnt;
    new 
Float:fOrigin[3], Float:fCurDist;
    
    
pev(idpev_originfPlrOrigin);
    
    new 
iEnt = -1;
    while((
iEnt engfunc(EngFunc_FindEntityByStringiEnt"classname"g_szIzClassName)) != 0)
    {
        
pev(iEntpev_originfOrigin);
        
        
fCurDist vector_distance(fPlrOriginfOrigin);
        
        if(
fCurDist fNearestDist)
        {
            
fNearestDist fCurDist;
            
iNearestEnt iEnt;
        }
    }
    return 
iNearestEnt;

__________________

padilha007 is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-17-2009 , 13:25   Re: Set checkpoints
Reply With Quote #10

Ty, its working. btw first : please say what was ma problem.
second : i cant add a point. i can see the box & .. but i cant plant the box :-(

__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Reply



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 08:58.


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