Raised This Month: $ Target: $400
 0% 

[SOLVED]Get Grenade Owner From Event


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
devilicioux
Veteran Member
Join Date: Jun 2013
Location: Delhi,India
Old 06-27-2014 , 14:20   [SOLVED]Get Grenade Owner From Event
Reply With Quote #1

Okay So i have these functions and Event hook i took from https://forums.alliedmods.net/showthread.php?p=77288 (Cluster Grenades) ..
What i am trying to do is .. Get who threw the He grenade using the stock .. Store the value returned by stock into the id..
That id is passed into a variable g_clusters[id] .. which decides the iterations of for loop.

But this all above doesnt seem to work right.. because Nade Clusters should be According to value in g_clusters[id] but still i am getting a 0 clusters what so ever the value in g_clusters[id]
(Because i am still a learner and not a pro )

Debug Results :
1. Works when i play alone .. and Fails when there are more players or bots
2. Stock isnt able to return grenade owner id in the grenade_explosion function

So any suggestions or someone can explain or help me out with the understanding part specially the stock or some alternative ?

PHP Code:
register_message23"grenade_explosion" 
PHP Code:
public grenade_explosion() {
    if (
get_msg_arg_int) == && get_msg_arg_int ) == 25 && get_msg_arg_int ) == 30) {
        new 
pos[3]
        
pos[0] = floatroundget_msg_arg_float) )
        
pos[1] = floatroundget_msg_arg_float) )
        
pos[2] = floatroundget_msg_arg_float) )
 
        new 
clusterFloat:vAngle[3], Float:angles[3], Float:velocity[3], Rvelocity[3], Float:distanceFloat:actualDistanceFloat:multiplier
 
        
new Float:origin[3
        
origin[0] = floatpos[0] )
        
origin[1] = floatpos[1] )
        
origin[2] = floatpos[2] )
 
        new 
Float:minBox[3] = { -1.0, ... }
        new 
Float:maxBox[3] = { 1.0, ... }
 
        new 
id=get_grenade_owner()
 
        
//This will launch the above specified number of clusters
        
for (new 0g_clusters[id]; i++) {
            
//Create a random direction for the cluster to fly
            
velocity[0] = random_floatfloatMIN_FLY_DISTANCE ), floatMAX_FLY_DISTANCE ) )
            if ( 
random_num0) == velocity[0] = floatmulvelocity[0], -1.0 )
            
velocity[1] = random_floatfloatMIN_FLY_DISTANCE ), floatMAX_FLY_DISTANCE ) )
            if ( 
random_num0) == velocity[1] = floatmulvelocity[1], -1.0 )
            
velocity[2] = floatUPWARD_ARC )
 
            
Rvelocity[0] = pos[0] + floatroundvelocity[0] )
            
Rvelocity[1] = pos[1] + floatroundvelocity[1] )
            
Rvelocity[2] = pos[2] + floatroundvelocity[2] )
 
            
//Create the distance the cluster will fly
            
distance random_floatfloatMIN_FLY_DISTANCE ), floatMAX_FLY_DISTANCE ) )
            
actualDistance floatget_distanceposRvelocity ) )
            
multiplier floatdivdistanceactualDistance )
 
 
            
velocity[0] = floatmulvelocity[0], multiplier )
            
velocity[1] = floatmulvelocity[1], multiplier )
            
velocity[2] = floatmulvelocity[2], multiplier )
 
            
//Create the angles for the facing of the cluster. PS: I have no idea how to do the angle thing really. This is a blind attempt.
            
vector_to_anglevelocityangles )
            
vector_to_anglevelocityvAngle )
 
            
//Create the entity of the cluster
            
cluster create_entity"info_target" )
 
            
//Set the identifying string of the cluster's entity
            
entity_set_stringclusterEV_SZ_classname"grenade_cluster"
 
            
//Set the model for the cluster's entity
            
entity_set_modelcluster"models/grenade.mdl" )     
 
            
//Set the bounds for the cluster's entity    
            
entity_set_vectorclusterEV_VEC_minsminBox)
            
entity_set_vectorclusterEV_VEC_maxsmaxBox)
 
            
//Set the origin for the cluster's entity (NOTE: The clusters will spawn in the same spot, but they will be set to ignore eachother
            
entity_set_originclusterorigin )
 
            
//Set the angles of the cluster's entity    
            
entity_set_vectorclusterEV_VEC_anglesangles )
            
entity_set_vectorclusterEV_VEC_v_anglevAngle )
 
            
//Set the behavior specific variables for the cluster's entity
            
entity_set_intclusterEV_INT_movetype//Has gravity and registers collisions
            
entity_set_intclusterEV_INT_solid//Collisions do not block
 
            //Record who the owner of this nade is
            
entity_set_edictclusterEV_ENT_ownerget_grenade_owner() )
 
            
//Make the cluster fly!
            
entity_set_vectorclusterEV_VEC_velocityvelocity 
        }
    }
 
    return 
PLUGIN_CONTINUE

PHP Code:
stock get_grenade_owner() {
    new 
which grenade[0]
    for ( new 
132i++ ) {
        
grenade[1] = grenade[i]
    }
    
grenade[31] = 0
 
    
return which

__________________
You keep bringing ANTICHRISTUS down .. He will rise again and kick asses !

#RespectList ANTICHRISTUS fysiks Bugsy

Most Common Errors You Can Encounter Every Now and Then

Last edited by devilicioux; 06-30-2014 at 07:11. Reason: appending solved
devilicioux is offline
 



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:09.


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