AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Zombie Plague Mod (https://forums.alliedmods.net/forumdisplay.php?f=126)
-   -   [Tutorial] Eighth lesson in a series develop [ZPA 1.61] - Unstuck Feature. (https://forums.alliedmods.net/showthread.php?t=275849)

arvEL. 12-09-2015 15:33

[Tutorial] Eighth lesson in a series develop [ZPA 1.61] - Unstuck Feature.
 
Eighth Lesson Add (Unstuck Feature)
- all rights reserved to arvEL.-, in : 9/12/2015
In these lesson i will explain how to develop [Zombie Plague Advance v1.6.1]
re programming unstuck feature.

first go to this topic [ # ] and download
[ZPA 1.6.1]
after that open the file [zombie_plague_advance_v1-6-1.sma] in [notepad++]

first add this variables

PHP Code:

// Unstuck
new on_stuck[33]
new const 
Float:sizez[][3] = {
    {
0.00.01.0}, {0.00.0, -1.0}, {0.01.00.0}, {0.0, -1.00.0}, {1.00.00.0}, {-1.00.00.0}, {-1.01.01.0}, {1.01.01.0}, {1.0, -1.01.0}, {1.01.0, -1.0}, {-1.0, -1.01.0}, {1.0, -1.0, -1.0}, {-1.01.0, -1.0}, {-1.0, -1.0, -1.0},
    {
0.00.02.0}, {0.00.0, -2.0}, {0.02.00.0}, {0.0, -2.00.0}, {2.00.00.0}, {-2.00.00.0}, {-2.02.02.0}, {2.02.02.0}, {2.0, -2.02.0}, {2.02.0, -2.0}, {-2.0, -2.02.0}, {2.0, -2.0, -2.0}, {-2.02.0, -2.0}, {-2.0, -2.0, -2.0},
    {
0.00.03.0}, {0.00.0, -3.0}, {0.03.00.0}, {0.0, -3.00.0}, {3.00.00.0}, {-3.00.00.0}, {-3.03.03.0}, {3.03.03.0}, {3.0, -3.03.0}, {3.03.0, -3.0}, {-3.0, -3.03.0}, {3.0, -3.0, -3.0}, {-3.03.0, -3.0}, {-3.0, -3.0, -3.0},
    {
0.00.04.0}, {0.00.0, -4.0}, {0.04.00.0}, {0.0, -4.00.0}, {4.00.00.0}, {-4.00.00.0}, {-4.04.04.0}, {4.04.04.0}, {4.0, -4.04.0}, {4.04.0, -4.0}, {-4.0, -4.04.0}, {4.0, -4.0, -4.0}, {-4.04.0, -4.0}, {-4.0, -4.0, -4.0},
    {
0.00.05.0}, {0.00.0, -5.0}, {0.05.00.0}, {0.0, -5.00.0}, {5.00.00.0}, {-5.00.00.0}, {-5.05.05.0}, {5.05.05.0}, {5.0, -5.05.0}, {5.05.0, -5.0}, {-5.0, -5.05.0}, {5.0, -5.0, -5.0}, {-5.05.0, -5.0}, {-5.0, -5.0, -5.0}



now press [Ctrl + F] and find this line:

PHP Code:

case 3// Unstuck 


it's have this codes:

PHP Code:

        case 3// Unstuck
        
{
            
// Check if player is stuck
            
if (g_isalive[id])
            {
                if (
is_player_stuck(id))
                {
                    
// Move to an initial spawn
                    
if (get_pcvar_num(cvar_randspawn))
                        
do_random_spawn(id// random spawn (including CSDM)
                    
else
                        
do_random_spawn(id1// regular spawn
                
}
                else
                    
zp_colored_print(id"^x04[ZP]^x01 %L"id"CMD_NOT_STUCK")
            }
            else
                
zp_colored_print(id"^x04[ZP]^x01 %L"id"CMD_NOT")
        } 

replace all codes to:

PHP Code:

    case 3// Unstuck
{
        
    
// Check if player is stuck
    
if (g_isalive[id])
    {
    if (
is_player_stuck(id))
    {
    
client_print_color(idGrey"^x04[ZP]^x01 You have been unstucked!")
    static 
players[32], pnum Float:origin[3], Float:mins[3], hullFloat:vec[3], i
    get_players
(playerspnum)
 
    for(
i=0i<pnumi++){
    
id players[i]
    if (
is_user_connected(id) && is_user_alive(id)) {
    
pev(idpev_originorigin)
    
hull pev(idpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMAN
    
if (!unstuck_is_hull_vacant(originhull,id) && !get_user_noclip(id) && !(pev(id,pev_solid) & SOLID_NOT))
    {
    ++
on_stuck[id]
    if(
on_stuck[id] >= 1) {
    
pev(idpev_minsmins)
    
vec[2] = origin[2]
    for (
o=0sizeof sizez; ++o) {
    
vec[0] = origin[0] - mins[0] * sizez[o][0]
    
vec[1] = origin[1] - mins[1] * sizez[o][1]
    
vec[2] = origin[2] - mins[2] * sizez[o][2]
    if (
unstuck_is_hull_vacant(vechull,id))
    {
    
engfunc(EngFunc_SetOriginidvec)
    
message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id);
    
write_short(1<<10);
    
write_short(1<<10);
    
write_short(1<<12);
    
write_byte(220);
    
write_byte(193);
    
write_byte(9);
    
write_byte(70);
    
message_end();
    
client_cmd(id,"spk fvox/blip.wav")    
    
set_pev(id,pev_velocity,{0.0,0.0,0.0})
    
sizeof sizez
    
}
    }
    }
    }
    else
    {
    
on_stuck[id] = 0
    
}
    }
    }
    }
    else
    
client_print_color(idGrey"^x04[ZP]^x01 You are not stuck...")
    }
    else
    
client_print_color(idGrey"^x04[ZP]^x01 Unavailable command.")



how add this codes in any place inside ZPA.sma main.

PHP Code:

// Stock unstuck
stock bool:unstuck_is_hull_vacant(const Float:origin[3], hull,id) {
    static 
tr
    engfunc
(EngFunc_TraceHulloriginorigin0hullidtr)
    if (!
get_tr2(trTR_StartSolid) || !get_tr2(trTR_AllSolid)) //get_tr2(tr, TR_InOpen))
        
return true
    
    
return false


now make compile and ejnoy :)
all rights reserved to arvEL.-


amir saiaoud 02-03-2016 22:07

Re: [Tutorial] Eighth lesson in a series develop [ZPA 1.61] - Unstuck Feature.
 
GJ thanks bro ^^ :*


All times are GMT -4. The time now is 23:16.

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