AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Origin of an entity? (https://forums.alliedmods.net/showthread.php?t=24743)

mysticssjgoku4 03-01-2006 20:31

Origin of an entity?
 
I've been searching around and I can't seem to find it, but how can I get the origin of a non-player entity by entid?

Thanks
---
This is what I have so far:

Code:
public item_c4_detonator() {     new arg[32]     read_argv(1,arg,31)         new id = str_to_num(arg)         new entid = find_ent_by_owner(id,"info_target",id)         new Float:vector[3]     //entity_get_vector(entid,EV_VEC_origin,vector)     get_brush_entity_origin(entid,vector)         new origin[3]     format(origin,0,"%f",vector[0])     format(origin,1,"%f",vector[1])     format(origin,2,"%f",vector[2])     basic_explosion(origin)         return PLUGIN_HANDLED }

Des12 03-01-2006 21:19

Code:
new Float:origin[3]; entity_get_vector(entid, EV_VEC_origin, origin);

See if this works Remo, I do not know why you had it commented out

mysticssjgoku4 03-01-2006 21:43

My origin cannot be a float, and it keeps giving me errors when I try to use float_to_str.

Code:
public item_c4_detonator() {     new arg[32]     read_argv(1,arg,31)         new id = str_to_num(arg)         for(new i=0;i<4;i++) {         new entid = find_ent_by_owner(id,"info_target",id)                 new Float:origin[3]         entity_get_vector(entid,EV_VEC_origin,origin)         //get_brush_entity_origin(entid,vector)             new norigin[3]         float_to_str(Float:origin,norigin,3)             basic_explosion(norigin)     }     //format(origin,0,"%f",vector[0])     //format(origin,1,"%f",vector[1])     //format(origin,2,"%f",vector[2])         return PLUGIN_HANDLED }

Kraugh 03-01-2006 22:02

Code:
new origin[3], Float:originF[3]; entity_get_vector(ent,EV_VEC_origin,originF); FVecIVec(originF,origin);

mysticssjgoku4 03-01-2006 22:13

Ok, I think this is wrong....keeps returning 0.

Code:
new entid = find_ent_by_owner(id,"info_target",id)

Code:
public item_c4_detonator() {     new arg[32]     read_argv(1,arg,31)         new id = str_to_num(arg)         for(new i=0;i<4;i++) {         new entid = find_ent_by_owner(id,"info_target",id)                 //new Float:origin[3]         //entity_get_vector(entid,EV_VEC_origin,origin)         //get_brush_entity_origin(entid,vector)             //new norigin[3]         //float_to_str(origin,norigin,3)                 new origin[3], Float:originF[3];         entity_get_vector(entid,EV_VEC_origin,originF);         FVecIVec(originF,origin);               basic_explosion(origin)         client_print(id,print_chat,"[ItemMod] C4 Successfully Exploded!")     }         //format(origin,0,"%f",vector[0])     //format(origin,1,"%f",vector[1])     //format(origin,2,"%f",vector[2])         return PLUGIN_HANDLED }

v3x 03-01-2006 22:54

No clue as to what you're trying to do.

My guess:
Code:
public item_c4_detonator() {     new arg[32]     read_argv(1,arg,31)     new id = cmd_target(0 , arg , 0);     if(!id) return PLUGIN_HANDLED;         new entid = find_ent_by_owner(-1,"info_target",id)             while(entid != 0) {         new origin[3], Float:originF[3];         entity_get_vector(entid,EV_VEC_origin,originF);         FVecIVec(originF,origin);               basic_explosion(origin)         client_print(id,print_chat,"[ItemMod] C4 Successfully Exploded!")     }     return PLUGIN_HANDLED }

mysticssjgoku4 03-01-2006 23:54

hmm, didn't work, said the player was not found with the cmd_target.

Kraugh 03-01-2006 23:55

cmd_target does not function correctly with an id of 0. just use the function that it is built around:

Code:
new id = find_player("bl",arg);

[edit]
this won't fix the problem of the player not being found

mysticssjgoku4 03-02-2006 00:05

Fixed it, I forgot to add the remove_ent.

Alright, How do I make it so that all of them are exploded at the same time. My FOR loop didn't work.

Code:
public item_c4det() {     new arg[32]     read_argv(1,arg,31)     new id = str_to_num(arg)     if(!id) {         client_print(id,print_chat,"[ItemMod] ID1: %i",id)         return PLUGIN_HANDLED     }         client_print(id,print_chat,"[ItemMod] ID2: %i",id)         for(new i = 0; i < 4; i++) {                 new entid = find_ent_by_owner(id,"item_c4",id)         //new entid2 = find_ent_by_owner(id,"item_c4",id)             client_print(id,print_chat,"[ItemMod] EntId: %i",entid)         //client_print(id,print_chat,"[ItemMod] EntId2: %i",entid2)                   while(entid != 0) {             new origin[3], Float:originF[3];               entity_get_vector(entid,EV_VEC_origin,originF);               FVecIVec(originF,origin);                     basic_explosion_c4(origin)             client_print(id,print_chat,"[ItemMod] C4 Successfully Exploded!")             remove_entity(entid)             c4limit[id] -= 1             radius_damage(originF,300,200)         }     }     return PLUGIN_HANDLED }

Also, what does each one of these lines represent, I seen another topic with a description of these, but the lines didn't match up, so I was confused.

Code:
// A Basic Explosion stock basic_explosion_c4(origin[3])     {     message_begin( MSG_BROADCAST,SVC_TEMPENTITY)     write_byte( 12 )     write_coord(origin[0]) //coord, coord, coord (start)     write_coord(origin[1])     write_coord(origin[2])     write_byte( 200 ) // byte (scale in 0.1's) 188     write_byte( 10 ) // byte (framerate)     message_end()         message_begin( MSG_BROADCAST,SVC_TEMPENTITY)     write_byte( 3 )     write_coord(origin[0]) //coord, coord, coord (start)     write_coord(origin[1])     write_coord(origin[2])     write_short( fire )     write_byte( 60 )     write_byte( 10 )     write_byte( 0 )     message_end()     return PLUGIN_HANDLED }

Des12 03-02-2006 22:03

I would suggest making an global variable such as

Code:
new g_c4count[33]; new g_c4store[33][5]; // . . . public item_c4det() {     new arg[32]     read_argv(1,arg,31)     new id = str_to_num(arg)     if(!id) {         client_print(id,print_chat,"[ItemMod] ID1: %i",id)         return PLUGIN_HANDLED     }         client_print(id,print_chat,"[ItemMod] ID2: %i",id)        for( new i = 0; i < g_c4count[id]; i++) {                 new entid = g_c4store[id][i];         //new entid2 = find_ent_by_owner(id,"item_c4",id)             client_print(id,print_chat,"[ItemMod] EntId: %i",entid)         //client_print(id,print_chat,"[ItemMod] EntId2: %i",entid2)                   while(entid != 0) {             new origin[3], Float:originF[3];               entity_get_vector(entid,EV_VEC_origin,originF);               FVecIVec(originF,origin);                     basic_explosion_c4(origin)             client_print(id,print_chat,"[ItemMod] C4 Successfully Exploded!")             remove_entity(entid)             c4limit[id] -= 1             radius_damage(originF,300,200)         }     }     return PLUGIN_HANDLED }


All times are GMT -4. The time now is 20:17.

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