Raised This Month: $105 Target: $400
 26% 

Check Point (TouchTarget)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
myusername
Senior Member
Join Date: Aug 2012
Old 01-31-2014 , 15:24   Check Point (TouchTarget)
Reply With Quote #1

Hello, i need help with this plugin.

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>

#define P "CheckPoint"
#define V "1.1"
#define A "BlackSmoke"

#define ClassName "info_checkpoint"
#define stn(%1) str_to_num(%1)
#define MaxCheckOnTheMap 15

new bool:bTouchPlayerCheck[33][512]
new 
iNumCheckRoundPl[33], bool:LastCheckbool:bOffCheck
new BeaconSprite
new Float:fTimeStartRound[33]

new 
szFile[127], OriginFile[MaxCheckOnTheMap][512]

new const 
szSoundCheck[3][] = 
{
    
"BlackSmoke/task_complete.wav",
    
"BlackSmoke/checkpoint_last.wav",
    
"BlackSmoke/wg_life_dr.wav"
}

new const 
szModelCheck[6][] = 
{
    
"models/BlackSmoke/Blue.mdl",
    
"models/BlackSmoke/Gray.mdl",
    
"models/BlackSmoke/Green.mdl",
    
"models/BlackSmoke/Red.mdl",
    
"models/BlackSmoke/Yellow.mdl",
    
"models/BlackSmoke/Purple.mdl"
}
new const 
szColorCheck[6][] = {/*Blue*/"0 0 255",/*Gray*/"100 100 100",/*Green*/"0 255 0",/*Red*/"255 0 0",/*Yellow*/"255 255 0",/*Purple*/"255 0 255"}

public 
plugin_init()
{
    
register_plugin(P,V,A)
    
register_touch(ClassName"player""TouchTarget")
    
register_think(ClassName"FwdThinkCheck")
    
register_think("info_checkpoint_finish""FwdThinkCheck")
    
register_touch("info_checkpoint_finish""player""TouchTargetFinish")
    
register_clcmd("amxx_add_check_point""MenuCheck")
    
register_event("HLTV""logevent_round_start""a""1=0""2=0")
    
register_menucmd(register_menuid("MenuCheckPointsAdd"), 1023"ActionMenuCheckPointsAdd")
    
    
RegisterHam(Ham_Killed"player""Ham_Killed_player_Post"1);
}

public 
MenuCheck(id)
{
    if(!(
get_user_flags(id) & ADMIN_MENU))
    {
        
client_print(idprint_console"You have no access to this command")
        return 
PLUGIN_HANDLED
    
}
    new 
szMenu[1024], iLenikey MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_0
    iLen 
format(szMenu[iLen], charsmax(szMenu)-iLen"\yCheckPoint^n\yPoints: \r%d \w| \yLast: \r%sChecked^n^n"GetNumEntity(ClassName), LastCheck "" "Un")
    
iLen += format(szMenu[iLen], charsmax(szMenu)-iLen"\y1. \wAdd \d[\yLeft\d: \r%d\d]^n", (MaxCheckOnTheMap GetNumEntity(ClassName)))
    
iLen += format(szMenu[iLen], charsmax(szMenu)-iLen"\y2. \wAdd Last \d[\yLeft\d: \r%d\d]^n"LastCheck 1)
    
iLen += format(szMenu[iLen], charsmax(szMenu)-iLen"\y3. \wDelete All^n^n")
    
iLen += format(szMenu[iLen], charsmax(szMenu)-iLen"\y4. \wCheckpoint \d[\y%s\d]^n"bOffCheck "Off" "On")
    
    
iLen += format(szMenu[iLen], charsmax(szMenu)-iLen"^n\r0. \wExit^n")
    
    
show_menu(idikeyszMenu, -1"MenuCheckPointsAdd")
    return 
PLUGIN_HANDLED
}

public 
ActionMenuCheckPointsAdd(idkey)
{
    switch(
key)
    {
        case 
0
        {
            if(
GetNumEntity(ClassName) >= 15)
            {
                return 
PLUGIN_CONTINUE
            
}
            new 
iOrigin[3], Float:fOrigin[3]
            
get_user_origin(idiOrigin3)
            
IVecFVec(iOriginfOrigin)
            
fOrigin[2] += 60.0
            AddCheck
(0fOrigin)
            
            
MenuCheck(id)
        }
        case 
1:
        {
            if(
LastCheck)
            {
                return 
PLUGIN_CONTINUE
            
}
            new 
iOrigin[3], Float:fOrigin[3]
            
get_user_origin(idiOrigin3)
            
IVecFVec(iOriginfOrigin)
            
fOrigin[2] += 60.0
            AddCheck
(1fOrigin)
            
            
MenuCheck(id)
        }
        case 
2:
        {
            
remove_entity_name(ClassName)
            
remove_entity_name("info_checkpoint_finish")
            
LastCheck false
            delete_file
(szFile)
            
MenuCheck(id)
        }
        case 
3:
        {
            
bOffCheck bOffCheck false true
            MenuCheck
(id)
        }
    }
    return 
PLUGIN_HANDLED
}

public 
Ham_Killed_player_Post(victimattacker)
{
    new 
q[33]
    
    
fTimeStartRound[victim] = get_gametime()
    
iNumCheckRoundPl[victim] = 0
    
while(q[victim] < 510)
    {
        
q[victim]++
        
bTouchPlayerCheck[victim][q[victim]] = false
    
}
}

public 
logevent_round_start()
{
    new 
iPlayers[32], iNumq[33]
    
get_players(iPlayersiNum)
    for(new 
iiNumi++)
    {
        
fTimeStartRound[iPlayers[i]] = get_gametime()
        
iNumCheckRoundPl[iPlayers[i]] = 0
        
while(q[iPlayers[i]] < 510)
        {
            
q[iPlayers[i]]++
            
bTouchPlayerCheck[iPlayers[i]][q[iPlayers[i]]] = false
        
}
    }
}

public 
TouchTarget(ent,id)
{
    if(!
is_valid_ent(ent) || !is_user_connected(id))
        return 
PLUGIN_CONTINUE
        
    
if(bTouchPlayerCheck[id][ent])
        return 
PLUGIN_CONTINUE
    
    iNumCheckRoundPl
[id]++
    
bTouchPlayerCheck[id][ent] = true
    
    
return PLUGIN_CONTINUE
}

public 
TouchTargetFinish(ent,id)
{
    if(!
is_valid_ent(ent) || !is_user_connected(id))
        return 
PLUGIN_CONTINUE
        
    
if(bTouchPlayerCheck[id][ent])
        return 
PLUGIN_CONTINUE
    
    
new szName[32]
    
get_user_name(idszNamecharsmax(szName))
    
    
Color_Print(0"!g%s !yfinished the map: !g%d:%02d"szNamefloatround(get_gametime() - fTimeStartRound[id]) / 60floatround(get_gametime() - fTimeStartRound[id]) % 60)
    
bTouchPlayerCheck[id][ent] = true
    client_cmd
(id"spk ^"%s^""szSoundCheck[random_num(0,sizeof szSoundCheck 1)])
    
    return 
PLUGIN_CONTINUE
}

public 
plugin_precache()
{
    for(new 
isizeof szModelChecki++)
        
precache_model(szModelCheck[i])
    for(new 
ysizeof szSoundChecky++)
        
precache_sound(szSoundCheck[y])
        
    
BeaconSprite precache_model("sprites/shockwave.spr")
    
    new 
CheckFolder[127]
    
format(CheckFoldercharsmax(CheckFolder), "addons/amxmodx/configs/checkpoints")
    if(!
dir_exists(CheckFolder))
    
mkdir(CheckFolder)
    
    new 
Map[32]
    
get_mapname(Map31)
    
format(szFilecharsmax(szFile), "%s/%s.ini"CheckFolder,Map)
    new 
qLeniNumString,p[5][32], Float:origin[3]
    if(
file_exists(szFile))
    {
        while(
MaxCheckOnTheMap && read_file(szFile,OriginFile[iNumString], 511Len))
        {
            
q++
            if(
OriginFile[iNumString][0] == ';' || Len == || !OriginFile[iNumString][0])
            {
                continue
            }
            
parse(OriginFile[iNumString], p[1], 31,p[2], 31,p[3], 31,p[4],31)
            
origin[0] = str_to_float(p[1])
            
origin[1] = str_to_float(p[2])
            
origin[2] = str_to_float(p[3])
            
AddCheck(str_to_num(p[4]), origin0)
            
iNumString++
        }
    }
}    

public 
FwdThinkCheck(ent)
{
    if(!
is_valid_ent(ent))
        return;
    
    if(!
bOffCheck)
        
UTIL_PlayAnimation(ent50)
    else
        
set_rendering(ent)
        
    
entity_set_float(entEV_FL_nextthinkget_gametime() + 1.90)
    
entity_set_int(entEV_INT_solidbOffCheck SOLID_NOT SOLID_TRIGGER)
}

stock AddCheck(type=0,Float:fOrigin[3]={0.0,0.0,0.0},save 1)
{
    static 
iNumber
    
if(save)
    {
        new 
szSave[512]
        
format(szSave511"%f %f %f %d"fOrigin[0], fOrigin[1], fOrigin[2], type)
        
write_file(szFileszSave)
    }
    if(
type)
        
LastCheck true
    
    iNumber
++    
    new 
iEntrnd random_num(0,sizeof szModelCheck 1),p[4][32]
    
iEnt create_entity("info_target")
    
parse(szColorCheck[rnd], p[1],5,p[2],5,p[3],5)
    if(
is_valid_ent(iEnt))
    {
        
entity_set_string(iEntEV_SZ_classnametype "info_checkpoint_finish" ClassName)
        
entity_set_float(iEntEV_FL_nextthinkget_gametime() + 0.1)
        
entity_set_origin(iEntfOrigin)
        
DispatchSpawn(iEnt)
        
entity_set_model(iEntszModelCheck[rnd])
        
set_rendering(iEntkRenderFxGlowShellstn(p[1]),stn(p[2]),stn(p[3]))
        
entity_set_int(iEntEV_INT_solidSOLID_TRIGGER)
        
entity_set_size(iEntFloat:{ -40.0, -40.0, -40.0 },  Float:{ 40.040.040.0 }) 
    }
}

stock UTIL_PlayAnimation( const entity, const sequence, const Float:framerate 1.0 )
{
    
entity_set_float(entityEV_FL_animtimeget_gametime());
    
entity_set_float(entityEV_FL_framerateframerate);
    
entity_set_float(entityEV_FL_frame0.0);
    
entity_set_int(entityEV_INT_sequencesequence);
    
    new 
Float:origin[3], c[4][6], szModel[127]
    
entity_get_string(entityEV_SZ_modelszModelcharsmax(szModel))
    for(new 
isizeof szModelChecki++)
    {
        if(
equal(szModelszModelCheck[i]))
        {
            
parse(szColorCheck[i], c[1],5,c[2],5,c[3],5)
            break;
        }
    }
    
set_rendering(entitykRenderFxGlowShellstn(c[1]),stn(c[2]),stn(c[3])) 
    
entity_get_vector(entityEV_VEC_originorigin)
    
origin[2] -= 50.0
    engfunc
(EngFunc_MessageBeginMSG_BROADCASTSVC_TEMPENTITYorigin0
    
write_byte(TE_BEAMCYLINDER)
    
engfunc(EngFunc_WriteCoordorigin[0]) //start x
    
engfunc(EngFunc_WriteCoordorigin[1]) //start y
    
engfunc(EngFunc_WriteCoordorigin[2]) //start z
    
engfunc(EngFunc_WriteCoordorigin[0]+50//end x
    
engfunc(EngFunc_WriteCoordorigin[1]) //end y
    
engfunc(EngFunc_WriteCoordorigin[2]+135//end z
    
write_short(BeaconSprite)
    
write_byte(0)
    
write_byte(1)
    
write_byte(6)
    
write_byte(1)  //hight
    
write_byte(1
    
write_byte(stn(c[1])) //red
    
write_byte(stn(c[2])) //green
    
write_byte(stn(c[3])) //blue
    
write_byte(255)
    
write_byte(0)
    
message_end()
}

stock Color_Print(const id, const input[], any:...)
{
    new 
count 1players[32]
    static 
msg[191]
    new 
pr[32]
    
format(pr,31,P), pr[11] = '^0'
    
vformat(msg190input3)
    
format(msgsizeof(msg), "^1[^4%s^1] %s"pr,msg)
    
replace_all(msg190"!g""^4"// Green Color
    
replace_all(msg190"!y""^1"// Default Color
    
replace_all(msg190"!team""^3"// Team Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch")
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i])
                
write_byte(players[i]);
                
write_string(msg); 
                
message_end();
            }
        }
    }
}

stock GetNumEntity(const class[])
{
    new 
iEntiNum
    
while((iEnt find_ent_by_class(iEnt, class)))
        
iNum++
    
    return 
iNum

That gives me this error.
PHP Code:
L 02/01/2014 00:52:12: [AMXXDisplaying debug trace (plugin "checkpoint.amxx")
L 02/01/2014 00:52:12: [AMXXRun time error 4index out of bounds 
L 02
/01/2014 00:52:12: [AMXX]    [0CheckPoint.sma::TouchTargetFinish (line 171
How can i add milliseconds to the finish text (line 177)?
Also how to save this in .ini or vault? And how to show it top15,10 of the map? Like fast runner of the map
__________________
Rest in piece.

Last edited by myusername; 01-31-2014 at 15:25.
myusername 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 23:47.


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