View Single Post
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 05-19-2023 , 17:36   Re: new error message
Reply With Quote #5

Upload the code
so the code based on some function
!teleport name value[origin]
!teleport name toTarget
!teleport @all toTarget
!teleport self self - need block it or pass origin
need block check and more

PHP Code:
/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define    PREFIX            "^4[Cmd]^1"
#define START_DISTANCE  32
#define MAX_ATTEMPTS    128
#define GetPlayerHullSize(%1)  ((pev(%1, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN)

enum _:ALIVE_MODE
{
    
ALL,
    
ALIVE_ONLY,
    
DEAD_ONLY,
};

enum _:CMD_STRUCT
{
    
CMD_NAME    [32],
    
CMD_INCHAT    [32],
    
CMD_SRV        [32],
    
CMD_USAGE    [128],
    
CMD_LEVEL,
};

enum _:Commands
{
    
TELEPORT
}

new const 
CommandsList[Commands][CMD_STRUCT] = 
{

    {
"Teleport",    "teleport",    """<^3From:@all/@t/@ct/@admin/target^1> <^3To:target/origin:X Y Z^1>",    ADMIN_KICK},    // !teleport     - flag c (VIP+)
}

new const 
HigherLevel[] =
{   
// low to high
    
ADMIN_KICK,         // VIP
    
ADMIN_BAN,          // Admin
    
ADMIN_LEVEL_C,      // SuperAdmin
    
ADMIN_RESERVATION,  // Manager
    
ADMIN_IMMUNITY,     // Owner
};

new 
gCmdPointer[Commands];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd("say""HandleSay");
    
register_clcmd("say_team""HandleSay");

    for (new 
0Commandsi++)
    {
        if (
strlen(CommandsList[i][CMD_SRV]) > 0)
        
gCmdPointer[i] = get_cvar_pointer(CommandsList[i][CMD_SRV]);
    }
}

// Say Command Handler.
public HandleSay(client)
{
    new 
said[32];
    new 
param[32];
    new 
szMessage[charsmax(said) + charsmax(param) + 2];
   
    
read_argv(1szMessagecharsmax(szMessage));
    
argbreak(szMessagesaidcharsmax(param), paramcharsmax(param));
 
    for (new 
0Commandsi++)
    {
        if (
equali(said[1], CommandsList[i][CMD_INCHAT]))
        {
            if (!(
get_user_flags(client) & CommandsList[i][CMD_LEVEL]))
            {
                
client_print_color(clientprint_team_default"%s ^3Error^1: You don't have Access Level."PREFIX);
                break;
            }
            
CommandSelector(iclientparam); // // Pass the command / don't need to modify the loop itself.
            
return PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_CONTINUE;
}

// Say Command Handler (Selector).
CommandSelector(cmdclientparam[])
{
    switch(
cmd)
    {
        case 
TELEPORT:    CmdTeleport    (clientparam);
    }
}

// Check Higher Admin (id < target).
bool:IsHigherAdmin(idtarget)
{
    
// my flags
    
new mFlags get_user_flags(id);
    
// target flags
    
new tFlags get_user_flags(target);
 
    new 
mLevel 1;
    new 
tLevel 1;
 
    for (new 
0sizeof(HigherLevel); i++)
    {
        if (
mFlags HigherLevel[i])
        
mLevel *= 10;
       
        if (
tFlags HigherLevel[i])
        
tLevel *= 10;
    }
 
    if (
tLevel mLevel)
    {
        return 
true;
    }
   
    return 
false;
}

/*
    Get Player Index for one target.
 */
bool:GetSingleTargetPlayer(clienttarget[], &playerCheckHigherAdminIsAlive)
{
    
trim(target);

    
player GetTargetPlayer(target);
   
    if (!
player)
    {
        
client_print_color(clientprint_team_default"%s ^3Error^1: You must write a valid player."PREFIX);
        return 
false;
    }

    if (
CheckHigherAdmin)
        if (
IsHigherAdmin(clientplayer))
        {
            
player 0;
            
client_print_color(clientprint_team_default"%s ^3Error:^1 You can not use this command on high admin"PREFIXplayer);
            return 
false;
        }

    switch(
IsAlive)
    {
        case 
ALIVE_ONLY:
            if (!
is_user_alive(player))
            {
                
player 0;
                
client_print_color(clientprint_team_default"%s ^3Error^1: This action could not perform on^4 alive client^1."PREFIX);
                return 
false;
            }
        case 
DEAD_ONLY:
            if (
is_user_alive(player))
            {
                
player 0;
                
client_print_color(clientprint_team_default"%s ^3Error^1: This action could not perform on^4 dead client^1."PREFIX);
                return 
false;
            }
    }

    return 
true;
}
GetTargetPlayer(target[])
{
    
trim(target);

    new 
player find_player("al"target);
    if (!
player)
    {
        
player find_player("bl"target);
        if (
player)
        {
            if (
player == find_player("bjl"target))
            {
                return 
player;
            }
        }
        return 
0;
    }
    return 
player;
}
// Check Parameter None.
bool:CheckUsage(clientcmdparam[])
{
    if (!
param[0])
    {
        
client_print_color(clientprint_team_default"%s Usage: '^4!%s ^1%s'"PREFIXCommandsList[cmd][CMD_NAME], CommandsList[cmd][CMD_USAGE]);
        return 
false;        
    }
    return 
true;
}

// Command: Teleport.
CmdTeleport(clientparam[])
{
    
// check param[] is none.
    
if (!CheckUsage(clientTELEPORTparam))
        return;
        
    
// Split parameter.
    
new fromTarget[32], toTarget[32];
    
argbreak(paramfromTargetcharsmax(fromTarget), toTargetcharsmax(toTarget));

    new 
players[32];
    new 
fPlayer;
    new 
tPlayer;
    new 
pnum 0;
    new 
Float:origin[3], Float:vAngle[3];
    new 
cOriginX[5],cOriginY[5],cOriginZ[5];
    if (
parse(toTargetcOriginXcharsmax(cOriginX), cOriginYcharsmax(cOriginY), cOriginZcharsmax(cOriginZ)) == 3)
    {
        
origin[0] = str_to_float(cOriginX);
        
origin[1] = str_to_float(cOriginY);
        
origin[2] = str_to_float(cOriginZ);
    } else
    {
        
// Get <To:target> player
        
if (GetSingleTargetPlayer(clienttoTargettPlayerfalseALIVE_ONLY))
        {
            
// Get <To:target> player location
            
GetTeleportLocation(tPlayeroriginvAngle);
        }
        
/*else
        {
            client_print_color(client, print_team_default, "%s Error: Missing or invalid destination target.", PREFIX);
            return;
        }*/
    
}

    
// Get <from:@xxx> player
    
if (GetMultiTargetPlayers(clientfromTargetplayerspnumtrueALIVE_ONLY))
    {
        
// Teleporting <from:@xxx>
        
for(new 0pnumi++)
        {
            if (
is_user_alive(players[i]))
                
doTeleport(players[i], originvAngle);
        }

        
// Print
        
if (pnum)
            
PrintTeleport(0fromTargettPlayerorigin);

        
// End
        
return;
    }

    
// Get <from:target> player
    
if (GetSingleTargetPlayer(clientfromTargetfPlayertrueALIVE_ONLY))
    {
        
// Teleporting <from:target> player
        
if (is_user_alive(fPlayer))
        {
            
doTeleport(fPlayeroriginvAngle);
            
// Print
            
PrintTeleport(0fromTargettPlayerorigin);
        }
        
// End
        
return;
    }
}

//    Get Teleport Location.
GetTeleportLocation(idFloat:origin[3], Float:vAngle[3])
{
    
pev(idpev_originorigin);
    
pev(idpev_v_anglevAngle);
}

//    Teleporting.
doTeleport(id, const Float:origin[3], const Float:vAngle[3])
{
    new 
Float:toVector[3];

    
// Check Stuck.
    
FindEmptyLocation(origintoVector100.0);

    
// Teleport.
    
engfunc(EngFunc_SetOriginidtoVector);
    
set_pev(idpev_v_anglevAngle);
    
set_pev(idpev_fixangle1);

    
UTIL_UnstickPlayer(idSTART_DISTANCEMAX_ATTEMPTS);
}
/*
    Teleport Location.
    Check Stuck Logic.
    Get the coordinates without obstacles within the range from the target coordinates.
 */
FindEmptyLocation(const Float:from[3], Float:Origin[3], Float:Radius)
{
    
Origin from;
    
    while (
PointContents(Origin) != CONTENTS_EMPTY && PointContents(Origin) != CONTENTS_SKY)
    {
        for(new 
Count;Count 2;Count++)
            
Origin[Count] = from[Count] + random_float(-Radius,Radius);
    }
}
UTIL_UnstickPlayer(const id, const i_StartDistance,const i_MaxAttempts)
{
    
// --| Not alive, ignore.
    
if (!is_user_alive(id))
        return -
1;
 
    static 
Float:vf_OriginalOrigin[3], Float:vf_NewOrigin[3];
    static 
i_Attemptsi_Distance;
 
    
// --| Get the current player's origin.
    
pev idpev_originvf_OriginalOrigin );
 
    
i_Distance i_StartDistance;
 
    while ( 
i_Distance 1000 )
    {
        
i_Attempts i_MaxAttempts;
 
        while (
i_Attempts--)
        {
            for(new 
03i++)
                
vf_NewOrigin[i] = random_float(vf_OriginalOrigin[i] - i_Distancevf_OriginalOrigin[i] + i_Distance);
 
            
engfunc(EngFunc_TraceHullvf_NewOriginvf_NewOriginDONT_IGNORE_MONSTERSGetPlayerHullSize(id), id0);
 
            
// --| Free space found.
            
if (get_tr2(0TR_InOpen) && !get_tr2(0TR_AllSolid) && !get_tr2(0TR_StartSolid))
            {
                
// --| Set the new origin .
                
engfunc EngFunc_SetOriginidvf_NewOrigin );
                return 
1;
            }
        }
        
i_Distance += i_StartDistance;
    }
    
// --| Could not be found.
    
return 0;
}

PrintTeleport(idtarget[], positionFloat:origin[3])
{
    
trim(target);
    if (
target[0] == '@')
    {
        if (
is_user_connected(position))
        {
            if (
equali(target"@all"))
                
client_print_color(idprint_team_default"%s ^3everyone ^1has teleport to ^3%n. ^1(Origin:%.2f, %.2f, %.2f)",        PREFIXpositionorigin[0], origin[1], origin[2]);
            else if(
equali(target"@admin"))
                
client_print_color(idprint_team_default"%s ^3Admins ^1has teleport to ^3%n. ^1(Origin:%.2f, %.2f, %.2f)",         PREFIXpositionorigin[0], origin[1], origin[2]);
            else if(
equali(target"@ct"))
                
client_print_color(idprint_team_default"%s ^3CT Team ^1has teleport to ^3%n. ^1(Origin:%.2f, %.2f, %.2f)",         PREFIXpositionorigin[0], origin[1], origin[2]);
            else if(
equali(target"@t"))
                
client_print_color(idprint_team_default"%s ^3Terrorist Team ^1has teleport to ^3%n. ^1(Origin:%.2f, %.2f, %.2f)",PREFIXpositionorigin[0], origin[1], origin[2]);
            else
            {
                new 
player GetTargetPlayer(target);
                
client_print_color(idprint_team_default"%s ^3%n ^1has teleport to ^3%n. ^1(Origin:%.2f, %.2f, %.2f)",             PREFIXplayerpositionorigin[0], origin[1], origin[2]);
            }
        }
        else
        {
            if (
equali(target"@all"))
                
client_print_color(idprint_team_default"%s ^3everyone ^1has teleported to ^3Origin.(%.2f, %.2f, %.2f)",        PREFIXorigin[0], origin[1], origin[2]);
            else if(
equali(target"@admin"))
                
client_print_color(idprint_team_default"%s ^3Admins ^1has teleported to ^3Origin.(%.2f, %.2f, %.2f)",         PREFIXorigin[0], origin[1], origin[2]);
            else if(
equali(target"@ct"))
                
client_print_color(idprint_team_default"%s ^3CT Team ^1has teleported to ^3Origin.(%.2f, %.2f, %.2f)",         PREFIXorigin[0], origin[1], origin[2]);
            else if(
equali(target"@t"))
                
client_print_color(idprint_team_default"%s ^3Terrorist Team ^1has teleported to ^3Origin.(%.2f, %.2f, %.2f)",PREFIXorigin[0], origin[1], origin[2]);
            else
            {
                new 
player GetTargetPlayer(target);
                
client_print_color(idprint_team_default"%s ^3%n ^1has teleported to ^3Origin.(%.2f, %.2f, %.2f)",             PREFIXplayerorigin[0], origin[1], origin[2]);
            }
        }
        return;
    }
    else
    {
        if (
is_user_connected(position))
        {
            new 
player GetTargetPlayer(target);
            
client_print_color(idprint_team_default"%s ^3%n ^1has teleport to ^3%n. ^1(Origin:%.2f, %.2f, %.2f)",                     PREFIXplayerorigin[0], origin[1], origin[2]);
        }        
        else
        {
            new 
player GetTargetPlayer(target);
            
client_print_color(idprint_team_default"%s ^3%n ^1has teleported to ^3Origin.(%.2f, %.2f, %.2f)",                     PREFIXplayerorigin[0], origin[1], origin[2]);
        }        
    }
    return;
}
bool:GetMultiTargetPlayers(clienttarget[], players[32], &pnumCheckHigherAdminIsAlive ALL)
{
    new 
tmpPlayers[32];
    new 
tmpNum 0;
    new 
isAdmin  false;
    new 
isTarget true;
    
pnum 0;

    
trim(target);
    if (
target[0] == '@')
    {
        
// @all
        
if (equali(target"@all"))
        {
            
get_players(tmpPlayerstmpNum"h");
        }
        else
        
// @admin
        
if (equali(target"@admin"))
        {
            
get_players(tmpPlayerstmpNum"h");
            
isAdmin true;
        }
        else
        
// @ct
        
if (equali(target"@ct"))
        {
            
get_players(tmpPlayerstmpNum"eh""CT");
        }
        else
        
// @t
        
if (equali(target"@t"))
        {
            
get_players(tmpPlayerstmpNum"eh""T");
        }

        for (new 
0tmpNumi++)
        {
            
isTarget true;
            if (
CheckHigherAdmin)
                if (
IsHigherAdmin(clienttmpPlayers[i]))
                    continue;

            if (
isAdmin)
            {
                
isTarget false;
                
// Higher Admin Loops.
                
for (new 0sizeof(HigherLevel); n++)
                {
                    
// Is Higher Admin?
                    
if (get_user_flags(tmpPlayers[i]) & HigherLevel[n])
                    {
                        
isTarget true;
                        break;
                    }
                }
            }

            if (
isTarget)
            {
                switch(
IsAlive)
                {
                    case 
ALL:
                    {
                        
players[pnum++] = tmpPlayers[i];
                    }
                    case 
ALIVE_ONLY:
                    {
                        if (
is_user_alive(tmpPlayers[i]))
                            
players[pnum++] = tmpPlayers[i];
                    }
                    case 
DEAD_ONLY:
                    {
                        if (!
is_user_alive(tmpPlayers[i]))
                            
players[pnum++] = tmpPlayers[i];
                    }
                }
            }
        }
        if (
tmpNum <= 0)
        {
            
client_print_color(clientprint_team_default"%s ^3Error^1: Not Found Players."PREFIX);
            return 
true;
        }
    }
    return (
pnum 0);

Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun