Raised This Month: $51 Target: $400
 12% 

[Help] Add glow on player when I grab him


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
z4rk
Member
Join Date: Aug 2019
Old 10-15-2021 , 03:26   [Help] Add glow on player when I grab him
Reply With Quote #1

Hi guys. I would like to have a modification for a "grab plugin". Here is the source code:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
 
#define KZ_LEVEL ADMIN_KICK        // Adminlevel
#define MIN_DIST 70.0
#define THROW_POWER 1500
 
new grab[32]
new 
Float:grabdistance[32]
new 
bool:grabsearch[32]
new 
g_short
 
enum color 
{normal 1greenteam}
 
public 
plugin_init() {
    
register_plugin("ProKreedzGrab","1.0","p4ddY")
 
    
register_clcmd("+grab","grab_on",KZ_LEVEL)
    
register_clcmd("-grab","grab_off",KZ_LEVEL)
 
    
register_event("DeathMsg","deathmsg","a")
    
register_event("ResetHUD","resethud","be")
}
 
public 
plugin_precache()
{
    
precache_sound("weapons/xbow_fire1.wav")
    
g_short precache_model("sprites/MG_grab/energy_grab.spr");
}
 
// =================================================================================================
 
public grab_on(id,level,cid) {
    if(!
cmd_access(id,level,cid,1)) 
        return 
PLUGIN_HANDLED
 
    grabsearch
[id-1] = true
 
    
return PLUGIN_HANDLED
}
 
public 
grab_off(id,level,cid) {
    if(!
cmd_access(id,level,cid,1)) 
        return 
PLUGIN_HANDLED
 
    grabsearch
[id-1] = false
    grab
[id-1] = 0
 
    
return PLUGIN_HANDLED
}
 
// =================================================================================================
 
public grab_player(id,target) {
    
grab[id-1] = target
    grabsearch
[id-1] = false
    
new Float:origin1[3], Float:origin2[3]
    
entity_get_vector(id,EV_VEC_origin,origin1)
    
entity_get_vector(target,EV_VEC_origin,origin2)
    
grabdistance[id-1] = get_distance_f(origin1,origin2)
 
    
set_user_rendering(targetkRenderFxGlowShellrandom(256), random(256), random(256), kRenderNormal43);
 
    new 
namep[32], namea[32]
    
get_user_name(targetnamepcharsmax(namep))
    
get_user_name(idnameacharsmax(namea))
    
ColorChat(id"!nYou grabbed !tPlayer !n: !g%s!n."namep)
    
ColorChat(target"!tAdmin !g%s !n: !ngrabbed you."namea)
    
emit_sound(idCHAN_VOICE"weapons/xbow_fire1.wav"1.0ATTN_NORM0PITCH_NORM)
    
grab_eff(target)
 
    if(
callfunc_begin("detect_cheat","prokreedz.amxx") == 1) {
        
callfunc_push_int(target)
        
callfunc_push_str("Grab")
        
callfunc_end()
    }
}
 
// =================================================================================================
 
public is_user_grabbed(id) {
    for(new 
i=0;i<32;i++) {
        if(
grab[i] == id)
            return (
i+1)
    }
 
    return -
1
}
 
// =================================================================================================
 
public client_PreThink(id) {
    new 
buttons entity_get_int(id,EV_INT_button)
 
    if(
grabsearch[id-1] == true) {
        new 
aimidaimbody
        
if(get_user_aiming(id,aimid,aimbody) != 0.0 && aimid != 0) {
            new 
targetclass[16]
            
entity_get_string(aimid,EV_SZ_classname,targetclass,16)
            if(
equal(targetclass,"player")) {
                if(
is_user_grabbed(aimid) == -1)
                    
grab_player(id,aimid)
                else {
                    
client_print(id,print_chat,"[ProKreedz] Dieser Spieler ist schon grabbed")
                    
grabsearch[id-1] = false
                
}
            }
        }
    }
 
    if(
grab[id-1] > 0) { // Took this from JediGrap by KCE
        
new Float:origin1[3], Float:origin2[3], ilook[3], Float:look[3], Float:direction[3], Float:moveto[3], Float:grabbedorigin[3], Float:velocity[3], Float:length
        get_user_origin
(id,ilook,3)
        
IVecFVec(ilook,look)
        
entity_get_vector(grab[id-1],EV_VEC_origin,grabbedorigin)
 
        
entity_get_vector(id,EV_VEC_origin,origin1)
        
entity_get_vector(grab[id-1],EV_VEC_origin,origin2)
 
        
direction[0] = look[0] - origin1[0]
        
direction[1] = look[1] - origin1[1]
        
direction[2] = look[2] - origin1[2]
        
length get_distance_f(look,origin1)
        if(!
length)
            
length 1.0 // avoid division by 0
 
        
moveto[0] = origin1[0] + direction[0] * grabdistance[id-1] / length
        moveto
[1] = origin1[1] + direction[1] * grabdistance[id-1] / length
        moveto
[2] = origin1[2] + direction[2] * grabdistance[id-1] / length
 
        velocity
[0] = (moveto[0] - origin2[0]) * 8
        velocity
[1] = (moveto[1] - origin2[1]) * 8
        velocity
[2] = (moveto[2] - origin2[2]) * 8
 
        entity_set_vector
(grab[id-1],EV_VEC_velocity,velocity)
 
        
// Push and Pull
        
if(buttons&IN_ATTACK) {
            
entity_set_int(id,EV_INT_button,buttons&~IN_ATTACK)
            
grabdistance[id-1] += 7
        
}
        else if(
buttons&IN_ATTACK2) {
            
entity_set_int(id,EV_INT_button,buttons&~IN_ATTACK2)
            
grabdistance[id-1] -= 7
            
if(grabdistance[id-1] < MIN_DIST)
                
grabdistance[id-1] = MIN_DIST
        
}
        else if(
buttons&IN_JUMP) {
            
entity_set_int(id,EV_INT_button,buttons&~IN_JUMP)
 
            
VelocityByAim(id,THROW_POWER,velocity)
            
entity_set_vector(grab[id-1],EV_VEC_velocity,velocity)
 
            
grab[id-1] = 0
        
}
    }
 
    if(
is_user_grabbed(id) != -1)
        
entity_set_int(id,EV_INT_button,buttons&~IN_MOVELEFT&~IN_MOVERIGHT&~IN_FORWARD&~IN_BACK&~IN_JUMP// Stop sucking :o
}
 
// =================================================================================================
 
public deathmsg() {
    new 
attacker read_data(1// attacker
    
new victim read_data(2)
    
grab[attacker-1] = 0
    grabsearch
[attacker-1] = false
 
    
new pid is_user_grabbed(victim)
    if(
pid != -1)
        
grab[pid-1] = 0
}
 
public 
resethud(id) {
    new 
pid is_user_grabbed(id)
    if(
pid != -1) {
        
grab[pid-1] = 0
    
}
 
    
grab[id-1] = 0
    grabsearch
[id-1] = false
}
 
// =================================================================================================
 
public client_disconnect(id) {
    
grabsearch[id-1] = false
    grab
[id-1] = 0
}
 
public 
client_putinserver(id) {
    
grabsearch[id-1] = false
    grab
[id-1] = 0
}
 
stock ColorChat(idString[], any:...) 
{
    static 
szMesage[192];
    
vformat(szMesagecharsmax(szMesage), String3);
 
    
replace_all(szMesagecharsmax(szMesage), "!n""^1");
    
replace_all(szMesagecharsmax(szMesage), "!t""^3");
    
replace_all(szMesagecharsmax(szMesage), "!g""^4");
 
    static 
g_msg_SayText 0;
    if(!
g_msg_SayText)
        
g_msg_SayText get_user_msgid("SayText");
 
    new 
Players[32], iNum 1i;
 
     if(
idPlayers[0] = id;
    else 
get_players(PlayersiNum"ch");
 
    for(--
iNumiNum >= 0iNum--) 
    {
        
Players[iNum];
 
        
message_begin(MSG_ONE_UNRELIABLEg_msg_SayText_i);
        
write_byte(i);
        
write_string(szMesage);
        
message_end();
    }
}
 
public 
grab_eff(target)
{
    new 
origin[3]
 
    
get_user_origin(target,origin)
 
    
message_begin(MSG_ALL,SVC_TEMPENTITY,{0,0,0},target)
    
write_byte(TE_SPRITETRAIL//Sprite capture
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2]+20)
    
write_coord(origin[0])
    
write_coord(origin[1])
    
write_coord(origin[2]+80)
    
write_short(g_short)
    
write_byte(20)
    
write_byte(20)
    
write_byte(4)
    
write_byte(20)
    
write_byte(10)
    
message_end()
}
// You reached the end of file
// This plugin was made by p4ddY :)
// Credits to KCE 

What I need:
- The player's glow is permanently active. I need it to be active only when I grab a player. After that, I would like the glow to become inactive.
- I also need random colors for player's glow.

Last edited by z4rk; 10-15-2021 at 06:02.
z4rk is offline
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 14:05.


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