Raised This Month: $ Target: $400
 0% 

EntSpawn in progress


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ts2do
Senior Member
Join Date: Mar 2004
Old 06-02-2004 , 23:25   EntSpawn in progress
Reply With Quote #1

ok Im workin on an amxx plugin called EntSpawn which will spawn entities into a map directly
I have a pretty solid structure for it so far but the only problem is that I cant see the entities in game!
Heres the code:
Code:
#include<amxmodx> #include<amxmisc> #include<engine> new fileName[128], mapName[128], customdir[128], debug new const intkeys[37][] = {     "gamestate",     "oldbuttons",     "groupinfo",     "iuser1",     "iuser2",     "iuser3",     "iuser4",     "weaponanim",     "pushmsec",     "bInDuck",     "flTimeStepSound",     "flSwimTime",     "flDuckTime",     "iStepLeft",     "movetype",     "solid",     "skin",     "body",     "effects",     "light_level",     "sequence",     "gaitsequence",     "modelindex",     "playerclass",     "waterlevel",     "watertype",     "spawnflags",     "flags",     "colormap",     "team",     "fixangle",     "weapons",     "rendermode",     "renderfx",     "button",     "impulse",     "deadflag" } new const floatkeys[37][] = {     "impacttime",     "starttime",     "idealpitch",     "pitch_speed",     "ideal_yaw",     "yaw_speed",     "ltime",     "nextthink",     "gravity",     "friction",     "frame",     "animtime",     "framerate",     "health",     "frags",     "takedamage",     "max_health",     "teleport_time",     "armortype",     "armorvalue",     "dmg_take",     "dmg_save",     "dmg",     "dmgtime",     "speed",     "air_finished",     "pain_finished",     "radsuit_finished",     "scale",     "renderamt",     "maxspeed",     "fov",     "flFallVelocity",     "fuser1",     "fuser2",     "fuser3",     "fuser4" } new const vectorkeys[23][] = {     "origin",     "oldorigin",     "velocity",     "basevelocity",     "clbasevelocity",     "movedir",     "angles",     "avelocity",     "punchangle",     "v_angle",     "endpos",     "startpos",     "absmin",     "absmax",     "mins",     "maxs",     "size",     "rendercolor",     "view_ofs",     "vuser1",     "vuser2",     "vuser3",     "vuser4" } new const edictkeys[11][] = {     "chain",     "dmg_inflictor",     "enemy",     "aiment",     "owner",     "groundentity",     "pContainingEntity",     "euser1",     "euser2",     "euser3",     "euser4" } new const strkeys[13][] = {     "classname",     "globalname",     "model",     "target",     "targetname",     "netname",     "message",     "noise",     "noise1",     "noise2",     "noise3",     "viewmodel",     "weaponmodel" } new const bytekeys[6][] = {     "controller1",     "controller2",     "controller3",     "controller4",     "blending1",     "blending2" } new const position[4][] = {     "Current position",     "Position from eyes",     "End position from player position",     "End position from eyes" } public retorigins(id){     new origin[3], x     for(x = 0;x<=4;x++){         get_user_origin(id,origin,x)         client_print(id,print_console,"[EntSpawn] %s: %i %i %i", position[x], origin[0], origin[1], origin[2])     }     client_print(id,print_chat,"[EntSpawn] Origins have been printed to console.")     return PLUGIN_HANDLED } public plugin_init(){     register_plugin("Entity Spawn","0.1","ts2do")     register_cvar("es_debug","1")     register_clcmd("say /origins","retorigins")     if(file_exists(fileName)){loadentsfromfile(fileName);}     //PAUSED FOR NOW, GOTTA ADD A PRECACHE FOR THESE register_concmd("amx_loadents","loadents") } /*public loadents(id, level, cid){     if(cmd_access(id,level,cid,2)){         new file[128]         read_argv(1,file,127)         format(file,127,"%s/entities/%s.ini",customdir,file)         if(file_exists(file)){loadprecache(file);loadentsfromfile(file)         }else if(!id){server_print("[EntSpawn] File %s not present.",file)         }else{client_print(id,print_console,"[EntSpawn] File %s not present.",file);}     } }*/ public loadentsfromfile(file[]){     debug=get_cvar_num("es_debug")     server_print("[EntSpawn] Started reading from %s", file)     new text[128], txtlen, x, y, z, arg[2][64], iEnt, bool:set=false, Float:vector[3], strvector[3][32]     while ( x<file_size(file,1) ) {         read_file( file, x, text, 127, txtlen )         if(equal(text,"entity{")) {             x++             read_file( file, x, text, 127, txtlen )             replace(text,127,"  ","")             iEnt = create_entity(text)             if(debug){                 server_print("[EntSpawn]  Started entity %s with index %i",text, iEnt)             }             while(!equal(text,"}")){                 x++                 read_file( file, x, text, 127, txtlen )                 parse(text,arg[0],63,arg[1],63)                 if(!equal(text,"}")){                     remove_quotes(arg[0])                     remove_quotes(arg[1])                     if(debug){                         server_print("[EntSpawn]   Set key ^"%s^" to value ^"%s^"",arg[0],arg[1])                     }                     for(y=0;y<=36;y++){                         if(equali(intkeys[y],arg[0])){                             entity_set_int(iEnt,y,str_to_num(arg[1]))                             set=true                         }                     }                     if(!set){                         for(y=0;y<=36;y++){                             if(equali(floatkeys[y],arg[0])){                                 entity_set_float(iEnt,y,floatstr(arg[1]))                                 set=true                             }                         }                     }                     if(!set){                         for(y=0;y<=23;y++){                             if(equali(vectorkeys[y],arg[0])){                                 parse(arg[1],strvector[0],31,strvector[1],31,strvector[2],31)                                 for(z=0;z<=2;z++){                                     vector[z]=floatstr(strvector[z])                                 }                                 if(y==EV_VEC_origin){                                     entity_set_origin(iEnt,vector)                                 }else{                                     entity_set_vector(iEnt,y,vector)                                 }                                 set=true                             }                         }                     }                     if(!set){                         for(y=0;y<=10;y++){                             if(equali(edictkeys[y],arg[0])){                                 if(is_valid_ent(str_to_num(arg[1]))){                                     entity_set_edict(iEnt,y,str_to_num(arg[1]))                                 }                                 set=true                             }                         }                     }                     if(!set){                         for(y=0;y<=12;y++){                             if(equali(strkeys[y],arg[0])){                                 if(y==EV_SZ_model){                                     entity_set_model(iEnt,arg[1])                                 }else{                                     DispatchKeyValue(iEnt,arg[0],arg[1])                                 }                                 set=true                             }                         }                     }                     if(!set){                         for(y=0;y<=5;y++){                             if(equali(bytekeys[y],arg[0])){                                 entity_set_byte(iEnt,y,str_to_num(arg[1]))                                 set=true                             }                         }                     }                     set=false                 }             }             if(debug){                 entity_get_string(iEnt,EV_SZ_classname,text,127)                 server_print("[EntSpawn]  Finished entity %s with index %i", text, iEnt)             }             new Float:vec[3] = {748.0, 3043.0, 36.0}             entity_set_origin(iEnt,vec)         }         x++     }     if(debug){server_print("[EntSpawn] Finished reading from %s", file);} } public plugin_precache(){     debug=get_cvar_num("es_debug")     get_mapname(mapName,32)     get_localinfo("amxx_customdir",customdir,127)     format(fileName,127,"%s/entities/%s.ini",customdir,mapName)     loadprecache(fileName) } public loadprecache(file[]){     if(file_exists(file)){         new text[128], txtlen, x         while ( x<file_size(file,1) ) {             read_file( file, x, text, 127, txtlen )             if(equal(text,"precache{")) {                 x++                 read_file( file, x, text, 127, txtlen )                 replace(text,127,"  ","")                 remove_quotes(text)                 while(!equal(text,"}")){                     if(file_exists(text)){                         if(containi(text,".spr")||containi(text,".mdl")) {                             precache_model(text)                             if(debug){                                 server_print("[EntSpawn] Precached model %s",text)                             }                         } else if(containi(text,".wav")) {                             precache_sound(text)                             if(debug){                                 server_print("[EntSpawn] Precached sound %s", text)                             }                         } else {                             precache_generic(text)                             if(debug){                                 server_print("[EntSpawn] Precached file %s", text)                             }                         }                     }else{                         if(debug){                             server_print("[EntSpawn] Faulty precache for %s", text)                         }                     }                     x++                     read_file( file, x, text, 31, txtlen )                 }             }             x++         }     }else{         if(debug){server_print("[EntSpawn] File %s not present.",file);}     } }
and heres an example of a map file (addons\amxx\custom\entities\de_dust.ini)
Code:
precache{
	models/aaablock.mdl
}
entity{
	info_target
		model models/aaablock.mdl
		origin "748 3043 36"
		movetype 5
		classname block
		body 1
		sequence 1
		solid 2
		mins "-20 -20 -20"
		maxs "20 20 20"
}
__________________
ts2do is offline
Send a message via AIM to ts2do
BAILOPAN
Join Date: Jan 2004
Old 06-03-2004 , 01:42  
Reply With Quote #2

create_entity("info_target")
Creating an info_target isn't a gateway to ANY entity, it's a gateway to making your own random entities. You may run into problems if you expect certain items to act differently (mod special things).

Also: "model" needs to be set, with entity_set_model, I don't see that anywhere in the code, so that's probably where it isn't working. You may need to write in a parse exception for that case.
__________________
egg
BAILOPAN is offline
ts2do
Senior Member
Join Date: Mar 2004
Old 06-03-2004 , 12:24  
Reply With Quote #3

I make it go thru a loop and test if the key is equal to the string "model" in the list...the const strings at the top coorespond with the EV_SZ_model...and the classname is set to something else also...it loads an info_target but is changed later in the script
__________________
ts2do is offline
Send a message via AIM to ts2do
BAILOPAN
Join Date: Jan 2004
Old 06-03-2004 , 13:55  
Reply With Quote #4

You're not listening, setting EV_SZ_model doesn't do anything. I just said there's a separate call for that.

entity_set_model and entity_set_origin replace EV_SZ_model and EV_VEC_origin.

Furthermore, simply changing the classname from info_target isn't the same thing, it doesn't become a "real" copy of the entity. To do that you have to either create it as its initially intended or use DispatchKeyValue.
__________________
egg
BAILOPAN is offline
ts2do
Senior Member
Join Date: Mar 2004
Old 06-03-2004 , 21:34  
Reply With Quote #5

there, I edited it, now it has what u said
__________________
ts2do is offline
Send a message via AIM to ts2do
ts2do
Senior Member
Join Date: Mar 2004
Old 06-03-2004 , 22:04  
Reply With Quote #6

oh u wanna kno what else I think should be in .2 I think there should be a thing in entity_set_string(id,EV_SZ_model,"modelname") to automatically redirect it to using entitiy_set_model
__________________
ts2do is offline
Send a message via AIM to ts2do
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:40.


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