AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Entity Keys (https://forums.alliedmods.net/showthread.php?t=11567)

More 03-23-2005 14:37

Entity Keys
 
Hi, I have a question, possible you can help me:
some entities, in my case the entity info_tfgoal in a tfc map,
have some entity-keys that seem to be not include by the engine-module,
like maxammo_shells or team1_name.
Is there a way to create an entity with these values??
in the map editor "hammer" there you can create an entity with these values so they must exist.
any ideas?

Johnny got his gun 03-23-2005 14:46

I think you should use this:

Code:
/* 2 formats.    Format: DispatchKeyValue("KeyName","Value") - sets keyvalues for the entity specified in the keyvalue() forward.    Format: DispatchKeyValue(index,"KeyName","Value") - Sets keyvalue for entity not specified in keyvalue() forward. */ native DispatchKeyValue(...);

Then spawn the entity.

More 03-23-2005 14:52

thx very much

Twilight Suzuka 03-23-2005 15:11

Make certain you use DispatchSpawn(ent) to spawn the entity, after setting keys on it.

More 03-23-2005 15:16

when retrieving entity information i always get an empty string. whats wrong with this code?
Code:
#include <amxmodx> #include <engine> #include <amxmisc> public plugin_init() {   register_plugin("Map Imformation", "0.1", "More")   register_clcmd("amx_mapinfo", "admin_mapinfo", ADMIN_CVAR) } public admin_mapinfo(id, level, cid) {   if (!cmd_access(id, level, cid, 1)) {     return PLUGIN_HANDLED   }   new entity = find_ent_by_class(-1, "info_tfdetect")   if (entity > 0) {     new info[32]     get_keyvalue(entity, "maxammo_shells", info, 31)     client_print(id, print_console, "The info is: ^"%s^"", info)   }   else {     client_print(id, print_console, "The entity info_tfdetect does not exist!")   }   return PLUGIN_HANDLED }

sry when i express me wrong.
my goal is to check the values on the entity info_tfgoal and change it when required.

another question: returns the command get_keyvalue always a string?

Johnny got his gun 03-23-2005 16:12

As soon as an entity is spawned, I don't think you should/can use keyvalues anymore. Those are only used in map files.

XxAvalanchexX 03-23-2005 17:12

Quote:

Originally Posted by BAILOPAN
hook keyvalue forwards and use copy_keyvalue. get_keyvalue is a useless native and does not work as you think it does ;]


Johnny got his gun 03-23-2005 19:46

1 Attachment(s)
Just realized that Fakemeta module never implemented the FM_KeyValue forward. So, a few hours later, here's a test build. Guess I will add it to CVS soon, you can try it out here though.

Quite cool, in fy_iceworld I was able to hook the setting of the onground weapons, and put 5 weapons on each place instead of just one.... using this script:

Code:
public forward_keyvalue(ent) {     //new classname[64],     //get_kv(KV_ClassName, classname, 63)     new keyname[64], value[64]     get_kv(KV_KeyName, keyname, 63)     get_kv(KV_Value, value, 63)     //new ret = get_kv(KV_fHandled)     //server_print("KeyValue(%d, ^"%s^", ^"%s^", ^"%s^", %d)", ent, classname, keyname, value, ret)     if (equal(keyname, "count") && equal(value, "1"))         set_kv(KV_Value, "5")     return FMRES_IGNORED } public plugin_precache() {     register_forward(FM_KeyValue, "forward_keyvalue") }


See if you can make something other cool out of it... maybe replace all weapons of a certain type with another. I think you should be able to replace all awps to scouts, etc....

Edit: Here's how to switch onground awps to scouts... as expected:
Code:
if (equal(classname, "armoury_entity") && equal(keyname, "item") && equal(value, "10"))     set_kv(KV_Value, "8")

Not very surprisingly, these values follow the mod's FGD file.

Twilight Suzuka 03-23-2005 20:24

So wait, you guys forgot the key values in FM?

Johnny got his gun 03-23-2005 20:51

Not _forgot_. It was just a large project and 98% of it was done anyway. At the time it was "enough", and everyone (at least those who worked on it, primarily sawce) got fed up with all the repetitive tasks...
There might still be a few things still not taken care of in there... :roll:


All times are GMT -4. The time now is 09:51.

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