Raised This Month: $ Target: $400
 0% 

Specific player can touch only specific entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bladell
Senior Member
Join Date: Jun 2012
Old 06-19-2014 , 05:21   Specific player can touch only specific entity
Reply With Quote #1

I have this plugin
PHP Code:
/*
Name: [ZP] Addon: Bonus Box
Author: PomanoB & STRELOK
Version 1.0

Based on [ZP] DM Item's by PomanoB
*/
#include <superheromod>
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN "[ZP] Addon: Bonus Box"
#define VERSION "1.0"
#define AUTHOR "PomanoB & Accelerator"

new const item_class_name[] = "dm_item"

new g_models[][] = {"models/shero/presents.mdl"}

public 
plugin_precache()
{
    for (new 
0sizeof g_modelsi++)
        
precache_model(g_models[i])    
}


public 
round_start()
{
    new 
ent FM_NULLENT
    
static string_class[] = "classname"
    
while ((ent engfunc(EngFunc_FindEntityByStringentstring_classitem_class_name))) 
        
set_pev(entpev_flagsFL_KILLME)
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_forward(FM_Touch"fwd_Touch")
    
    
register_event("HLTV""round_start""a""1=0""2=0")
    
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
    
    
register_dictionary("bonus_box.txt")
}

public 
show_hud()
{
    new 
Player[32], playerCount
    
    get_players
(PlayerplayerCount"c")
    
    
set_hudmessage(225000.990.15clamp(102), 6.01800.06.06.0, -1)
    
    for(new 
id=1id <= playerCountid++)
    {
        if(!
is_user_alive(Player[id]))
            
ShowSyncHudMsg(Player[id], CreateHudSyncObj(), "Bonus boxes event!")
    }
}

public 
fwd_Touch(touchertouched)
{
    if (!
is_user_alive(toucher) || !pev_valid(touched))
        return 
FMRES_IGNORED
    
    
new classname[32]    
    
pev(touchedpev_classnameclassname31)
    if (!
equal(classnameitem_class_name))
        return 
FMRES_IGNORED
    
    
    
    shgive_item
(toucher)
    
set_pev(touchedpev_effectsEF_NODRAW)
    
set_pev(touchedpev_solidSOLID_NOT)
    
    return 
FMRES_IGNORED
    
}

public 
fw_PlayerKilled(victimattackershouldgib)
{
    if (!
is_user_connected(attacker) || !is_user_connected(victim) || attacker == victim || !attacker)
        return 
HAM_IGNORED
    
    
    
new random random_num(09)
    
    new 
hour[3]
    
    
get_time("%H"hour2)
    
    if(
str_to_num(hour) == 20)
    {
        if (
random <= 5)
        {
            new 
origin[3]
            
get_user_origin(victimorigin0)
            
            
addItem(origin)
            
            if(!
task_exists(2212))
                
set_task(1.0"show_hud"2212__"b")
        }
    }
    else if(
random == 5)
    {
        new 
origin[3]
        
get_user_origin(victimorigin0)
        
        
addItem(origin)
        
        if(
task_exists(2212))
            
remove_task(2212)
    }
        
    return 
HAM_IGNORED
}

public 
removeEntity(ent)
{
    if (
pev_valid(ent))
        
engfunc(EngFunc_RemoveEntityent)
}

public 
addItem(origin[3])
{
    new 
ent fm_create_entity("info_target")
    
set_pev(entpev_classnameitem_class_name)
    
    
engfunc(EngFunc_SetModel,entg_models[random_num(0sizeof g_models 1)])

    
set_pev(ent,pev_mins,Float:{-10.0,-10.0,0.0})
    
set_pev(ent,pev_maxs,Float:{10.0,10.0,25.0})
    
set_pev(ent,pev_size,Float:{-10.0,-10.0,0.0,10.0,10.0,25.0})
    
engfunc(EngFunc_SetSize,ent,Float:{-10.0,-10.0,0.0},Float:{10.0,10.0,25.0})

    
set_pev(ent,pev_solid,SOLID_BBOX)
    
set_pev(ent,pev_movetype,MOVETYPE_FLY)
    
    new 
Float:fOrigin[3]
    
IVecFVec(originfOrigin)
    
set_pev(entpev_originfOrigin)
    
    
set_pev(ent,pev_renderfx,kRenderFxGlowShell)
    switch(
random_num(1,4))
    {
        case 
1set_pev(ent,pev_rendercolor,Float:{0.0,0.0,255.0})
        case 
2set_pev(ent,pev_rendercolor,Float:{0.0,255.0,0.0})
        case 
3set_pev(ent,pev_rendercolor,Float:{255.0,0.0,0.0})
        case 
4set_pev(ent,pev_rendercolor,Float:{255.0,255.0,255.0})
    }

When somebody dies a box is let behind and if someone touch it will receive something. It want to change this plugin... only the player who killed the victim can touch the box left by victim and receive the bonus, or at least the toucher id team != victim id team

I know that function shgive_item is missing, there is nothing that I could change to make this plugin as I want.
Bladell is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 06-19-2014 , 06:47   Re: Specific player can touch only specific entity
Reply With Quote #2

Set pev_owner to the user that should be able to pick it up and then compare pev_owner in the touch forward. Also why do you set EF_NODRAW and SOLID_NOT and only delete the entities on new round? You should delete them immediately.

/edit: SpeeDeeR is correct. You would probably want to use pev_iuser.
__________________
In Flames we trust!

Last edited by Nextra; 06-19-2014 at 09:18.
Nextra is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 06-19-2014 , 08:30   Re: Specific player can touch only specific entity
Reply With Quote #3

Setting pev_owner will make the box not interactable with the owner. You could use groupinfo or if you want all players to see the box, set the killers index in a costume pev, like iuser, and check it on touch.

Last edited by SpeeDeeR; 06-22-2014 at 10:42.
SpeeDeeR is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 06-22-2014 , 10:40   Re: Specific player can touch only specific entity
Reply With Quote #4

Quote:
Originally Posted by SpeeDeeR View Post
Setting pev_owner will make the box not interactable with the owner. You could use groupinfo or if you want all players to see the box, set the killers index in a costume pev, like iuser, and check it on touch.

Last edited by SpeeDeeR; 06-22-2014 at 10:42.
SpeeDeeR is offline
Bladell
Senior Member
Join Date: Jun 2012
Old 06-22-2014 , 12:24   Re: Specific player can touch only specific entity
Reply With Quote #5

Thank you!
Bladell is offline
Bladell
Senior Member
Join Date: Jun 2012
Old 06-19-2014 , 09:39   Re: Specific player can touch only specific entity
Reply With Quote #6

@Nextra This plugin isn't made by me... box disappear automatically when somebody touch it.
@SpeeDeeR I have no ideea about what are you talking about, and example would be great.
Bladell is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 06-19-2014 , 15:00   Re: Specific player can touch only specific entity
Reply With Quote #7

Quote:
Originally Posted by Bladell View Post
@Nextra This plugin isn't made by me... box disappear automatically when somebody touch it.
@SpeeDeeR I have no ideea about what are you talking about, and example would be great.
post in the plugin's topic or in the request forum
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
Compidence
Junior Member
Join Date: Feb 2014
Old 06-22-2014 , 12:30   Re: Specific player can touch only specific entity
Reply With Quote #8

Quote:
Originally Posted by Bladell View Post
@Nextra This plugin isn't made by me... box disappear automatically when somebody touch it.
@SpeeDeeR I have no ideea about what are you talking about, and example would be great.
What SpeeDeeR is saying is use pev_iuser1, like you would use pev_owner to store the owner of the entity. Or in your case, use it to store the id of the killer. Then on touch [when someone touches the entity] check if the id = pev_iuser1, if it does then you got your guy.

set_pev(ent, pev_iuser1, id);
if(pev(ent, pev_iuser1) == id);
Compidence is offline
Old 06-20-2014, 04:20
Bladell
This message has been deleted by Bladell.
Bladell
Senior Member
Join Date: Jun 2012
Old 06-22-2014 , 08:40   Re: Specific player can touch only specific entity
Reply With Quote #10

That topic is dead, I can modify it...
I tried with pev_owner, but as far as I know, the entity will be automatically set set_pev(touched, pev_solid, SOLID_NOT) for owner. This mean that the owner can't touch the box, it will walk trough it.
Function public fwd_Touch(toucher, touched) will not work for owner, so the owner can't receive the bonus.
Bladell 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 21:16.


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